Updating trunk VERSION from 2139.0 to 2140.0
[chromium-blink-merge.git] / components / nacl / loader / nacl_listener.h
blob0e335a42338b5afcf446a74d4ea6889b049837c0
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
3 // found in the LICENSE file.
5 #ifndef CHROME_NACL_NACL_LISTENER_H_
6 #define CHROME_NACL_NACL_LISTENER_H_
8 #include <vector>
10 #include "base/memory/scoped_ptr.h"
11 #include "base/memory/shared_memory.h"
12 #include "base/synchronization/waitable_event.h"
13 #include "base/threading/thread.h"
14 #include "components/nacl/common/nacl_types.h"
15 #include "components/nacl/loader/nacl_trusted_listener.h"
16 #include "ipc/ipc_listener.h"
18 namespace base {
19 class MessageLoopProxy;
22 namespace IPC {
23 class SyncChannel;
24 class SyncMessageFilter;
27 // The NaClListener is an IPC channel listener that waits for a
28 // request to start a NaCl module.
29 class NaClListener : public IPC::Listener {
30 public:
31 NaClListener();
32 virtual ~NaClListener();
33 // Listen for a request to launch a NaCl module.
34 void Listen();
36 bool Send(IPC::Message* msg);
38 #if defined(OS_LINUX)
39 void set_prereserved_sandbox_size(size_t prereserved_sandbox_size) {
40 prereserved_sandbox_size_ = prereserved_sandbox_size;
42 #endif
43 #if defined(OS_POSIX)
44 void set_number_of_cores(int number_of_cores) {
45 number_of_cores_ = number_of_cores;
47 #endif
49 void* crash_info_shmem_memory() const { return crash_info_shmem_->memory(); }
51 private:
52 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE;
54 void OnStart(const nacl::NaClStartParams& params);
56 // A channel back to the browser.
57 scoped_ptr<IPC::SyncChannel> channel_;
59 // A filter that allows other threads to use the channel.
60 scoped_refptr<IPC::SyncMessageFilter> filter_;
62 base::WaitableEvent shutdown_event_;
63 base::Thread io_thread_;
65 #if defined(OS_LINUX)
66 size_t prereserved_sandbox_size_;
67 #endif
68 #if defined(OS_POSIX)
69 // The outer sandbox on Linux and OSX prevents
70 // sysconf(_SC_NPROCESSORS) from working; in Windows, there are no
71 // problems with invoking GetSystemInfo. Therefore, only in
72 // OS_POSIX do we need to supply the number of cores into the
73 // NaClChromeMainArgs object.
74 int number_of_cores_;
75 #endif
77 scoped_ptr<base::SharedMemory> crash_info_shmem_;
79 scoped_refptr<NaClTrustedListener> trusted_listener_;
81 // Used to identify what thread we're on.
82 base::MessageLoop* main_loop_;
84 DISALLOW_COPY_AND_ASSIGN(NaClListener);
87 #endif // CHROME_NACL_NACL_LISTENER_H_