Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / components / nacl / loader / nacl_trusted_listener.h
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
3 // found in the LICENSE file.
4
5 #ifndef COMPONENTS_NACL_LOADER_NACL_TRUSTED_LISTENER_H_
6 #define COMPONENTS_NACL_LOADER_NACL_TRUSTED_LISTENER_H_
7
8 #include "base/memory/ref_counted.h"
9 #include "ipc/ipc_channel_handle.h"
10 #include "ipc/ipc_listener.h"
11 #include "ipc/ipc_sync_channel.h"
12
13 namespace base {
14 class SingleThreadTaskRunner;
15 }
16
17 class NaClTrustedListener : public base::RefCounted<NaClTrustedListener>,
18                             public IPC::Listener {
19  public:
20   NaClTrustedListener(const IPC::ChannelHandle& handle,
21                       base::SingleThreadTaskRunner* ipc_task_runner,
22                       base::WaitableEvent* shutdown_event);
23
24   IPC::ChannelHandle TakeClientChannelHandle();
25
26   // Listener implementation.
27   bool OnMessageReceived(const IPC::Message& message) override;
28   void OnChannelError() override;
29
30   bool Send(IPC::Message* msg);
31
32  private:
33   friend class base::RefCounted<NaClTrustedListener>;
34   ~NaClTrustedListener() override;
35   IPC::ChannelHandle channel_handle_;
36   scoped_ptr<IPC::SyncChannel> channel_;
37
38   DISALLOW_COPY_AND_ASSIGN(NaClTrustedListener);
39 };
40
41 #endif  // COMPONENTS_NACL_LOADER_NACL_TRUSTED_LISTENER_H_