Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(360)

Side by Side Diff: components/nacl/loader/nacl_listener.h

Issue 439713002: Refactoring: Split NaClListener into two delegated classes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "components/nacl/loader/nacl_trusted_listener.h" 14 #include "components/nacl/loader/nacl_trusted_listener.h"
15 #include "ipc/ipc_listener.h" 15 #include "ipc/ipc_listener.h"
16 16
17 namespace base { 17 namespace base {
18 class MessageLoopProxy; 18 class MessageLoopProxy;
19 } 19 } // namespace base
20 20
21 namespace IPC { 21 namespace IPC {
22 class SyncChannel; 22 class SyncChannel;
23 class SyncMessageFilter; 23 class SyncMessageFilter;
24 } 24 } // namespace IPC
25
26 namespace nacl {
27 class ListenerDelegate;
28 } // namespace nacl
25 29
26 // The NaClListener is an IPC channel listener that waits for a 30 // The NaClListener is an IPC channel listener that waits for a
27 // request to start a NaCl module. 31 // request to start a NaCl module.
28 class NaClListener : public IPC::Listener { 32 class NaClListener : public IPC::Listener, public IPC::Sender {
29 public: 33 public:
30 NaClListener(); 34 explicit NaClListener(scoped_ptr<nacl::ListenerDelegate> delegate);
31 virtual ~NaClListener(); 35 virtual ~NaClListener();
32 // Listen for a request to launch a NaCl module. 36 // Listen for a request to launch a NaCl module.
33 void Listen(); 37 void Listen();
34 38
35 bool Send(IPC::Message* msg); 39 virtual bool Send(IPC::Message* msg) OVERRIDE;
36
37 void set_uses_nonsfi_mode(bool uses_nonsfi_mode) {
38 uses_nonsfi_mode_ = uses_nonsfi_mode;
39 }
40 #if defined(OS_LINUX)
41 void set_prereserved_sandbox_size(size_t prereserved_sandbox_size) {
42 prereserved_sandbox_size_ = prereserved_sandbox_size;
43 }
44 #endif
45 #if defined(OS_POSIX)
46 void set_number_of_cores(int number_of_cores) {
47 number_of_cores_ = number_of_cores;
48 }
49 #endif
50 40
51 private: 41 private:
52 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE; 42 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE;
53 43
54 void OnStart(const nacl::NaClStartParams& params); 44 void OnStart(const nacl::NaClStartParams& params);
55 45
56 // Non-SFI version of OnStart(). 46 IPC::ChannelHandle CreateTrustedListener();
57 void StartNonSfi(const nacl::NaClStartParams& params);
58 47
59 IPC::ChannelHandle CreateTrustedListener( 48 scoped_ptr<nacl::ListenerDelegate> delegate_;
60 base::MessageLoopProxy* message_loop_proxy,
61 base::WaitableEvent* shutdown_event);
62 49
63 // A channel back to the browser. 50 // A channel back to the browser.
64 scoped_ptr<IPC::SyncChannel> channel_; 51 scoped_ptr<IPC::SyncChannel> channel_;
65 52
66 // A filter that allows other threads to use the channel. 53 // A filter that allows other threads to use the channel.
67 scoped_refptr<IPC::SyncMessageFilter> filter_; 54 scoped_refptr<IPC::SyncMessageFilter> filter_;
68 55
69 base::WaitableEvent shutdown_event_; 56 base::WaitableEvent shutdown_event_;
70 base::Thread io_thread_; 57 base::Thread io_thread_;
71 58
72 bool uses_nonsfi_mode_;
73 #if defined(OS_LINUX)
74 size_t prereserved_sandbox_size_;
75 #endif
76 #if defined(OS_POSIX)
77 // The outer sandbox on Linux and OSX prevents
78 // sysconf(_SC_NPROCESSORS) from working; in Windows, there are no
79 // problems with invoking GetSystemInfo. Therefore, only in
80 // OS_POSIX do we need to supply the number of cores into the
81 // NaClChromeMainArgs object.
82 int number_of_cores_;
83 #endif
84
85 scoped_refptr<NaClTrustedListener> trusted_listener_; 59 scoped_refptr<NaClTrustedListener> trusted_listener_;
86 60
87 // Used to identify what thread we're on. 61 // Used to identify what thread we're on.
88 base::MessageLoop* main_loop_; 62 base::MessageLoop* main_loop_;
89 63
90 DISALLOW_COPY_AND_ASSIGN(NaClListener); 64 DISALLOW_COPY_AND_ASSIGN(NaClListener);
91 }; 65 };
92 66
93 #endif // CHROME_NACL_NACL_LISTENER_H_ 67 #endif // CHROME_NACL_NACL_LISTENER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698