| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 COMPONENTS_NACL_LOADER_NACL_TRUSTED_LISTENER_H_ | 5 #ifndef COMPONENTS_NACL_LOADER_NACL_TRUSTED_LISTENER_H_ |
| 6 #define COMPONENTS_NACL_LOADER_NACL_TRUSTED_LISTENER_H_ | 6 #define COMPONENTS_NACL_LOADER_NACL_TRUSTED_LISTENER_H_ |
| 7 | 7 |
| 8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
| 9 #include "base/synchronization/waitable_event.h" |
| 9 #include "ipc/ipc_channel_handle.h" | 10 #include "ipc/ipc_channel_handle.h" |
| 10 #include "ipc/ipc_channel_proxy.h" | 11 #include "ipc/ipc_channel_proxy.h" |
| 11 #include "ipc/ipc_listener.h" | 12 #include "ipc/ipc_listener.h" |
| 12 | 13 |
| 13 namespace base { | 14 namespace base { |
| 14 class SingleThreadTaskRunner; | 15 class SingleThreadTaskRunner; |
| 15 } | 16 } |
| 16 | 17 |
| 17 class NaClTrustedListener : public base::RefCounted<NaClTrustedListener>, | 18 class NaClTrustedListener : public base::RefCounted<NaClTrustedListener>, |
| 18 public IPC::Listener { | 19 public IPC::Listener { |
| 19 public: | 20 public: |
| 20 NaClTrustedListener(const IPC::ChannelHandle& handle, | 21 NaClTrustedListener(const IPC::ChannelHandle& handle, |
| 21 base::SingleThreadTaskRunner* ipc_task_runner); | 22 base::SingleThreadTaskRunner* ipc_task_runner); |
| 22 | 23 |
| 23 #if defined(OS_POSIX) | 24 #if defined(OS_POSIX) |
| 24 int TakeClientFileDescriptor(); | 25 int TakeClientFileDescriptor(); |
| 25 #endif | 26 #endif |
| 26 | 27 |
| 27 // Listener implementation. | 28 // Listener implementation. |
| 28 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | 29 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
| 29 virtual void OnChannelError() OVERRIDE; | 30 virtual void OnChannelError() OVERRIDE; |
| 30 | 31 |
| 31 bool Send(IPC::Message* msg); | 32 bool Send(IPC::Message* msg); |
| 32 | 33 |
| 34 // Flushes tasks on the IPC task runner. This gives the IPC task runner a |
| 35 // change to send messages if the process is being aborted. |
| 36 bool FlushIpcTaskRunner(const base::TimeDelta& time); |
| 37 |
| 38 static NaClTrustedListener* Get(); |
| 39 |
| 33 private: | 40 private: |
| 34 friend class base::RefCounted<NaClTrustedListener>; | 41 friend class base::RefCounted<NaClTrustedListener>; |
| 35 virtual ~NaClTrustedListener(); | 42 virtual ~NaClTrustedListener(); |
| 43 void SignalIpcTaskRunnerFlushed(); |
| 44 |
| 45 base::SingleThreadTaskRunner* ipc_task_runner_; |
| 36 scoped_ptr<IPC::ChannelProxy> channel_proxy_; | 46 scoped_ptr<IPC::ChannelProxy> channel_proxy_; |
| 47 base::WaitableEvent waitable_event_; |
| 37 | 48 |
| 38 DISALLOW_COPY_AND_ASSIGN(NaClTrustedListener); | 49 DISALLOW_COPY_AND_ASSIGN(NaClTrustedListener); |
| 39 }; | 50 }; |
| 40 | 51 |
| 41 #endif // COMPONENTS_NACL_LOADER_NACL_TRUSTED_LISTENER_H_ | 52 #endif // COMPONENTS_NACL_LOADER_NACL_TRUSTED_LISTENER_H_ |
| OLD | NEW |