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