| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_BROKER_THREAD_H_ | 5 #ifndef CHROME_NACL_NACL_BROKER_LISTENER_H_ |
| 6 #define CHROME_NACL_BROKER_THREAD_H_ | 6 #define CHROME_NACL_NACL_BROKER_LISTENER_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/process.h" | 10 #include "base/process.h" |
| 10 #include "chrome/common/nacl_types.h" | 11 #include "chrome/common/nacl_types.h" |
| 11 #include "content/common/child_thread.h" | 12 #include "ipc/ipc_channel.h" |
| 12 | |
| 13 #if defined(OS_WIN) | |
| 14 #include "sandbox/src/sandbox.h" | |
| 15 #endif | |
| 16 | 13 |
| 17 // The BrokerThread class represents the thread that handles the messages from | 14 // The BrokerThread class represents the thread that handles the messages from |
| 18 // the browser process and starts NaCl loader processes. | 15 // the browser process and starts NaCl loader processes. |
| 19 class NaClBrokerThread : public ChildThread { | 16 class NaClBrokerListener : public IPC::Channel::Listener { |
| 20 public: | 17 public: |
| 21 NaClBrokerThread(); | 18 NaClBrokerListener(); |
| 22 ~NaClBrokerThread(); | 19 ~NaClBrokerListener(); |
| 23 // Returns the one NaCl thread. | 20 |
| 24 static NaClBrokerThread* current(); | 21 void Listen(); |
| 25 | 22 |
| 26 // IPC::Channel::Listener implementation. | 23 // IPC::Channel::Listener implementation. |
| 27 virtual void OnChannelConnected(int32 peer_pid) OVERRIDE; | 24 virtual void OnChannelConnected(int32 peer_pid) OVERRIDE; |
| 25 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE; |
| 28 | 26 |
| 29 private: | 27 private: |
| 30 virtual bool OnControlMessageReceived(const IPC::Message& msg); | |
| 31 void OnLaunchLoaderThroughBroker(const std::wstring& loader_channel_id); | 28 void OnLaunchLoaderThroughBroker(const std::wstring& loader_channel_id); |
| 32 void OnShareBrowserHandle(int browser_handle); | 29 void OnShareBrowserHandle(int browser_handle); |
| 33 void OnStopBroker(); | 30 void OnStopBroker(); |
| 34 | 31 |
| 35 base::ProcessHandle browser_handle_; | 32 base::ProcessHandle browser_handle_; |
| 36 sandbox::BrokerServices* broker_services_; | 33 scoped_ptr<IPC::Channel> channel_; |
| 37 | 34 |
| 38 DISALLOW_COPY_AND_ASSIGN(NaClBrokerThread); | 35 DISALLOW_COPY_AND_ASSIGN(NaClBrokerListener); |
| 39 }; | 36 }; |
| 40 | 37 |
| 41 #endif // CHROME_NACL_BROKER_THREAD_H_ | 38 #endif // CHROME_NACL_NACL_BROKER_LISTENER_H_ |
| OLD | NEW |