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_PLUGIN_PLUGIN_CHANNEL_H_ | 5 #ifndef CONTENT_PLUGIN_PLUGIN_CHANNEL_H_ |
6 #define CONTENT_PLUGIN_PLUGIN_CHANNEL_H_ | 6 #define CONTENT_PLUGIN_PLUGIN_CHANNEL_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "base/process/process.h" | 10 #include "base/process/process.h" |
11 #include "build/build_config.h" | 11 #include "build/build_config.h" |
12 #include "content/child/npapi/np_channel_base.h" | 12 #include "content/child/npapi/np_channel_base.h" |
13 #include "content/child/scoped_child_process_reference.h" | 13 #include "content/child/scoped_child_process_reference.h" |
14 #include "content/plugin/webplugin_delegate_stub.h" | 14 #include "content/plugin/webplugin_delegate_stub.h" |
15 | 15 |
16 namespace base { | 16 namespace base { |
17 class WaitableEvent; | 17 class WaitableEvent; |
18 } | 18 } |
19 | 19 |
20 namespace content { | 20 namespace content { |
21 | 21 |
22 // Encapsulates an IPC channel between the plugin process and one renderer | 22 // Encapsulates an IPC channel between the plugin process and one renderer |
23 // process. On the renderer side there's a corresponding PluginChannelHost. | 23 // process. On the renderer side there's a corresponding PluginChannelHost. |
24 class PluginChannel : public NPChannelBase { | 24 class PluginChannel : public NPChannelBase { |
25 public: | 25 public: |
26 // Get a new PluginChannel object for the current process to talk to the | 26 // Get a new PluginChannel object for the current process to talk to the |
27 // given renderer process. The renderer ID is an opaque unique ID generated | 27 // given renderer process. The renderer ID is an opaque unique ID generated |
28 // by the browser. | 28 // by the browser. |
29 static PluginChannel* GetPluginChannel( | 29 static PluginChannel* GetPluginChannel( |
30 int renderer_id, base::MessageLoopProxy* ipc_message_loop); | 30 int renderer_id, base::SingleThreadTaskRunner* ipc_task_runner); |
31 | 31 |
32 // Send a message to all renderers that the process is going to shutdown. | 32 // Send a message to all renderers that the process is going to shutdown. |
33 static void NotifyRenderersOfPendingShutdown(); | 33 static void NotifyRenderersOfPendingShutdown(); |
34 | 34 |
35 // IPC::Listener: | 35 // IPC::Listener: |
36 bool Send(IPC::Message* msg) override; | 36 bool Send(IPC::Message* msg) override; |
37 bool OnMessageReceived(const IPC::Message& message) override; | 37 bool OnMessageReceived(const IPC::Message& message) override; |
38 void OnChannelError() override; | 38 void OnChannelError() override; |
39 | 39 |
40 int renderer_id() { return renderer_id_; } | 40 int renderer_id() { return renderer_id_; } |
(...skipping 13 matching lines...) Expand all Loading... |
54 base::ScopedFD TakeRendererFileDescriptor() { | 54 base::ScopedFD TakeRendererFileDescriptor() { |
55 return channel_->TakeClientFileDescriptor(); | 55 return channel_->TakeClientFileDescriptor(); |
56 } | 56 } |
57 #endif | 57 #endif |
58 | 58 |
59 protected: | 59 protected: |
60 ~PluginChannel() override; | 60 ~PluginChannel() override; |
61 | 61 |
62 // NPChannelBase:: | 62 // NPChannelBase:: |
63 void CleanUp() override; | 63 void CleanUp() override; |
64 bool Init(base::MessageLoopProxy* ipc_message_loop, | 64 bool Init(base::SingleThreadTaskRunner* ipc_task_runner, |
65 bool create_pipe_now, | 65 bool create_pipe_now, |
66 base::WaitableEvent* shutdown_event) override; | 66 base::WaitableEvent* shutdown_event) override; |
67 | 67 |
68 private: | 68 private: |
69 class MessageFilter; | 69 class MessageFilter; |
70 | 70 |
71 // Called on the plugin thread | 71 // Called on the plugin thread |
72 PluginChannel(); | 72 PluginChannel(); |
73 | 73 |
74 bool OnControlMessageReceived(const IPC::Message& msg) override; | 74 bool OnControlMessageReceived(const IPC::Message& msg) override; |
(...skipping 23 matching lines...) Expand all Loading... |
98 // Dummy NPP value used in the plugin process to represent entities other | 98 // Dummy NPP value used in the plugin process to represent entities other |
99 // that other plugin instances for the purpose of object ownership tracking. | 99 // that other plugin instances for the purpose of object ownership tracking. |
100 scoped_ptr<struct _NPP> npp_; | 100 scoped_ptr<struct _NPP> npp_; |
101 | 101 |
102 DISALLOW_COPY_AND_ASSIGN(PluginChannel); | 102 DISALLOW_COPY_AND_ASSIGN(PluginChannel); |
103 }; | 103 }; |
104 | 104 |
105 } // namespace content | 105 } // namespace content |
106 | 106 |
107 #endif // CONTENT_PLUGIN_PLUGIN_CHANNEL_H_ | 107 #endif // CONTENT_PLUGIN_PLUGIN_CHANNEL_H_ |
OLD | NEW |