1 // Copyright 2014 The Chromium Authors 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef COMPONENTS_NACL_RENDERER_TRUSTED_PLUGIN_CHANNEL_H_ 6 #define COMPONENTS_NACL_RENDERER_TRUSTED_PLUGIN_CHANNEL_H_ 7 8 #include "base/functional/callback.h" 9 #include "components/nacl/common/nacl.mojom.h" 10 #include "mojo/public/cpp/bindings/pending_receiver.h" 11 #include "mojo/public/cpp/bindings/pending_remote.h" 12 #include "mojo/public/cpp/bindings/receiver.h" 13 #include "mojo/public/cpp/bindings/remote.h" 14 #include "native_client/src/trusted/service_runtime/nacl_error_code.h" 15 #include "ppapi/c/pp_instance.h" 16 17 namespace nacl { 18 class NexeLoadManager; 19 20 class TrustedPluginChannel : public mojom::NaClRendererHost { 21 public: 22 TrustedPluginChannel(NexeLoadManager* nexe_load_manager, 23 mojo::PendingReceiver<mojom::NaClRendererHost> receiver, 24 bool is_helper_nexe); 25 26 TrustedPluginChannel(const TrustedPluginChannel&) = delete; 27 TrustedPluginChannel& operator=(const TrustedPluginChannel&) = delete; 28 29 ~TrustedPluginChannel() override; 30 31 private: 32 void OnChannelError(); 33 34 // mojom::NaClRendererHost overrides. 35 void ReportExitStatus(int exit_status, 36 ReportExitStatusCallback callback) override; 37 void ReportLoadStatus(NaClErrorCode load_status, 38 ReportLoadStatusCallback callback) override; 39 void ProvideExitControl( 40 mojo::PendingRemote<mojom::NaClExitControl> exit_control) override; 41 42 // Non-owning pointer. This is safe because the TrustedPluginChannel is owned 43 // by the NexeLoadManager pointed to here. 44 NexeLoadManager* nexe_load_manager_; 45 mojo::Receiver<mojom::NaClRendererHost> receiver_; 46 mojo::Remote<mojom::NaClExitControl> exit_control_; 47 const bool is_helper_nexe_; 48 }; 49 50 } // namespace nacl 51 52 #endif // COMPONENTS_NACL_RENDERER_TRUSTED_PLUGIN_CHANNEL_H_ 53