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