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 "base/memory/raw_ptr.h" 10 #include "components/nacl/common/nacl.mojom.h" 11 #include "mojo/public/cpp/bindings/pending_receiver.h" 12 #include "mojo/public/cpp/bindings/pending_remote.h" 13 #include "mojo/public/cpp/bindings/receiver.h" 14 #include "mojo/public/cpp/bindings/remote.h" 15 #include "native_client/src/trusted/service_runtime/nacl_error_code.h" 16 #include "ppapi/c/pp_instance.h" 17 18 namespace nacl { 19 class NexeLoadManager; 20 21 class TrustedPluginChannel : public mojom::NaClRendererHost { 22 public: 23 TrustedPluginChannel(NexeLoadManager* nexe_load_manager, 24 mojo::PendingReceiver<mojom::NaClRendererHost> receiver, 25 bool is_helper_nexe); 26 27 TrustedPluginChannel(const TrustedPluginChannel&) = delete; 28 TrustedPluginChannel& operator=(const TrustedPluginChannel&) = delete; 29 30 ~TrustedPluginChannel() override; 31 32 private: 33 void OnChannelError(); 34 35 // mojom::NaClRendererHost overrides. 36 void ReportExitStatus(int exit_status, 37 ReportExitStatusCallback callback) override; 38 void ReportLoadStatus(NaClErrorCode load_status, 39 ReportLoadStatusCallback callback) override; 40 void ProvideExitControl( 41 mojo::PendingRemote<mojom::NaClExitControl> exit_control) override; 42 43 // Non-owning pointer. This is safe because the TrustedPluginChannel is owned 44 // by the NexeLoadManager pointed to here. 45 raw_ptr<NexeLoadManager> nexe_load_manager_; 46 mojo::Receiver<mojom::NaClRendererHost> receiver_; 47 mojo::Remote<mojom::NaClExitControl> exit_control_; 48 const bool is_helper_nexe_; 49 }; 50 51 } // namespace nacl 52 53 #endif // COMPONENTS_NACL_RENDERER_TRUSTED_PLUGIN_CHANNEL_H_ 54