OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CONTENT_RENDERER_NPAPI_PLUGIN_CHANNEL_HOST_H_ | |
6 #define CONTENT_RENDERER_NPAPI_PLUGIN_CHANNEL_HOST_H_ | |
7 | |
8 #include "base/containers/hash_tables.h" | |
9 #include "base/macros.h" | |
10 #include "build/build_config.h" | |
11 #include "content/child/npapi/np_channel_base.h" | |
12 #include "ipc/ipc_channel_handle.h" | |
13 | |
14 namespace content { | |
15 // Encapsulates an IPC channel between the renderer and one plugin process. | |
16 // On the plugin side there's a corresponding PluginChannel. | |
17 class PluginChannelHost : public NPChannelBase { | |
18 public: | |
19 #if defined(OS_MACOSX) | |
20 // TODO(shess): Debugging for http://crbug.com/97285 . See comment | |
21 // in plugin_channel_host.cc. | |
22 static bool* GetRemoveTrackingFlag(); | |
23 #endif | |
24 static PluginChannelHost* GetPluginChannelHost( | |
25 const IPC::ChannelHandle& channel_handle, | |
26 base::SingleThreadTaskRunner* ipc_task_runner); | |
27 | |
28 bool Init(base::SingleThreadTaskRunner* ipc_task_runner, | |
29 bool create_pipe_now, | |
30 base::WaitableEvent* shutdown_event) override; | |
31 | |
32 int GenerateRouteID() override; | |
33 | |
34 void AddRoute(int route_id, IPC::Listener* listener); | |
35 void RemoveRoute(int route_id); | |
36 | |
37 // NPChannelBase override: | |
38 bool Send(IPC::Message* msg) override; | |
39 | |
40 // IPC::Listener override | |
41 void OnChannelError() override; | |
42 | |
43 static void Broadcast(IPC::Message* message) { | |
44 NPChannelBase::Broadcast(message); | |
45 } | |
46 | |
47 bool expecting_shutdown() { return expecting_shutdown_; } | |
48 | |
49 private: | |
50 // Called on the render thread | |
51 PluginChannelHost(); | |
52 ~PluginChannelHost() override; | |
53 | |
54 static NPChannelBase* ClassFactory() { return new PluginChannelHost(); } | |
55 | |
56 bool OnControlMessageReceived(const IPC::Message& message) override; | |
57 void OnPluginShuttingDown(); | |
58 | |
59 // Keep track of all the registered WebPluginDelegeProxies to | |
60 // inform about OnChannelError | |
61 typedef base::hash_map<int, IPC::Listener*> ProxyMap; | |
62 ProxyMap proxies_; | |
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 } // namespace content | |
72 | |
73 #endif // CONTENT_RENDERER_NPAPI_PLUGIN_CHANNEL_HOST_H_ | |
OLD | NEW |