Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(370)

Side by Side Diff: content/browser/ppapi_plugin_process_host.cc

Issue 10014013: Add a hang monitor for Pepper plugins (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/browser/ppapi_plugin_process_host.h" 5 #include "content/browser/ppapi_plugin_process_host.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/base_switches.h" 9 #include "base/base_switches.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 } 104 }
105 105
106 // We already have an open channel, send a request right away to plugin. 106 // We already have an open channel, send a request right away to plugin.
107 RequestPluginChannel(client); 107 RequestPluginChannel(client);
108 } 108 }
109 109
110 PpapiPluginProcessHost::PpapiPluginProcessHost(net::HostResolver* host_resolver) 110 PpapiPluginProcessHost::PpapiPluginProcessHost(net::HostResolver* host_resolver)
111 : filter_(new PepperMessageFilter(PepperMessageFilter::PLUGIN, 111 : filter_(new PepperMessageFilter(PepperMessageFilter::PLUGIN,
112 host_resolver)), 112 host_resolver)),
113 network_observer_(new PluginNetworkObserver(this)), 113 network_observer_(new PluginNetworkObserver(this)),
114 is_broker_(false), 114 is_broker_(false) {
115 process_id_(ChildProcessHostImpl::GenerateChildProcessUniqueId()) {
116 process_.reset(new BrowserChildProcessHostImpl( 115 process_.reset(new BrowserChildProcessHostImpl(
117 content::PROCESS_TYPE_PPAPI_PLUGIN, this)); 116 content::PROCESS_TYPE_PPAPI_PLUGIN, this));
118 process_->GetHost()->AddFilter(filter_.get()); 117 process_->GetHost()->AddFilter(filter_.get());
119 } 118 }
120 119
121 PpapiPluginProcessHost::PpapiPluginProcessHost() 120 PpapiPluginProcessHost::PpapiPluginProcessHost()
122 : is_broker_(true), 121 : is_broker_(true) {
123 process_id_(ChildProcessHostImpl::GenerateChildProcessUniqueId()) {
124 process_.reset(new BrowserChildProcessHostImpl( 122 process_.reset(new BrowserChildProcessHostImpl(
125 content::PROCESS_TYPE_PPAPI_BROKER, this)); 123 content::PROCESS_TYPE_PPAPI_BROKER, this));
126 } 124 }
127 125
128 bool PpapiPluginProcessHost::Init(const content::PepperPluginInfo& info) { 126 bool PpapiPluginProcessHost::Init(const content::PepperPluginInfo& info) {
129 plugin_path_ = info.path; 127 plugin_path_ = info.path;
130 if (info.name.empty()) { 128 if (info.name.empty()) {
131 process_->SetName(plugin_path_.BaseName().LossyDisplayName()); 129 process_->SetName(plugin_path_.BaseName().LossyDisplayName());
132 } else { 130 } else {
133 process_->SetName(UTF8ToUTF16(info.name)); 131 process_->SetName(UTF8ToUTF16(info.name));
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 202
205 // We can't send any sync messages from the browser because it might lead to 203 // We can't send any sync messages from the browser because it might lead to
206 // a hang. See the similar code in PluginProcessHost for more description. 204 // a hang. See the similar code in PluginProcessHost for more description.
207 PpapiMsg_CreateChannel* msg = new PpapiMsg_CreateChannel(process_handle, 205 PpapiMsg_CreateChannel* msg = new PpapiMsg_CreateChannel(process_handle,
208 renderer_id); 206 renderer_id);
209 msg->set_unblock(true); 207 msg->set_unblock(true);
210 if (Send(msg)) { 208 if (Send(msg)) {
211 sent_requests_.push(client); 209 sent_requests_.push(client);
212 } else { 210 } else {
213 client->OnPpapiChannelOpened(base::kNullProcessHandle, 211 client->OnPpapiChannelOpened(base::kNullProcessHandle,
214 IPC::ChannelHandle()); 212 IPC::ChannelHandle(), 0);
215 } 213 }
216 } 214 }
217 215
218 void PpapiPluginProcessHost::OnProcessLaunched() { 216 void PpapiPluginProcessHost::OnProcessLaunched() {
219 } 217 }
220 218
221 bool PpapiPluginProcessHost::OnMessageReceived(const IPC::Message& msg) { 219 bool PpapiPluginProcessHost::OnMessageReceived(const IPC::Message& msg) {
222 bool handled = true; 220 bool handled = true;
223 IPC_BEGIN_MESSAGE_MAP(PpapiPluginProcessHost, msg) 221 IPC_BEGIN_MESSAGE_MAP(PpapiPluginProcessHost, msg)
224 IPC_MESSAGE_HANDLER(PpapiHostMsg_ChannelCreated, 222 IPC_MESSAGE_HANDLER(PpapiHostMsg_ChannelCreated,
(...skipping 27 matching lines...) Expand all
252 // state at the same time. Instead, we just need to notify any renderers 250 // state at the same time. Instead, we just need to notify any renderers
253 // that have requested a connection but have not yet received one. 251 // that have requested a connection but have not yet received one.
254 CancelRequests(); 252 CancelRequests();
255 } 253 }
256 254
257 void PpapiPluginProcessHost::CancelRequests() { 255 void PpapiPluginProcessHost::CancelRequests() {
258 DVLOG(1) << "PpapiPluginProcessHost" << (is_broker_ ? "[broker]" : "") 256 DVLOG(1) << "PpapiPluginProcessHost" << (is_broker_ ? "[broker]" : "")
259 << "CancelRequests()"; 257 << "CancelRequests()";
260 for (size_t i = 0; i < pending_requests_.size(); i++) { 258 for (size_t i = 0; i < pending_requests_.size(); i++) {
261 pending_requests_[i]->OnPpapiChannelOpened(base::kNullProcessHandle, 259 pending_requests_[i]->OnPpapiChannelOpened(base::kNullProcessHandle,
262 IPC::ChannelHandle()); 260 IPC::ChannelHandle(), 0);
263 } 261 }
264 pending_requests_.clear(); 262 pending_requests_.clear();
265 263
266 while (!sent_requests_.empty()) { 264 while (!sent_requests_.empty()) {
267 sent_requests_.front()->OnPpapiChannelOpened(base::kNullProcessHandle, 265 sent_requests_.front()->OnPpapiChannelOpened(base::kNullProcessHandle,
268 IPC::ChannelHandle()); 266 IPC::ChannelHandle(), 0);
269 sent_requests_.pop(); 267 sent_requests_.pop();
270 } 268 }
271 } 269 }
272 270
273 // Called when a new plugin <--> renderer channel has been created. 271 // Called when a new plugin <--> renderer channel has been created.
274 void PpapiPluginProcessHost::OnRendererPluginChannelCreated( 272 void PpapiPluginProcessHost::OnRendererPluginChannelCreated(
275 const IPC::ChannelHandle& channel_handle) { 273 const IPC::ChannelHandle& channel_handle) {
276 if (sent_requests_.empty()) 274 if (sent_requests_.empty())
277 return; 275 return;
278 276
(...skipping 11 matching lines...) Expand all
290 288
291 base::ProcessHandle renderers_plugin_handle = NULL; 289 base::ProcessHandle renderers_plugin_handle = NULL;
292 ::DuplicateHandle(::GetCurrentProcess(), plugin_process, 290 ::DuplicateHandle(::GetCurrentProcess(), plugin_process,
293 renderer_process, &renderers_plugin_handle, 291 renderer_process, &renderers_plugin_handle,
294 0, FALSE, DUPLICATE_SAME_ACCESS); 292 0, FALSE, DUPLICATE_SAME_ACCESS);
295 #elif defined(OS_POSIX) 293 #elif defined(OS_POSIX)
296 // Don't need to duplicate anything on POSIX since it's just a PID. 294 // Don't need to duplicate anything on POSIX since it's just a PID.
297 base::ProcessHandle renderers_plugin_handle = plugin_process; 295 base::ProcessHandle renderers_plugin_handle = plugin_process;
298 #endif 296 #endif
299 297
300 client->OnPpapiChannelOpened(renderers_plugin_handle, channel_handle); 298 client->OnPpapiChannelOpened(renderers_plugin_handle, channel_handle,
299 process_->GetData().id);
301 } 300 }
OLDNEW
« no previous file with comments | « content/browser/ppapi_plugin_process_host.h ('k') | content/browser/renderer_host/render_message_filter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698