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