Use multiline attribute to check for IA2_STATE_MULTILINE.
[chromium-blink-merge.git] / components / nacl / loader / nacl_listener.h
blob9e8d67b65747d96b35f3391e7bb95a22faf55f0a
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 ~NaClListener() override;
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 typedef base::Callback<void(IPC::PlatformFileForTransit, base::FilePath)>
52 ResolveFileTokenCallback;
53 void ResolveFileToken(uint64_t token_lo,
54 uint64_t token_hi,
55 ResolveFileTokenCallback cb);
56 void OnFileTokenResolved(uint64_t token_lo,
57 uint64_t token_hi,
58 IPC::PlatformFileForTransit ipc_fd,
59 base::FilePath file_path);
61 private:
62 bool OnMessageReceived(const IPC::Message& msg) override;
64 void OnStart(const nacl::NaClStartParams& params);
66 // A channel back to the browser.
67 scoped_ptr<IPC::SyncChannel> channel_;
69 // A filter that allows other threads to use the channel.
70 scoped_refptr<IPC::SyncMessageFilter> filter_;
72 base::WaitableEvent shutdown_event_;
73 base::Thread io_thread_;
75 #if defined(OS_LINUX)
76 size_t prereserved_sandbox_size_;
77 #endif
78 #if defined(OS_POSIX)
79 // The outer sandbox on Linux and OSX prevents
80 // sysconf(_SC_NPROCESSORS) from working; in Windows, there are no
81 // problems with invoking GetSystemInfo. Therefore, only in
82 // OS_POSIX do we need to supply the number of cores into the
83 // NaClChromeMainArgs object.
84 int number_of_cores_;
85 #endif
87 scoped_ptr<base::SharedMemory> crash_info_shmem_;
89 scoped_refptr<NaClTrustedListener> trusted_listener_;
91 ResolveFileTokenCallback resolved_cb_;
93 // Used to identify what thread we're on.
94 base::MessageLoop* main_loop_;
96 DISALLOW_COPY_AND_ASSIGN(NaClListener);
99 #endif // CHROME_NACL_NACL_LISTENER_H_