Add ICU message format support
[chromium-blink-merge.git] / content / renderer / npapi / plugin_channel_host.h
blobdd9dd1b51c769a380d1227f7dec04f4a448d4fcc
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 IPC {
13 class AttachmentBroker;
16 namespace content {
17 class NPObjectBase;
19 // Encapsulates an IPC channel between the renderer and one plugin process.
20 // On the plugin side there's a corresponding PluginChannel.
21 class PluginChannelHost : public NPChannelBase {
22 public:
23 #if defined(OS_MACOSX)
24 // TODO(shess): Debugging for http://crbug.com/97285 . See comment
25 // in plugin_channel_host.cc.
26 static bool* GetRemoveTrackingFlag();
27 #endif
28 static PluginChannelHost* GetPluginChannelHost(
29 const IPC::ChannelHandle& channel_handle,
30 base::SingleThreadTaskRunner* ipc_task_runner,
31 IPC::AttachmentBroker* broker);
33 bool Init(base::SingleThreadTaskRunner* ipc_task_runner,
34 bool create_pipe_now,
35 base::WaitableEvent* shutdown_event,
36 IPC::AttachmentBroker* broker) override;
38 int GenerateRouteID() override;
40 void AddRoute(int route_id, IPC::Listener* listener,
41 NPObjectBase* npobject);
42 void RemoveRoute(int route_id);
44 // NPChannelBase override:
45 bool Send(IPC::Message* msg) override;
47 // IPC::Listener override
48 void OnChannelError() override;
50 static void Broadcast(IPC::Message* message) {
51 NPChannelBase::Broadcast(message);
54 bool expecting_shutdown() { return expecting_shutdown_; }
56 private:
57 // Called on the render thread
58 PluginChannelHost();
59 ~PluginChannelHost() override;
61 static NPChannelBase* ClassFactory() { return new PluginChannelHost(); }
63 bool OnControlMessageReceived(const IPC::Message& message) override;
64 void OnSetException(const std::string& message);
65 void OnPluginShuttingDown();
67 // Keep track of all the registered WebPluginDelegeProxies to
68 // inform about OnChannelError
69 typedef base::hash_map<int, IPC::Listener*> ProxyMap;
70 ProxyMap proxies_;
72 // True if we are expecting the plugin process to go away - in which case,
73 // don't treat it as a crash.
74 bool expecting_shutdown_;
76 DISALLOW_COPY_AND_ASSIGN(PluginChannelHost);
79 } // namespace content
81 #endif // CONTENT_RENDERER_NPAPI_PLUGIN_CHANNEL_HOST_H_