| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_NPAPI_PLUGIN_CHANNEL_HOST_H_ | 5 #ifndef CONTENT_RENDERER_NPAPI_PLUGIN_CHANNEL_HOST_H_ |
| 6 #define CONTENT_RENDERER_NPAPI_PLUGIN_CHANNEL_HOST_H_ | 6 #define CONTENT_RENDERER_NPAPI_PLUGIN_CHANNEL_HOST_H_ |
| 7 | 7 |
| 8 #include "base/containers/hash_tables.h" | 8 #include "base/containers/hash_tables.h" |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
| 11 #include "content/child/npapi/np_channel_base.h" | 11 #include "content/child/npapi/np_channel_base.h" |
| 12 #include "ipc/ipc_channel_handle.h" | 12 #include "ipc/ipc_channel_handle.h" |
| 13 | 13 |
| 14 namespace content { | 14 namespace content { |
| 15 class NPObjectBase; | |
| 16 | |
| 17 // Encapsulates an IPC channel between the renderer and one plugin process. | 15 // Encapsulates an IPC channel between the renderer and one plugin process. |
| 18 // On the plugin side there's a corresponding PluginChannel. | 16 // On the plugin side there's a corresponding PluginChannel. |
| 19 class PluginChannelHost : public NPChannelBase { | 17 class PluginChannelHost : public NPChannelBase { |
| 20 public: | 18 public: |
| 21 #if defined(OS_MACOSX) | 19 #if defined(OS_MACOSX) |
| 22 // TODO(shess): Debugging for http://crbug.com/97285 . See comment | 20 // TODO(shess): Debugging for http://crbug.com/97285 . See comment |
| 23 // in plugin_channel_host.cc. | 21 // in plugin_channel_host.cc. |
| 24 static bool* GetRemoveTrackingFlag(); | 22 static bool* GetRemoveTrackingFlag(); |
| 25 #endif | 23 #endif |
| 26 static PluginChannelHost* GetPluginChannelHost( | 24 static PluginChannelHost* GetPluginChannelHost( |
| 27 const IPC::ChannelHandle& channel_handle, | 25 const IPC::ChannelHandle& channel_handle, |
| 28 base::SingleThreadTaskRunner* ipc_task_runner); | 26 base::SingleThreadTaskRunner* ipc_task_runner); |
| 29 | 27 |
| 30 bool Init(base::SingleThreadTaskRunner* ipc_task_runner, | 28 bool Init(base::SingleThreadTaskRunner* ipc_task_runner, |
| 31 bool create_pipe_now, | 29 bool create_pipe_now, |
| 32 base::WaitableEvent* shutdown_event) override; | 30 base::WaitableEvent* shutdown_event) override; |
| 33 | 31 |
| 34 int GenerateRouteID() override; | 32 int GenerateRouteID() override; |
| 35 | 33 |
| 36 void AddRoute(int route_id, IPC::Listener* listener, | 34 void AddRoute(int route_id, IPC::Listener* listener); |
| 37 NPObjectBase* npobject); | |
| 38 void RemoveRoute(int route_id); | 35 void RemoveRoute(int route_id); |
| 39 | 36 |
| 40 // NPChannelBase override: | 37 // NPChannelBase override: |
| 41 bool Send(IPC::Message* msg) override; | 38 bool Send(IPC::Message* msg) override; |
| 42 | 39 |
| 43 // IPC::Listener override | 40 // IPC::Listener override |
| 44 void OnChannelError() override; | 41 void OnChannelError() override; |
| 45 | 42 |
| 46 static void Broadcast(IPC::Message* message) { | 43 static void Broadcast(IPC::Message* message) { |
| 47 NPChannelBase::Broadcast(message); | 44 NPChannelBase::Broadcast(message); |
| 48 } | 45 } |
| 49 | 46 |
| 50 bool expecting_shutdown() { return expecting_shutdown_; } | 47 bool expecting_shutdown() { return expecting_shutdown_; } |
| 51 | 48 |
| 52 private: | 49 private: |
| 53 // Called on the render thread | 50 // Called on the render thread |
| 54 PluginChannelHost(); | 51 PluginChannelHost(); |
| 55 ~PluginChannelHost() override; | 52 ~PluginChannelHost() override; |
| 56 | 53 |
| 57 static NPChannelBase* ClassFactory() { return new PluginChannelHost(); } | 54 static NPChannelBase* ClassFactory() { return new PluginChannelHost(); } |
| 58 | 55 |
| 59 bool OnControlMessageReceived(const IPC::Message& message) override; | 56 bool OnControlMessageReceived(const IPC::Message& message) override; |
| 60 void OnSetException(const std::string& message); | |
| 61 void OnPluginShuttingDown(); | 57 void OnPluginShuttingDown(); |
| 62 | 58 |
| 63 // Keep track of all the registered WebPluginDelegeProxies to | 59 // Keep track of all the registered WebPluginDelegeProxies to |
| 64 // inform about OnChannelError | 60 // inform about OnChannelError |
| 65 typedef base::hash_map<int, IPC::Listener*> ProxyMap; | 61 typedef base::hash_map<int, IPC::Listener*> ProxyMap; |
| 66 ProxyMap proxies_; | 62 ProxyMap proxies_; |
| 67 | 63 |
| 68 // True if we are expecting the plugin process to go away - in which case, | 64 // True if we are expecting the plugin process to go away - in which case, |
| 69 // don't treat it as a crash. | 65 // don't treat it as a crash. |
| 70 bool expecting_shutdown_; | 66 bool expecting_shutdown_; |
| 71 | 67 |
| 72 DISALLOW_COPY_AND_ASSIGN(PluginChannelHost); | 68 DISALLOW_COPY_AND_ASSIGN(PluginChannelHost); |
| 73 }; | 69 }; |
| 74 | 70 |
| 75 } // namespace content | 71 } // namespace content |
| 76 | 72 |
| 77 #endif // CONTENT_RENDERER_NPAPI_PLUGIN_CHANNEL_HOST_H_ | 73 #endif // CONTENT_RENDERER_NPAPI_PLUGIN_CHANNEL_HOST_H_ |
| OLD | NEW |