OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "base/synchronization/waitable_event.h" | 12 #include "base/synchronization/waitable_event.h" |
13 #include "base/threading/thread.h" | 13 #include "base/threading/thread.h" |
14 #include "chrome/common/nacl_types.h" | 14 #include "chrome/common/nacl_types.h" |
15 #include "ipc/ipc_channel.h" | 15 #include "ipc/ipc_channel.h" |
16 | 16 |
17 namespace IPC { | 17 namespace IPC { |
18 class SyncChannel; | 18 class SyncChannel; |
19 class SyncMessageFilter; | 19 class SyncMessageFilter; |
20 } | 20 } |
21 | 21 |
22 // The NaClListener is an IPC channel listener that waits for a | 22 // The NaClListener is an IPC channel listener that waits for a |
23 // request to start a NaCl module. | 23 // request to start a NaCl module. |
24 class NaClListener : public IPC::Channel::Listener { | 24 class NaClListener : public IPC::Channel::Listener { |
25 public: | 25 public: |
26 NaClListener(); | 26 NaClListener(); |
27 virtual ~NaClListener(); | 27 virtual ~NaClListener(); |
28 // Listen for a request to launch a NaCl module. | 28 // Listen for a request to launch a NaCl module. |
29 void Listen(); | 29 void Listen(); |
30 void set_debug_enabled(bool value) {debug_enabled_ = value;} | |
31 | 30 |
32 bool Send(IPC::Message* msg); | 31 bool Send(IPC::Message* msg); |
33 | 32 |
34 private: | 33 private: |
35 void OnMsgStart(const nacl::NaClStartParams& params); | 34 void OnMsgStart(const nacl::NaClStartParams& params); |
36 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE; | 35 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE; |
37 | 36 |
38 // A channel back to the browser. | 37 // A channel back to the browser. |
39 scoped_ptr<IPC::SyncChannel> channel_; | 38 scoped_ptr<IPC::SyncChannel> channel_; |
40 | 39 |
41 // A filter that allows other threads to use the channel. | 40 // A filter that allows other threads to use the channel. |
42 scoped_refptr<IPC::SyncMessageFilter> filter_; | 41 scoped_refptr<IPC::SyncMessageFilter> filter_; |
43 | 42 |
44 base::WaitableEvent shutdown_event_; | 43 base::WaitableEvent shutdown_event_; |
45 base::Thread io_thread_; | 44 base::Thread io_thread_; |
46 | 45 |
47 // Used to identify what thread we're on. | 46 // Used to identify what thread we're on. |
48 MessageLoop* main_loop_; | 47 MessageLoop* main_loop_; |
49 | 48 |
50 bool debug_enabled_; | |
51 | |
52 DISALLOW_COPY_AND_ASSIGN(NaClListener); | 49 DISALLOW_COPY_AND_ASSIGN(NaClListener); |
53 }; | 50 }; |
54 | 51 |
55 #endif // CHROME_NACL_NACL_LISTENER_H_ | 52 #endif // CHROME_NACL_NACL_LISTENER_H_ |
OLD | NEW |