Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / components / nacl / renderer / trusted_plugin_channel.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_RENDERER_TRUSTED_PLUGIN_CHANNEL_H_
6 #define COMPONENTS_NACL_RENDERER_TRUSTED_PLUGIN_CHANNEL_H_
7
8 #include "base/callback.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "ipc/ipc_listener.h"
11
12 namespace base {
13 class WaitableEvent;
14 }  // namespace base
15
16 namespace IPC {
17 struct ChannelHandle;
18 class Message;
19 class SyncChannel;
20 }  // namespace IPC
21
22 namespace nacl {
23
24 class TrustedPluginChannel : public IPC::Listener {
25  public:
26   TrustedPluginChannel(
27       const IPC::ChannelHandle& handle,
28       const base::Callback<void(int32_t)>& connected_callback,
29       base::WaitableEvent* waitable_event);
30   virtual ~TrustedPluginChannel();
31
32   bool Send(IPC::Message* message);
33
34   // Listener implementation.
35   virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
36   virtual void OnChannelConnected(int32 peer_pid) OVERRIDE;
37   virtual void OnChannelError() OVERRIDE;
38
39  private:
40   base::Callback<void(int32_t)> connected_callback_;
41   scoped_ptr<IPC::SyncChannel> channel_;
42
43   DISALLOW_COPY_AND_ASSIGN(TrustedPluginChannel);
44 };
45
46 }  // namespace nacl
47
48 #endif  // COMPONENTS_NACL_RENDERER_TRUSTED_PLUGIN_CHANNEL_H_