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

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: Fix leak 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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 void PpapiPluginProcessHost::RequestPluginChannel(Client* client) { 198 void PpapiPluginProcessHost::RequestPluginChannel(Client* client) {
201 base::ProcessHandle process_handle; 199 base::ProcessHandle process_handle;
202 int renderer_id; 200 int renderer_id;
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(),
212 process_->GetData().id);
yzshen1 2012/04/11 18:30:46 Should it be 0?
213 }
214 } 214 }
215 215
216 void PpapiPluginProcessHost::OnProcessLaunched() { 216 void PpapiPluginProcessHost::OnProcessLaunched() {
217 } 217 }
218 218
219 bool PpapiPluginProcessHost::OnMessageReceived(const IPC::Message& msg) { 219 bool PpapiPluginProcessHost::OnMessageReceived(const IPC::Message& msg) {
220 bool handled = true; 220 bool handled = true;
221 IPC_BEGIN_MESSAGE_MAP(PpapiPluginProcessHost, msg) 221 IPC_BEGIN_MESSAGE_MAP(PpapiPluginProcessHost, msg)
222 IPC_MESSAGE_HANDLER(PpapiHostMsg_ChannelCreated, 222 IPC_MESSAGE_HANDLER(PpapiHostMsg_ChannelCreated,
223 OnRendererPluginChannelCreated) 223 OnRendererPluginChannelCreated)
(...skipping 26 matching lines...) Expand all
250 // 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
251 // that have requested a connection but have not yet received one. 251 // that have requested a connection but have not yet received one.
252 CancelRequests(); 252 CancelRequests();
253 } 253 }
254 254
255 void PpapiPluginProcessHost::CancelRequests() { 255 void PpapiPluginProcessHost::CancelRequests() {
256 DVLOG(1) << "PpapiPluginProcessHost" << (is_broker_ ? "[broker]" : "") 256 DVLOG(1) << "PpapiPluginProcessHost" << (is_broker_ ? "[broker]" : "")
257 << "CancelRequests()"; 257 << "CancelRequests()";
258 for (size_t i = 0; i < pending_requests_.size(); i++) { 258 for (size_t i = 0; i < pending_requests_.size(); i++) {
259 pending_requests_[i]->OnChannelOpened(base::kNullProcessHandle, 259 pending_requests_[i]->OnChannelOpened(base::kNullProcessHandle,
260 IPC::ChannelHandle()); 260 IPC::ChannelHandle(), 0);
261 } 261 }
262 pending_requests_.clear(); 262 pending_requests_.clear();
263 263
264 while (!sent_requests_.empty()) { 264 while (!sent_requests_.empty()) {
265 sent_requests_.front()->OnChannelOpened(base::kNullProcessHandle, 265 sent_requests_.front()->OnChannelOpened(base::kNullProcessHandle,
266 IPC::ChannelHandle()); 266 IPC::ChannelHandle(), 0);
267 sent_requests_.pop(); 267 sent_requests_.pop();
268 } 268 }
269 } 269 }
270 270
271 // Called when a new plugin <--> renderer channel has been created. 271 // Called when a new plugin <--> renderer channel has been created.
272 void PpapiPluginProcessHost::OnRendererPluginChannelCreated( 272 void PpapiPluginProcessHost::OnRendererPluginChannelCreated(
273 const IPC::ChannelHandle& channel_handle) { 273 const IPC::ChannelHandle& channel_handle) {
274 if (sent_requests_.empty()) 274 if (sent_requests_.empty())
275 return; 275 return;
276 276
(...skipping 11 matching lines...) Expand all
288 288
289 base::ProcessHandle renderers_plugin_handle = NULL; 289 base::ProcessHandle renderers_plugin_handle = NULL;
290 ::DuplicateHandle(::GetCurrentProcess(), plugin_process, 290 ::DuplicateHandle(::GetCurrentProcess(), plugin_process,
291 renderer_process, &renderers_plugin_handle, 291 renderer_process, &renderers_plugin_handle,
292 0, FALSE, DUPLICATE_SAME_ACCESS); 292 0, FALSE, DUPLICATE_SAME_ACCESS);
293 #elif defined(OS_POSIX) 293 #elif defined(OS_POSIX)
294 // 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.
295 base::ProcessHandle renderers_plugin_handle = plugin_process; 295 base::ProcessHandle renderers_plugin_handle = plugin_process;
296 #endif 296 #endif
297 297
298 client->OnChannelOpened(renderers_plugin_handle, channel_handle); 298 client->OnChannelOpened(renderers_plugin_handle, channel_handle,
299 process_->GetData().id);
299 } 300 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698