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

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

Issue 103623003: Instrument pepper plugin load failures. (Closed) Base URL: https://src.chromium.org/chrome/trunk/src/
Patch Set: Created 7 years 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
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 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 << "~PpapiPluginProcessHost()"; 110 << "~PpapiPluginProcessHost()";
111 CancelRequests(); 111 CancelRequests();
112 } 112 }
113 113
114 // static 114 // static
115 PpapiPluginProcessHost* PpapiPluginProcessHost::CreatePluginHost( 115 PpapiPluginProcessHost* PpapiPluginProcessHost::CreatePluginHost(
116 const PepperPluginInfo& info, 116 const PepperPluginInfo& info,
117 const base::FilePath& profile_data_directory) { 117 const base::FilePath& profile_data_directory) {
118 PpapiPluginProcessHost* plugin_host = new PpapiPluginProcessHost( 118 PpapiPluginProcessHost* plugin_host = new PpapiPluginProcessHost(
119 info, profile_data_directory); 119 info, profile_data_directory);
120 CHECK(plugin_host);
piman 2013/12/09 22:39:06 nit: DCHECK
Scott Hess - ex-Googler 2013/12/09 23:47:45 Wouldn't NULL be obvious from the crash reports an
ilja 2013/12/10 05:55:31 Done.
ilja 2013/12/10 05:55:31 It has virtuals, so it should crash when accessing
120 if (plugin_host->Init(info)) 121 if (plugin_host->Init(info))
121 return plugin_host; 122 return plugin_host;
122 123
123 NOTREACHED(); // Init is not expected to fail. 124 NOTREACHED(); // Init is not expected to fail.
124 return NULL; 125 return NULL;
125 } 126 }
126 127
127 // static 128 // static
128 PpapiPluginProcessHost* PpapiPluginProcessHost::CreateBrokerHost( 129 PpapiPluginProcessHost* PpapiPluginProcessHost::CreateBrokerHost(
129 const PepperPluginInfo& info) { 130 const PepperPluginInfo& info) {
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 247
247 bool PpapiPluginProcessHost::Init(const PepperPluginInfo& info) { 248 bool PpapiPluginProcessHost::Init(const PepperPluginInfo& info) {
248 plugin_path_ = info.path; 249 plugin_path_ = info.path;
249 if (info.name.empty()) { 250 if (info.name.empty()) {
250 process_->SetName(plugin_path_.BaseName().LossyDisplayName()); 251 process_->SetName(plugin_path_.BaseName().LossyDisplayName());
251 } else { 252 } else {
252 process_->SetName(UTF8ToUTF16(info.name)); 253 process_->SetName(UTF8ToUTF16(info.name));
253 } 254 }
254 255
255 std::string channel_id = process_->GetHost()->CreateChannel(); 256 std::string channel_id = process_->GetHost()->CreateChannel();
256 if (channel_id.empty()) 257 if (channel_id.empty()) {
258 LOG(ERROR) << "Could not create pepper host channel.";
257 return false; 259 return false;
260 }
258 261
259 const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess(); 262 const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess();
260 CommandLine::StringType plugin_launcher = 263 CommandLine::StringType plugin_launcher =
261 browser_command_line.GetSwitchValueNative(switches::kPpapiPluginLauncher); 264 browser_command_line.GetSwitchValueNative(switches::kPpapiPluginLauncher);
262 265
263 #if defined(OS_LINUX) 266 #if defined(OS_LINUX)
264 int flags = plugin_launcher.empty() ? ChildProcessHost::CHILD_ALLOW_SELF : 267 int flags = plugin_launcher.empty() ? ChildProcessHost::CHILD_ALLOW_SELF :
265 ChildProcessHost::CHILD_NORMAL; 268 ChildProcessHost::CHILD_NORMAL;
266 #else 269 #else
267 int flags = ChildProcessHost::CHILD_NORMAL; 270 int flags = ChildProcessHost::CHILD_NORMAL;
268 #endif 271 #endif
269 base::FilePath exe_path = ChildProcessHost::GetChildPath(flags); 272 base::FilePath exe_path = ChildProcessHost::GetChildPath(flags);
270 if (exe_path.empty()) 273 if (exe_path.empty()) {
274 LOG(ERROR) << "Pepper plugin exe path is empty.";
271 return false; 275 return false;
276 }
272 277
273 CommandLine* cmd_line = new CommandLine(exe_path); 278 CommandLine* cmd_line = new CommandLine(exe_path);
274 cmd_line->AppendSwitchASCII(switches::kProcessType, 279 cmd_line->AppendSwitchASCII(switches::kProcessType,
275 is_broker_ ? switches::kPpapiBrokerProcess 280 is_broker_ ? switches::kPpapiBrokerProcess
276 : switches::kPpapiPluginProcess); 281 : switches::kPpapiPluginProcess);
277 cmd_line->AppendSwitchASCII(switches::kProcessChannelID, channel_id); 282 cmd_line->AppendSwitchASCII(switches::kProcessChannelID, channel_id);
278 283
279 // These switches are forwarded to both plugin and broker pocesses. 284 // These switches are forwarded to both plugin and broker pocesses.
280 static const char* kCommonForwardSwitches[] = { 285 static const char* kCommonForwardSwitches[] = {
281 switches::kVModule 286 switches::kVModule
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 } else { 359 } else {
355 client->OnPpapiChannelOpened(IPC::ChannelHandle(), base::kNullProcessId, 0); 360 client->OnPpapiChannelOpened(IPC::ChannelHandle(), base::kNullProcessId, 0);
356 } 361 }
357 } 362 }
358 363
359 void PpapiPluginProcessHost::OnProcessLaunched() { 364 void PpapiPluginProcessHost::OnProcessLaunched() {
360 host_impl_->set_plugin_process_handle(process_->GetHandle()); 365 host_impl_->set_plugin_process_handle(process_->GetHandle());
361 } 366 }
362 367
363 void PpapiPluginProcessHost::OnProcessCrashed(int exit_code) { 368 void PpapiPluginProcessHost::OnProcessCrashed(int exit_code) {
369 LOG(WARNING) << "ppapi plugin process crashed.";
364 PluginServiceImpl::GetInstance()->RegisterPluginCrash(plugin_path_); 370 PluginServiceImpl::GetInstance()->RegisterPluginCrash(plugin_path_);
365 } 371 }
366 372
367 bool PpapiPluginProcessHost::OnMessageReceived(const IPC::Message& msg) { 373 bool PpapiPluginProcessHost::OnMessageReceived(const IPC::Message& msg) {
368 bool handled = true; 374 bool handled = true;
369 IPC_BEGIN_MESSAGE_MAP(PpapiPluginProcessHost, msg) 375 IPC_BEGIN_MESSAGE_MAP(PpapiPluginProcessHost, msg)
370 IPC_MESSAGE_HANDLER(PpapiHostMsg_ChannelCreated, 376 IPC_MESSAGE_HANDLER(PpapiHostMsg_ChannelCreated,
371 OnRendererPluginChannelCreated) 377 OnRendererPluginChannelCreated)
372 IPC_MESSAGE_UNHANDLED(handled = false) 378 IPC_MESSAGE_UNHANDLED(handled = false)
373 IPC_END_MESSAGE_MAP() 379 IPC_END_MESSAGE_MAP()
(...skipping 10 matching lines...) Expand all
384 390
385 // Process all pending channel requests from the renderers. 391 // Process all pending channel requests from the renderers.
386 for (size_t i = 0; i < pending_requests_.size(); i++) 392 for (size_t i = 0; i < pending_requests_.size(); i++)
387 RequestPluginChannel(pending_requests_[i]); 393 RequestPluginChannel(pending_requests_[i]);
388 pending_requests_.clear(); 394 pending_requests_.clear();
389 } 395 }
390 396
391 // Called when the browser <--> plugin channel has an error. This normally 397 // Called when the browser <--> plugin channel has an error. This normally
392 // means the plugin has crashed. 398 // means the plugin has crashed.
393 void PpapiPluginProcessHost::OnChannelError() { 399 void PpapiPluginProcessHost::OnChannelError() {
400 LOG(WARNING) << "ppapi plugin channel error.";
394 DVLOG(1) << "PpapiPluginProcessHost" << (is_broker_ ? "[broker]" : "") 401 DVLOG(1) << "PpapiPluginProcessHost" << (is_broker_ ? "[broker]" : "")
395 << "::OnChannelError()"; 402 << "::OnChannelError()";
396 // We don't need to notify the renderers that were communicating with the 403 // We don't need to notify the renderers that were communicating with the
397 // plugin since they have their own channels which will go into the error 404 // plugin since they have their own channels which will go into the error
398 // state at the same time. Instead, we just need to notify any renderers 405 // state at the same time. Instead, we just need to notify any renderers
399 // that have requested a connection but have not yet received one. 406 // that have requested a connection but have not yet received one.
400 CancelRequests(); 407 CancelRequests();
401 } 408 }
402 409
403 void PpapiPluginProcessHost::CancelRequests() { 410 void PpapiPluginProcessHost::CancelRequests() {
(...skipping 22 matching lines...) Expand all
426 // sent_requests_ queue should be the one that the plugin just created. 433 // sent_requests_ queue should be the one that the plugin just created.
427 Client* client = sent_requests_.front(); 434 Client* client = sent_requests_.front();
428 sent_requests_.pop(); 435 sent_requests_.pop();
429 436
430 const ChildProcessData& data = process_->GetData(); 437 const ChildProcessData& data = process_->GetData();
431 client->OnPpapiChannelOpened(channel_handle, base::GetProcId(data.handle), 438 client->OnPpapiChannelOpened(channel_handle, base::GetProcId(data.handle),
432 data.id); 439 data.id);
433 } 440 }
434 441
435 } // namespace content 442 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698