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" |
(...skipping 16 matching lines...) Expand all Loading... |
27 // request to start a NaCl module. | 27 // request to start a NaCl module. |
28 class NaClListener : public IPC::Listener { | 28 class NaClListener : public IPC::Listener { |
29 public: | 29 public: |
30 NaClListener(); | 30 NaClListener(); |
31 virtual ~NaClListener(); | 31 virtual ~NaClListener(); |
32 // Listen for a request to launch a NaCl module. | 32 // Listen for a request to launch a NaCl module. |
33 void Listen(); | 33 void Listen(); |
34 | 34 |
35 bool Send(IPC::Message* msg); | 35 bool Send(IPC::Message* msg); |
36 | 36 |
37 void set_uses_nonsfi_mode(bool uses_nonsfi_mode) { | |
38 uses_nonsfi_mode_ = uses_nonsfi_mode; | |
39 } | |
40 #if defined(OS_LINUX) | 37 #if defined(OS_LINUX) |
41 void set_prereserved_sandbox_size(size_t prereserved_sandbox_size) { | 38 void set_prereserved_sandbox_size(size_t prereserved_sandbox_size) { |
42 prereserved_sandbox_size_ = prereserved_sandbox_size; | 39 prereserved_sandbox_size_ = prereserved_sandbox_size; |
43 } | 40 } |
44 #endif | 41 #endif |
45 #if defined(OS_POSIX) | 42 #if defined(OS_POSIX) |
46 void set_number_of_cores(int number_of_cores) { | 43 void set_number_of_cores(int number_of_cores) { |
47 number_of_cores_ = number_of_cores; | 44 number_of_cores_ = number_of_cores; |
48 } | 45 } |
49 #endif | 46 #endif |
50 | 47 |
51 private: | 48 private: |
52 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE; | 49 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE; |
53 | 50 |
54 void OnStart(const nacl::NaClStartParams& params); | 51 void OnStart(const nacl::NaClStartParams& params); |
55 | 52 |
56 // Non-SFI version of OnStart(). | |
57 void StartNonSfi(const nacl::NaClStartParams& params); | |
58 | |
59 IPC::ChannelHandle CreateTrustedListener( | |
60 base::MessageLoopProxy* message_loop_proxy, | |
61 base::WaitableEvent* shutdown_event); | |
62 | |
63 // A channel back to the browser. | 53 // A channel back to the browser. |
64 scoped_ptr<IPC::SyncChannel> channel_; | 54 scoped_ptr<IPC::SyncChannel> channel_; |
65 | 55 |
66 // A filter that allows other threads to use the channel. | 56 // A filter that allows other threads to use the channel. |
67 scoped_refptr<IPC::SyncMessageFilter> filter_; | 57 scoped_refptr<IPC::SyncMessageFilter> filter_; |
68 | 58 |
69 base::WaitableEvent shutdown_event_; | 59 base::WaitableEvent shutdown_event_; |
70 base::Thread io_thread_; | 60 base::Thread io_thread_; |
71 | 61 |
72 bool uses_nonsfi_mode_; | |
73 #if defined(OS_LINUX) | 62 #if defined(OS_LINUX) |
74 size_t prereserved_sandbox_size_; | 63 size_t prereserved_sandbox_size_; |
75 #endif | 64 #endif |
76 #if defined(OS_POSIX) | 65 #if defined(OS_POSIX) |
77 // The outer sandbox on Linux and OSX prevents | 66 // The outer sandbox on Linux and OSX prevents |
78 // sysconf(_SC_NPROCESSORS) from working; in Windows, there are no | 67 // sysconf(_SC_NPROCESSORS) from working; in Windows, there are no |
79 // problems with invoking GetSystemInfo. Therefore, only in | 68 // problems with invoking GetSystemInfo. Therefore, only in |
80 // 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 |
81 // NaClChromeMainArgs object. | 70 // NaClChromeMainArgs object. |
82 int number_of_cores_; | 71 int number_of_cores_; |
83 #endif | 72 #endif |
84 | 73 |
85 scoped_refptr<NaClTrustedListener> trusted_listener_; | 74 scoped_refptr<NaClTrustedListener> trusted_listener_; |
86 | 75 |
87 // Used to identify what thread we're on. | 76 // Used to identify what thread we're on. |
88 base::MessageLoop* main_loop_; | 77 base::MessageLoop* main_loop_; |
89 | 78 |
90 DISALLOW_COPY_AND_ASSIGN(NaClListener); | 79 DISALLOW_COPY_AND_ASSIGN(NaClListener); |
91 }; | 80 }; |
92 | 81 |
93 #endif // CHROME_NACL_NACL_LISTENER_H_ | 82 #endif // CHROME_NACL_NACL_LISTENER_H_ |
OLD | NEW |