Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / content / renderer / npapi / plugin_channel_host.h
blob6c6f8e2593f22bf26eed19670209a43ce8b64d7d
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.
5 #ifndef CONTENT_RENDERER_NPAPI_PLUGIN_CHANNEL_HOST_H_
6 #define CONTENT_RENDERER_NPAPI_PLUGIN_CHANNEL_HOST_H_
8 #include "base/containers/hash_tables.h"
9 #include "content/child/npapi/np_channel_base.h"
10 #include "ipc/ipc_channel_handle.h"
12 namespace content {
13 class NPObjectBase;
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);
28 bool Init(base::SingleThreadTaskRunner* ipc_task_runner,
29 bool create_pipe_now,
30 base::WaitableEvent* shutdown_event) override;
32 int GenerateRouteID() override;
34 void AddRoute(int route_id, IPC::Listener* listener,
35 NPObjectBase* npobject);
36 void RemoveRoute(int route_id);
38 // NPChannelBase override:
39 bool Send(IPC::Message* msg) override;
41 // IPC::Listener override
42 void OnChannelError() override;
44 static void Broadcast(IPC::Message* message) {
45 NPChannelBase::Broadcast(message);
48 bool expecting_shutdown() { return expecting_shutdown_; }
50 private:
51 // Called on the render thread
52 PluginChannelHost();
53 ~PluginChannelHost() override;
55 static NPChannelBase* ClassFactory() { return new PluginChannelHost(); }
57 bool OnControlMessageReceived(const IPC::Message& message) override;
58 void OnSetException(const std::string& message);
59 void OnPluginShuttingDown();
61 // Keep track of all the registered WebPluginDelegeProxies to
62 // inform about OnChannelError
63 typedef base::hash_map<int, IPC::Listener*> ProxyMap;
64 ProxyMap proxies_;
66 // True if we are expecting the plugin process to go away - in which case,
67 // don't treat it as a crash.
68 bool expecting_shutdown_;
70 DISALLOW_COPY_AND_ASSIGN(PluginChannelHost);
73 } // namespace content
75 #endif // CONTENT_RENDERER_NPAPI_PLUGIN_CHANNEL_HOST_H_