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

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: Review comments 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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 client->GetChannelInfo(&process_handle, &renderer_id); 201 client->GetChannelInfo(&process_handle, &renderer_id);
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->OnChannelOpened(base::kNullProcessHandle, IPC::ChannelHandle()); 211 client->OnChannelOpened(base::kNullProcessHandle, IPC::ChannelHandle(), 0);
214 } 212 }
215 213
216 void PpapiPluginProcessHost::OnProcessLaunched() { 214 void PpapiPluginProcessHost::OnProcessLaunched() {
217 } 215 }
218 216
219 bool PpapiPluginProcessHost::OnMessageReceived(const IPC::Message& msg) { 217 bool PpapiPluginProcessHost::OnMessageReceived(const IPC::Message& msg) {
220 bool handled = true; 218 bool handled = true;
221 IPC_BEGIN_MESSAGE_MAP(PpapiPluginProcessHost, msg) 219 IPC_BEGIN_MESSAGE_MAP(PpapiPluginProcessHost, msg)
222 IPC_MESSAGE_HANDLER(PpapiHostMsg_ChannelCreated, 220 IPC_MESSAGE_HANDLER(PpapiHostMsg_ChannelCreated,
223 OnRendererPluginChannelCreated) 221 OnRendererPluginChannelCreated)
(...skipping 26 matching lines...) Expand all
250 // state at the same time. Instead, we just need to notify any renderers 248 // state at the same time. Instead, we just need to notify any renderers
251 // that have requested a connection but have not yet received one. 249 // that have requested a connection but have not yet received one.
252 CancelRequests(); 250 CancelRequests();
253 } 251 }
254 252
255 void PpapiPluginProcessHost::CancelRequests() { 253 void PpapiPluginProcessHost::CancelRequests() {
256 DVLOG(1) << "PpapiPluginProcessHost" << (is_broker_ ? "[broker]" : "") 254 DVLOG(1) << "PpapiPluginProcessHost" << (is_broker_ ? "[broker]" : "")
257 << "CancelRequests()"; 255 << "CancelRequests()";
258 for (size_t i = 0; i < pending_requests_.size(); i++) { 256 for (size_t i = 0; i < pending_requests_.size(); i++) {
259 pending_requests_[i]->OnChannelOpened(base::kNullProcessHandle, 257 pending_requests_[i]->OnChannelOpened(base::kNullProcessHandle,
260 IPC::ChannelHandle()); 258 IPC::ChannelHandle(), 0);
261 } 259 }
262 pending_requests_.clear(); 260 pending_requests_.clear();
263 261
264 while (!sent_requests_.empty()) { 262 while (!sent_requests_.empty()) {
265 sent_requests_.front()->OnChannelOpened(base::kNullProcessHandle, 263 sent_requests_.front()->OnChannelOpened(base::kNullProcessHandle,
266 IPC::ChannelHandle()); 264 IPC::ChannelHandle(), 0);
267 sent_requests_.pop(); 265 sent_requests_.pop();
268 } 266 }
269 } 267 }
270 268
271 // Called when a new plugin <--> renderer channel has been created. 269 // Called when a new plugin <--> renderer channel has been created.
272 void PpapiPluginProcessHost::OnRendererPluginChannelCreated( 270 void PpapiPluginProcessHost::OnRendererPluginChannelCreated(
273 const IPC::ChannelHandle& channel_handle) { 271 const IPC::ChannelHandle& channel_handle) {
274 if (sent_requests_.empty()) 272 if (sent_requests_.empty())
275 return; 273 return;
276 274
(...skipping 11 matching lines...) Expand all
288 286
289 base::ProcessHandle renderers_plugin_handle = NULL; 287 base::ProcessHandle renderers_plugin_handle = NULL;
290 ::DuplicateHandle(::GetCurrentProcess(), plugin_process, 288 ::DuplicateHandle(::GetCurrentProcess(), plugin_process,
291 renderer_process, &renderers_plugin_handle, 289 renderer_process, &renderers_plugin_handle,
292 0, FALSE, DUPLICATE_SAME_ACCESS); 290 0, FALSE, DUPLICATE_SAME_ACCESS);
293 #elif defined(OS_POSIX) 291 #elif defined(OS_POSIX)
294 // Don't need to duplicate anything on POSIX since it's just a PID. 292 // Don't need to duplicate anything on POSIX since it's just a PID.
295 base::ProcessHandle renderers_plugin_handle = plugin_process; 293 base::ProcessHandle renderers_plugin_handle = plugin_process;
296 #endif 294 #endif
297 295
298 client->OnChannelOpened(renderers_plugin_handle, channel_handle); 296 client->OnChannelOpened(renderers_plugin_handle, channel_handle,
297 process_->GetData().id);
299 } 298 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698