| 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 CHROME_NACL_NACL_LISTENER_H_ | 5 #ifndef CHROME_NACL_NACL_LISTENER_H_ |
| 6 #define CHROME_NACL_NACL_LISTENER_H_ | 6 #define CHROME_NACL_NACL_LISTENER_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "base/synchronization/waitable_event.h" | 11 #include "base/synchronization/waitable_event.h" |
| 12 #include "base/threading/thread.h" | 12 #include "base/threading/thread.h" |
| 13 #include "components/nacl/common/nacl_types.h" | 13 #include "components/nacl/common/nacl_types.h" |
| 14 #include "ipc/ipc_listener.h" | 14 #include "ipc/ipc_listener.h" |
| 15 | 15 |
| 16 namespace IPC { | 16 namespace IPC { |
| 17 class SyncChannel; | 17 class SyncChannel; |
| 18 class SyncMessageFilter; | 18 class SyncMessageFilter; |
| 19 } | 19 } |
| 20 | 20 |
| 21 struct NaClApp; |
| 22 class NaClTrustedListener; |
| 23 |
| 21 // The NaClListener is an IPC channel listener that waits for a | 24 // The NaClListener is an IPC channel listener that waits for a |
| 22 // request to start a NaCl module. | 25 // request to start a NaCl module. |
| 23 class NaClListener : public IPC::Listener { | 26 class NaClListener : public IPC::Listener { |
| 24 public: | 27 public: |
| 25 NaClListener(); | 28 NaClListener(); |
| 26 virtual ~NaClListener(); | 29 virtual ~NaClListener(); |
| 27 // Listen for a request to launch a NaCl module. | 30 // Listen for a request to launch a NaCl module. |
| 28 void Listen(); | 31 void Listen(); |
| 29 | 32 |
| 30 bool Send(IPC::Message* msg); | 33 bool Send(IPC::Message* msg); |
| 31 | 34 |
| 32 #if defined(OS_LINUX) | 35 #if defined(OS_LINUX) |
| 33 void set_prereserved_sandbox_size(size_t prereserved_sandbox_size) { | 36 void set_prereserved_sandbox_size(size_t prereserved_sandbox_size) { |
| 34 prereserved_sandbox_size_ = prereserved_sandbox_size; | 37 prereserved_sandbox_size_ = prereserved_sandbox_size; |
| 35 } | 38 } |
| 36 #endif | 39 #endif |
| 37 #if defined(OS_POSIX) | 40 #if defined(OS_POSIX) |
| 38 void set_number_of_cores(int number_of_cores) { | 41 void set_number_of_cores(int number_of_cores) { |
| 39 number_of_cores_ = number_of_cores; | 42 number_of_cores_ = number_of_cores; |
| 40 } | 43 } |
| 41 #endif | 44 #endif |
| 42 | 45 |
| 43 private: | 46 private: |
| 47 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE; |
| 48 |
| 44 void OnStart(const nacl::NaClStartParams& params); | 49 void OnStart(const nacl::NaClStartParams& params); |
| 45 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE; | 50 void CreateTrustedPluginChannel(struct NaClApp* nap, int irt_fd); |
| 46 | 51 |
| 47 // A channel back to the browser. | 52 // A channel back to the browser. |
| 48 scoped_ptr<IPC::SyncChannel> channel_; | 53 scoped_ptr<IPC::SyncChannel> channel_; |
| 49 | 54 |
| 50 // A filter that allows other threads to use the channel. | 55 // A filter that allows other threads to use the channel. |
| 51 scoped_refptr<IPC::SyncMessageFilter> filter_; | 56 scoped_refptr<IPC::SyncMessageFilter> filter_; |
| 52 | 57 |
| 53 base::WaitableEvent shutdown_event_; | 58 base::WaitableEvent shutdown_event_; |
| 54 base::Thread io_thread_; | 59 base::Thread io_thread_; |
| 60 base::Thread chrome_main_thread_; |
| 55 | 61 |
| 56 #if defined(OS_LINUX) | 62 #if defined(OS_LINUX) |
| 57 size_t prereserved_sandbox_size_; | 63 size_t prereserved_sandbox_size_; |
| 58 #endif | 64 #endif |
| 59 #if defined(OS_POSIX) | 65 #if defined(OS_POSIX) |
| 60 // The outer sandbox on Linux and OSX prevents | 66 // The outer sandbox on Linux and OSX prevents |
| 61 // sysconf(_SC_NPROCESSORS) from working; in Windows, there are no | 67 // sysconf(_SC_NPROCESSORS) from working; in Windows, there are no |
| 62 // problems with invoking GetSystemInfo. Therefore, only in | 68 // problems with invoking GetSystemInfo. Therefore, only in |
| 63 // OS_POSIX do we need to supply the number of cores into the | 69 // OS_POSIX do we need to supply the number of cores into the |
| 64 // NaClChromeMainArgs object. | 70 // NaClChromeMainArgs object. |
| 65 int number_of_cores_; | 71 int number_of_cores_; |
| 66 #endif | 72 #endif |
| 67 | 73 |
| 68 // Used to identify what thread we're on. | 74 // Used to identify what thread we're on. |
| 69 base::MessageLoop* main_loop_; | 75 base::MessageLoop* main_loop_; |
| 70 | 76 |
| 77 scoped_refptr<NaClTrustedListener> trusted_listener_; |
| 78 |
| 71 DISALLOW_COPY_AND_ASSIGN(NaClListener); | 79 DISALLOW_COPY_AND_ASSIGN(NaClListener); |
| 72 }; | 80 }; |
| 73 | 81 |
| 74 #endif // CHROME_NACL_NACL_LISTENER_H_ | 82 #endif // CHROME_NACL_NACL_LISTENER_H_ |
| OLD | NEW |