OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 CONTENT_RENDERER_PLUGIN_CHANNEL_HOST_H_ | 5 #ifndef CONTENT_RENDERER_PLUGIN_CHANNEL_HOST_H_ |
6 #define CONTENT_RENDERER_PLUGIN_CHANNEL_HOST_H_ | 6 #define CONTENT_RENDERER_PLUGIN_CHANNEL_HOST_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/hash_tables.h" | 9 #include "base/hash_tables.h" |
10 #include "content/common/np_channel_base.h" | 10 #include "content/common/np_channel_base.h" |
11 #include "ipc/ipc_channel_handle.h" | 11 #include "ipc/ipc_channel_handle.h" |
12 | 12 |
13 class IsListeningFilter; | 13 class IsListeningFilter; |
14 class NPObjectBase; | 14 class NPObjectBase; |
15 | 15 |
16 // Encapsulates an IPC channel between the renderer and one plugin process. | 16 // Encapsulates an IPC channel between the renderer and one plugin process. |
17 // On the plugin side there's a corresponding PluginChannel. | 17 // On the plugin side there's a corresponding PluginChannel. |
18 class PluginChannelHost : public NPChannelBase { | 18 class PluginChannelHost : public NPChannelBase { |
19 public: | 19 public: |
20 static PluginChannelHost* GetPluginChannelHost( | 20 static PluginChannelHost* GetPluginChannelHost( |
21 const IPC::ChannelHandle& channel_handle, | 21 const IPC::ChannelHandle& channel_handle, |
22 base::MessageLoopProxy* ipc_message_loop); | 22 base::MessageLoopProxy* ipc_message_loop); |
23 | 23 |
24 virtual bool Init(base::MessageLoopProxy* ipc_message_loop, | 24 virtual bool Init(base::MessageLoopProxy* ipc_message_loop, |
25 bool create_pipe_now, | 25 bool create_pipe_now, |
26 base::WaitableEvent* shutdown_event); | 26 base::WaitableEvent* shutdown_event) OVERRIDE; |
27 | 27 |
28 virtual int GenerateRouteID(); | 28 virtual int GenerateRouteID() OVERRIDE; |
29 | 29 |
30 void AddRoute(int route_id, IPC::Channel::Listener* listener, | 30 void AddRoute(int route_id, IPC::Channel::Listener* listener, |
31 NPObjectBase* npobject); | 31 NPObjectBase* npobject); |
32 void RemoveRoute(int route_id); | 32 void RemoveRoute(int route_id); |
33 | 33 |
34 // NPChannelBase override: | 34 // NPChannelBase override: |
35 virtual bool Send(IPC::Message* msg); | 35 virtual bool Send(IPC::Message* msg) OVERRIDE; |
36 | 36 |
37 // IPC::Channel::Listener override | 37 // IPC::Channel::Listener override |
38 virtual void OnChannelError(); | 38 virtual void OnChannelError() OVERRIDE; |
39 | 39 |
40 static void SetListening(bool flag); | 40 static void SetListening(bool flag); |
41 | 41 |
42 static bool IsListening(); | 42 static bool IsListening(); |
43 | 43 |
44 static void Broadcast(IPC::Message* message) { | 44 static void Broadcast(IPC::Message* message) { |
45 NPChannelBase::Broadcast(message); | 45 NPChannelBase::Broadcast(message); |
46 } | 46 } |
47 | 47 |
48 bool expecting_shutdown() { return expecting_shutdown_; } | 48 bool expecting_shutdown() { return expecting_shutdown_; } |
49 | 49 |
50 private: | 50 private: |
51 // Called on the render thread | 51 // Called on the render thread |
52 PluginChannelHost(); | 52 PluginChannelHost(); |
53 virtual ~PluginChannelHost(); | 53 virtual ~PluginChannelHost(); |
54 | 54 |
55 static NPChannelBase* ClassFactory() { return new PluginChannelHost(); } | 55 static NPChannelBase* ClassFactory() { return new PluginChannelHost(); } |
56 | 56 |
57 virtual bool OnControlMessageReceived(const IPC::Message& message); | 57 virtual bool OnControlMessageReceived(const IPC::Message& message) OVERRIDE; |
58 void OnSetException(const std::string& message); | 58 void OnSetException(const std::string& message); |
59 void OnPluginShuttingDown(); | 59 void OnPluginShuttingDown(); |
60 | 60 |
61 // Keep track of all the registered WebPluginDelegeProxies to | 61 // Keep track of all the registered WebPluginDelegeProxies to |
62 // inform about OnChannelError | 62 // inform about OnChannelError |
63 typedef base::hash_map<int, IPC::Channel::Listener*> ProxyMap; | 63 typedef base::hash_map<int, IPC::Channel::Listener*> ProxyMap; |
64 ProxyMap proxies_; | 64 ProxyMap proxies_; |
65 | 65 |
66 // An IPC MessageFilter that can be told to filter out all messages. This is | 66 // An IPC MessageFilter that can be told to filter out all messages. This is |
67 // used when the JS debugger is attached in order to avoid browser hangs. | 67 // used when the JS debugger is attached in order to avoid browser hangs. |
68 scoped_refptr<IsListeningFilter> is_listening_filter_; | 68 scoped_refptr<IsListeningFilter> is_listening_filter_; |
69 | 69 |
70 // True if we are expecting the plugin process to go away - in which case, | 70 // True if we are expecting the plugin process to go away - in which case, |
71 // don't treat it as a crash. | 71 // don't treat it as a crash. |
72 bool expecting_shutdown_; | 72 bool expecting_shutdown_; |
73 | 73 |
74 DISALLOW_COPY_AND_ASSIGN(PluginChannelHost); | 74 DISALLOW_COPY_AND_ASSIGN(PluginChannelHost); |
75 }; | 75 }; |
76 | 76 |
77 #endif // CONTENT_RENDERER_PLUGIN_CHANNEL_HOST_H_ | 77 #endif // CONTENT_RENDERER_PLUGIN_CHANNEL_HOST_H_ |
OLD | NEW |