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

Side by Side Diff: content/ppapi_plugin/ppapi_thread.cc

Issue 13548005: Add UMA reporting on failure to load ppapi plugins. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: comments resolved Created 7 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
« no previous file with comments | « content/ppapi_plugin/ppapi_thread.h ('k') | content/public/plugin/content_plugin_client.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/ppapi_plugin/ppapi_thread.h" 5 #include "content/ppapi_plugin/ppapi_thread.h"
6 6
7 #include <limits> 7 #include <limits>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/debug/crash_logging.h" 10 #include "base/debug/crash_logging.h"
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 252
253 // If the plugin isn't internal then load it from |path|. 253 // If the plugin isn't internal then load it from |path|.
254 base::ScopedNativeLibrary library; 254 base::ScopedNativeLibrary library;
255 if (plugin_entry_points_.initialize_module == NULL) { 255 if (plugin_entry_points_.initialize_module == NULL) {
256 // Load the plugin from the specified library. 256 // Load the plugin from the specified library.
257 std::string error; 257 std::string error;
258 library.Reset(base::LoadNativeLibrary(path, &error)); 258 library.Reset(base::LoadNativeLibrary(path, &error));
259 if (!library.is_valid()) { 259 if (!library.is_valid()) {
260 LOG(ERROR) << "Failed to load Pepper module from " 260 LOG(ERROR) << "Failed to load Pepper module from "
261 << path.value() << " (error: " << error << ")"; 261 << path.value() << " (error: " << error << ")";
262 ReportLoadResult(path, ContentPluginClient::LOAD_FAILED);
262 return; 263 return;
263 } 264 }
264 265
265 // Get the GetInterface function (required). 266 // Get the GetInterface function (required).
266 plugin_entry_points_.get_interface = 267 plugin_entry_points_.get_interface =
267 reinterpret_cast<PP_GetInterface_Func>( 268 reinterpret_cast<PP_GetInterface_Func>(
268 library.GetFunctionPointer("PPP_GetInterface")); 269 library.GetFunctionPointer("PPP_GetInterface"));
269 if (!plugin_entry_points_.get_interface) { 270 if (!plugin_entry_points_.get_interface) {
270 LOG(WARNING) << "No PPP_GetInterface in plugin library"; 271 LOG(WARNING) << "No PPP_GetInterface in plugin library";
272 ReportLoadResult(path, ContentPluginClient::ENTRY_POINT_MISSING);
271 return; 273 return;
272 } 274 }
273 275
274 // The ShutdownModule/ShutdownBroker function is optional. 276 // The ShutdownModule/ShutdownBroker function is optional.
275 plugin_entry_points_.shutdown_module = 277 plugin_entry_points_.shutdown_module =
276 is_broker_ ? 278 is_broker_ ?
277 reinterpret_cast<PP_ShutdownModule_Func>( 279 reinterpret_cast<PP_ShutdownModule_Func>(
278 library.GetFunctionPointer("PPP_ShutdownBroker")) : 280 library.GetFunctionPointer("PPP_ShutdownBroker")) :
279 reinterpret_cast<PP_ShutdownModule_Func>( 281 reinterpret_cast<PP_ShutdownModule_Func>(
280 library.GetFunctionPointer("PPP_ShutdownModule")); 282 library.GetFunctionPointer("PPP_ShutdownModule"));
281 283
282 if (!is_broker_) { 284 if (!is_broker_) {
283 // Get the InitializeModule function (required for non-broker code). 285 // Get the InitializeModule function (required for non-broker code).
284 plugin_entry_points_.initialize_module = 286 plugin_entry_points_.initialize_module =
285 reinterpret_cast<PP_InitializeModule_Func>( 287 reinterpret_cast<PP_InitializeModule_Func>(
286 library.GetFunctionPointer("PPP_InitializeModule")); 288 library.GetFunctionPointer("PPP_InitializeModule"));
287 if (!plugin_entry_points_.initialize_module) { 289 if (!plugin_entry_points_.initialize_module) {
288 LOG(WARNING) << "No PPP_InitializeModule in plugin library"; 290 LOG(WARNING) << "No PPP_InitializeModule in plugin library";
291 ReportLoadResult(path, ContentPluginClient::ENTRY_POINT_MISSING);
289 return; 292 return;
290 } 293 }
291 } 294 }
292 } 295 }
293 296
294 #if defined(OS_WIN) 297 #if defined(OS_WIN)
295 // If code subsequently tries to exit using abort(), force a crash (since 298 // If code subsequently tries to exit using abort(), force a crash (since
296 // otherwise these would be silent terminations and fly under the radar). 299 // otherwise these would be silent terminations and fly under the radar).
297 base::win::SetAbortBehaviorForCrashReporting(); 300 base::win::SetAbortBehaviorForCrashReporting();
298 if (permissions.HasPermission(ppapi::PERMISSION_FLASH)) { 301 if (permissions.HasPermission(ppapi::PERMISSION_FLASH)) {
(...skipping 17 matching lines...) Expand all
316 } 319 }
317 #endif 320 #endif
318 321
319 if (is_broker_) { 322 if (is_broker_) {
320 // Get the InitializeBroker function (required). 323 // Get the InitializeBroker function (required).
321 InitializeBrokerFunc init_broker = 324 InitializeBrokerFunc init_broker =
322 reinterpret_cast<InitializeBrokerFunc>( 325 reinterpret_cast<InitializeBrokerFunc>(
323 library.GetFunctionPointer("PPP_InitializeBroker")); 326 library.GetFunctionPointer("PPP_InitializeBroker"));
324 if (!init_broker) { 327 if (!init_broker) {
325 LOG(WARNING) << "No PPP_InitializeBroker in plugin library"; 328 LOG(WARNING) << "No PPP_InitializeBroker in plugin library";
329 ReportLoadResult(path, ContentPluginClient::ENTRY_POINT_MISSING);
326 return; 330 return;
327 } 331 }
328 332
329 int32_t init_error = init_broker(&connect_instance_func_); 333 int32_t init_error = init_broker(&connect_instance_func_);
330 if (init_error != PP_OK) { 334 if (init_error != PP_OK) {
331 LOG(WARNING) << "InitBroker failed with error " << init_error; 335 LOG(WARNING) << "InitBroker failed with error " << init_error;
336 ReportLoadResult(path, ContentPluginClient::INIT_FAILED);
332 return; 337 return;
333 } 338 }
334 if (!connect_instance_func_) { 339 if (!connect_instance_func_) {
335 LOG(WARNING) << "InitBroker did not provide PP_ConnectInstance_Func"; 340 LOG(WARNING) << "InitBroker did not provide PP_ConnectInstance_Func";
341 ReportLoadResult(path, ContentPluginClient::ENTRY_POINT_MISSING);
ddorwin 2013/04/09 00:50:40 Is this a missing entry point or a failure (INIT_F
xhwang 2013/04/09 00:54:05 Done.
336 return; 342 return;
337 } 343 }
338 } else { 344 } else {
339 #if defined(OS_MACOSX) 345 #if defined(OS_MACOSX)
340 // We need to do this after getting |PPP_GetInterface()| (or presumably 346 // We need to do this after getting |PPP_GetInterface()| (or presumably
341 // doing something nontrivial with the library), else the sandbox 347 // doing something nontrivial with the library), else the sandbox
342 // intercedes. 348 // intercedes.
343 CHECK(InitializeSandbox()); 349 CHECK(InitializeSandbox());
344 #endif 350 #endif
345 351
346 int32_t init_error = plugin_entry_points_.initialize_module( 352 int32_t init_error = plugin_entry_points_.initialize_module(
347 local_pp_module_, 353 local_pp_module_,
348 &ppapi::proxy::PluginDispatcher::GetBrowserInterface); 354 &ppapi::proxy::PluginDispatcher::GetBrowserInterface);
349 if (init_error != PP_OK) { 355 if (init_error != PP_OK) {
350 LOG(WARNING) << "InitModule failed with error " << init_error; 356 LOG(WARNING) << "InitModule failed with error " << init_error;
357 ReportLoadResult(path, ContentPluginClient::INIT_FAILED);
351 return; 358 return;
352 } 359 }
353 } 360 }
354 361
355 // Initialization succeeded, so keep the plugin DLL loaded. 362 // Initialization succeeded, so keep the plugin DLL loaded.
363 ReportLoadResult(path, ContentPluginClient::LOAD_SUCCESS);
356 library_.Reset(library.Release()); 364 library_.Reset(library.Release());
357 } 365 }
358 366
359 void PpapiThread::OnCreateChannel(base::ProcessId renderer_pid, 367 void PpapiThread::OnCreateChannel(base::ProcessId renderer_pid,
360 int renderer_child_id, 368 int renderer_child_id,
361 bool incognito) { 369 bool incognito) {
362 IPC::ChannelHandle channel_handle; 370 IPC::ChannelHandle channel_handle;
363 371
364 if (!plugin_entry_points_.get_interface || // Plugin couldn't be loaded. 372 if (!plugin_entry_points_.get_interface || // Plugin couldn't be loaded.
365 !SetupRendererChannel(renderer_pid, renderer_child_id, incognito, 373 !SetupRendererChannel(renderer_pid, renderer_child_id, incognito,
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
452 460
453 // From here, the dispatcher will manage its own lifetime according to the 461 // From here, the dispatcher will manage its own lifetime according to the
454 // lifetime of the attached channel. 462 // lifetime of the attached channel.
455 return true; 463 return true;
456 } 464 }
457 465
458 void PpapiThread::SavePluginName(const base::FilePath& path) { 466 void PpapiThread::SavePluginName(const base::FilePath& path) {
459 ppapi::proxy::PluginGlobals::Get()->set_plugin_name( 467 ppapi::proxy::PluginGlobals::Get()->set_plugin_name(
460 path.BaseName().AsUTF8Unsafe()); 468 path.BaseName().AsUTF8Unsafe());
461 469
462 // plugin() is NULL when in-process. Which is fine, because this is 470 // plugin() is NULL when in-process, which is fine, because this is
463 // just a hook for setting the process name. 471 // just a hook for setting the process name.
464 if (GetContentClient()->plugin()) { 472 if (GetContentClient()->plugin()) {
465 GetContentClient()->plugin()->PluginProcessStarted( 473 GetContentClient()->plugin()->PluginProcessStarted(
466 path.BaseName().RemoveExtension().LossyDisplayName()); 474 path.BaseName().RemoveExtension().LossyDisplayName());
467 } 475 }
468 } 476 }
469 477
478 void PpapiThread::ReportLoadResult(
479 const base::FilePath& path,
480 ContentPluginClient::PluginLoadResult result) {
481 // plugin() is NULL when in-process, which is fine, because we only care
482 // about loading status for out-of-process plugins.
483 if (GetContentClient()->plugin())
484 GetContentClient()->plugin()->PluginLoaded(path, is_broker_, result);
485 }
486
470 } // namespace content 487 } // namespace content
OLDNEW
« no previous file with comments | « content/ppapi_plugin/ppapi_thread.h ('k') | content/public/plugin/content_plugin_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698