OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_BROKER_NACL_BROKER_LISTENER_H_ | 5 #ifndef COMPONENTS_NACL_BROKER_NACL_BROKER_LISTENER_H_ |
6 #define COMPONENTS_NACL_BROKER_NACL_BROKER_LISTENER_H_ | 6 #define COMPONENTS_NACL_BROKER_NACL_BROKER_LISTENER_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "base/process/process.h" | 12 #include "base/process/process.h" |
13 #include "components/nacl/common/nacl_types.h" | 13 #include "components/nacl/common/nacl_types.h" |
14 #include "content/public/common/sandboxed_process_launcher_delegate.h" | 14 #include "content/public/common/sandboxed_process_launcher_delegate.h" |
15 #include "ipc/ipc_listener.h" | 15 #include "ipc/ipc_listener.h" |
16 | 16 |
17 namespace IPC { | 17 namespace IPC { |
18 class AttachmentBrokerUnprivileged; | |
19 class Channel; | 18 class Channel; |
20 } | 19 } |
21 | 20 |
22 // The BrokerThread class represents the thread that handles the messages from | 21 // The BrokerThread class represents the thread that handles the messages from |
23 // the browser process and starts NaCl loader processes. | 22 // the browser process and starts NaCl loader processes. |
24 class NaClBrokerListener : public content::SandboxedProcessLauncherDelegate, | 23 class NaClBrokerListener : public content::SandboxedProcessLauncherDelegate, |
25 public IPC::Listener { | 24 public IPC::Listener { |
26 public: | 25 public: |
27 NaClBrokerListener(); | 26 NaClBrokerListener(); |
28 ~NaClBrokerListener() override; | 27 ~NaClBrokerListener() override; |
29 | 28 |
30 void Listen(); | 29 void Listen(); |
31 | 30 |
32 // content::SandboxedProcessLauncherDelegate implementation: | 31 // content::SandboxedProcessLauncherDelegate implementation: |
33 bool PreSpawnTarget(sandbox::TargetPolicy* policy) override; | 32 bool PreSpawnTarget(sandbox::TargetPolicy* policy) override; |
34 | 33 |
35 // IPC::Listener implementation. | 34 // IPC::Listener implementation. |
36 void OnChannelConnected(int32_t peer_pid) override; | 35 void OnChannelConnected(int32_t peer_pid) override; |
37 bool OnMessageReceived(const IPC::Message& msg) override; | 36 bool OnMessageReceived(const IPC::Message& msg) override; |
38 void OnChannelError() override; | 37 void OnChannelError() override; |
39 | 38 |
40 private: | 39 private: |
41 void OnLaunchLoaderThroughBroker(const std::string& loader_channel_id); | 40 void OnLaunchLoaderThroughBroker(const std::string& loader_channel_id); |
42 void OnLaunchDebugExceptionHandler(int32_t pid, | 41 void OnLaunchDebugExceptionHandler(int32_t pid, |
43 base::ProcessHandle process_handle, | 42 base::ProcessHandle process_handle, |
44 const std::string& startup_info); | 43 const std::string& startup_info); |
45 void OnStopBroker(); | 44 void OnStopBroker(); |
46 | 45 |
47 base::Process browser_process_; | 46 base::Process browser_process_; |
48 scoped_ptr<IPC::AttachmentBrokerUnprivileged> attachment_broker_; | |
49 scoped_ptr<IPC::Channel> channel_; | 47 scoped_ptr<IPC::Channel> channel_; |
50 | 48 |
51 DISALLOW_COPY_AND_ASSIGN(NaClBrokerListener); | 49 DISALLOW_COPY_AND_ASSIGN(NaClBrokerListener); |
52 }; | 50 }; |
53 | 51 |
54 #endif // COMPONENTS_NACL_BROKER_NACL_BROKER_LISTENER_H_ | 52 #endif // COMPONENTS_NACL_BROKER_NACL_BROKER_LISTENER_H_ |
OLD | NEW |