| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef COMPONENTS_NACL_RENDERER_TRUSTED_PLUGIN_CHANNEL_H_ | 5 #ifndef COMPONENTS_NACL_RENDERER_TRUSTED_PLUGIN_CHANNEL_H_ |
| 6 #define COMPONENTS_NACL_RENDERER_TRUSTED_PLUGIN_CHANNEL_H_ | 6 #define COMPONENTS_NACL_RENDERER_TRUSTED_PLUGIN_CHANNEL_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "components/nacl/common/nacl.mojom.h" | 12 #include "ipc/ipc_listener.h" |
| 13 #include "mojo/public/cpp/bindings/binding.h" | |
| 14 #include "native_client/src/trusted/service_runtime/nacl_error_code.h" | 13 #include "native_client/src/trusted/service_runtime/nacl_error_code.h" |
| 15 #include "ppapi/c/pp_instance.h" | 14 #include "ppapi/c/pp_instance.h" |
| 16 | 15 |
| 16 namespace base { |
| 17 class WaitableEvent; |
| 18 } // namespace base |
| 19 |
| 20 namespace IPC { |
| 21 struct ChannelHandle; |
| 22 class Message; |
| 23 class SyncChannel; |
| 24 } // namespace IPC |
| 25 |
| 17 namespace nacl { | 26 namespace nacl { |
| 18 class NexeLoadManager; | 27 class NexeLoadManager; |
| 19 | 28 |
| 20 class TrustedPluginChannel : public mojom::NaClRendererHost { | 29 class TrustedPluginChannel : public IPC::Listener { |
| 21 public: | 30 public: |
| 22 TrustedPluginChannel(NexeLoadManager* nexe_load_manager, | 31 TrustedPluginChannel(NexeLoadManager* nexe_load_manager, |
| 23 mojom::NaClRendererHostRequest request, | 32 const IPC::ChannelHandle& handle, |
| 33 base::WaitableEvent* shutdown_event, |
| 24 bool is_helper_nexe); | 34 bool is_helper_nexe); |
| 25 ~TrustedPluginChannel() override; | 35 ~TrustedPluginChannel() override; |
| 26 | 36 |
| 37 bool Send(IPC::Message* message); |
| 38 |
| 39 // Listener implementation. |
| 40 bool OnMessageReceived(const IPC::Message& message) override; |
| 41 void OnChannelError() override; |
| 42 |
| 43 void OnReportExitStatus(int exit_status); |
| 44 void OnReportLoadStatus(NaClErrorCode load_status); |
| 45 |
| 27 private: | 46 private: |
| 28 void OnChannelError(); | |
| 29 | |
| 30 // mojom::NaClRendererHost overrides. | |
| 31 void ReportExitStatus(int exit_status, | |
| 32 const ReportExitStatusCallback& callback) override; | |
| 33 void ReportLoadStatus(NaClErrorCode load_status, | |
| 34 const ReportLoadStatusCallback& callback) override; | |
| 35 void ProvideExitControl(mojom::NaClExitControlPtr exit_control) override; | |
| 36 | |
| 37 // Non-owning pointer. This is safe because the TrustedPluginChannel is owned | 47 // Non-owning pointer. This is safe because the TrustedPluginChannel is owned |
| 38 // by the NexeLoadManager pointed to here. | 48 // by the NexeLoadManager pointed to here. |
| 39 NexeLoadManager* nexe_load_manager_; | 49 NexeLoadManager* nexe_load_manager_; |
| 40 mojo::Binding<mojom::NaClRendererHost> binding_; | 50 std::unique_ptr<IPC::SyncChannel> channel_; |
| 41 mojom::NaClExitControlPtr exit_control_; | 51 bool is_helper_nexe_; |
| 42 const bool is_helper_nexe_; | |
| 43 | 52 |
| 44 DISALLOW_COPY_AND_ASSIGN(TrustedPluginChannel); | 53 DISALLOW_COPY_AND_ASSIGN(TrustedPluginChannel); |
| 45 }; | 54 }; |
| 46 | 55 |
| 47 } // namespace nacl | 56 } // namespace nacl |
| 48 | 57 |
| 49 #endif // COMPONENTS_NACL_RENDERER_TRUSTED_PLUGIN_CHANNEL_H_ | 58 #endif // COMPONENTS_NACL_RENDERER_TRUSTED_PLUGIN_CHANNEL_H_ |
| OLD | NEW |