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 #include "content/plugin/plugin_channel.h" | 5 #include "content/plugin/plugin_channel.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/process/process_handle.h" | 9 #include "base/process/process_handle.h" |
10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
11 #include "base/synchronization/lock.h" | 11 #include "base/synchronization/lock.h" |
12 #include "base/synchronization/waitable_event.h" | 12 #include "base/synchronization/waitable_event.h" |
13 #include "build/build_config.h" | 13 #include "build/build_config.h" |
14 #include "content/child/child_process.h" | 14 #include "content/child/child_process.h" |
15 #include "content/child/npapi/plugin_instance.h" | 15 #include "content/child/npapi/plugin_instance.h" |
16 #include "content/child/npapi/webplugin_delegate_impl.h" | 16 #include "content/child/npapi/webplugin_delegate_impl.h" |
17 #include "content/child/plugin_messages.h" | 17 #include "content/child/plugin_messages.h" |
18 #include "content/common/plugin_process_messages.h" | 18 #include "content/common/plugin_process_messages.h" |
19 #include "content/plugin/plugin_thread.h" | 19 #include "content/plugin/plugin_thread.h" |
20 #include "content/plugin/webplugin_delegate_stub.h" | 20 #include "content/plugin/webplugin_delegate_stub.h" |
21 #include "content/plugin/webplugin_proxy.h" | 21 #include "content/plugin/webplugin_proxy.h" |
22 #include "content/public/common/content_switches.h" | 22 #include "content/public/common/content_switches.h" |
| 23 #include "ipc/message_filter.h" |
23 #include "third_party/WebKit/public/web/WebBindings.h" | 24 #include "third_party/WebKit/public/web/WebBindings.h" |
24 | 25 |
25 #if defined(OS_POSIX) | 26 #if defined(OS_POSIX) |
26 #include "ipc/ipc_channel_posix.h" | 27 #include "ipc/ipc_channel_posix.h" |
27 #endif | 28 #endif |
28 | 29 |
29 using blink::WebBindings; | 30 using blink::WebBindings; |
30 | 31 |
31 namespace content { | 32 namespace content { |
32 | 33 |
33 namespace { | 34 namespace { |
34 | 35 |
35 // How long we wait before releasing the plugin process. | 36 // How long we wait before releasing the plugin process. |
36 const int kPluginReleaseTimeMinutes = 5; | 37 const int kPluginReleaseTimeMinutes = 5; |
37 | 38 |
38 } // namespace | 39 } // namespace |
39 | 40 |
40 // If a sync call to the renderer results in a modal dialog, we need to have a | 41 // If a sync call to the renderer results in a modal dialog, we need to have a |
41 // way to know so that we can run a nested message loop to simulate what would | 42 // way to know so that we can run a nested message loop to simulate what would |
42 // happen in a single process browser and avoid deadlock. | 43 // happen in a single process browser and avoid deadlock. |
43 class PluginChannel::MessageFilter : public IPC::ChannelProxy::MessageFilter { | 44 class PluginChannel::MessageFilter : public IPC::MessageFilter { |
44 public: | 45 public: |
45 MessageFilter() : channel_(NULL) { } | 46 MessageFilter() : channel_(NULL) { } |
46 | 47 |
47 base::WaitableEvent* GetModalDialogEvent(int render_view_id) { | 48 base::WaitableEvent* GetModalDialogEvent(int render_view_id) { |
48 base::AutoLock auto_lock(modal_dialog_event_map_lock_); | 49 base::AutoLock auto_lock(modal_dialog_event_map_lock_); |
49 if (!modal_dialog_event_map_.count(render_view_id)) { | 50 if (!modal_dialog_event_map_.count(render_view_id)) { |
50 NOTREACHED(); | 51 NOTREACHED(); |
51 return NULL; | 52 return NULL; |
52 } | 53 } |
53 | 54 |
(...skipping 16 matching lines...) Expand all Loading... |
70 base::MessageLoop::current()->DeleteSoon( | 71 base::MessageLoop::current()->DeleteSoon( |
71 FROM_HERE, modal_dialog_event_map_[render_view_id].event); | 72 FROM_HERE, modal_dialog_event_map_[render_view_id].event); |
72 modal_dialog_event_map_.erase(render_view_id); | 73 modal_dialog_event_map_.erase(render_view_id); |
73 } | 74 } |
74 | 75 |
75 bool Send(IPC::Message* message) { | 76 bool Send(IPC::Message* message) { |
76 // Need this function for the IPC_MESSAGE_HANDLER_DELAY_REPLY macro. | 77 // Need this function for the IPC_MESSAGE_HANDLER_DELAY_REPLY macro. |
77 return channel_->Send(message); | 78 return channel_->Send(message); |
78 } | 79 } |
79 | 80 |
80 // IPC::ChannelProxy::MessageFilter: | 81 // IPC::MessageFilter: |
81 virtual void OnFilterAdded(IPC::Channel* channel) OVERRIDE { | 82 virtual void OnFilterAdded(IPC::Channel* channel) OVERRIDE { |
82 channel_ = channel; | 83 channel_ = channel; |
83 } | 84 } |
84 | 85 |
85 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE { | 86 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE { |
86 IPC_BEGIN_MESSAGE_MAP(PluginChannel::MessageFilter, message) | 87 IPC_BEGIN_MESSAGE_MAP(PluginChannel::MessageFilter, message) |
87 IPC_MESSAGE_HANDLER_DELAY_REPLY(PluginMsg_Init, OnInit) | 88 IPC_MESSAGE_HANDLER_DELAY_REPLY(PluginMsg_Init, OnInit) |
88 IPC_MESSAGE_HANDLER(PluginMsg_SignalModalDialogEvent, | 89 IPC_MESSAGE_HANDLER(PluginMsg_SignalModalDialogEvent, |
89 OnSignalModalDialogEvent) | 90 OnSignalModalDialogEvent) |
90 IPC_MESSAGE_HANDLER(PluginMsg_ResetModalDialogEvent, | 91 IPC_MESSAGE_HANDLER(PluginMsg_ResetModalDialogEvent, |
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
338 void PluginChannel::OnDidAbortLoading(int render_view_id) { | 339 void PluginChannel::OnDidAbortLoading(int render_view_id) { |
339 for (size_t i = 0; i < plugin_stubs_.size(); ++i) { | 340 for (size_t i = 0; i < plugin_stubs_.size(); ++i) { |
340 if (plugin_stubs_[i]->webplugin()->host_render_view_routing_id() == | 341 if (plugin_stubs_[i]->webplugin()->host_render_view_routing_id() == |
341 render_view_id) { | 342 render_view_id) { |
342 plugin_stubs_[i]->delegate()->instance()->CloseStreams(); | 343 plugin_stubs_[i]->delegate()->instance()->CloseStreams(); |
343 } | 344 } |
344 } | 345 } |
345 } | 346 } |
346 | 347 |
347 } // namespace content | 348 } // namespace content |
OLD | NEW |