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

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

Issue 206713004: Report PPAPI plugin load error code to UMA. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Make NativeLibraryLoadError a class. Created 6 years, 9 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/zygote/zygote_main_linux.cc » ('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/cpu.h" 10 #include "base/cpu.h"
11 #include "base/debug/crash_logging.h" 11 #include "base/debug/crash_logging.h"
12 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "base/metrics/histogram.h" 13 #include "base/metrics/histogram.h"
14 #include "base/metrics/sparse_histogram.h"
14 #include "base/rand_util.h" 15 #include "base/rand_util.h"
15 #include "base/strings/stringprintf.h" 16 #include "base/strings/stringprintf.h"
16 #include "base/strings/utf_string_conversions.h" 17 #include "base/strings/utf_string_conversions.h"
17 #include "base/threading/platform_thread.h" 18 #include "base/threading/platform_thread.h"
18 #include "base/time/time.h" 19 #include "base/time/time.h"
19 #include "content/child/browser_font_resource_trusted.h" 20 #include "content/child/browser_font_resource_trusted.h"
20 #include "content/child/child_process.h" 21 #include "content/child/child_process.h"
21 #include "content/common/child_process_messages.h" 22 #include "content/common/child_process_messages.h"
22 #include "content/common/sandbox_util.h" 23 #include "content/common/sandbox_util.h"
23 #include "content/ppapi_plugin/broker_process_dispatcher.h" 24 #include "content/ppapi_plugin/broker_process_dispatcher.h"
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 if (plugins[i].is_internal && plugins[i].path == path) { 263 if (plugins[i].is_internal && plugins[i].path == path) {
263 // An internal plugin is being loaded, so fetch the entry points. 264 // An internal plugin is being loaded, so fetch the entry points.
264 plugin_entry_points_ = plugins[i].internal_entry_points; 265 plugin_entry_points_ = plugins[i].internal_entry_points;
265 } 266 }
266 } 267 }
267 268
268 // If the plugin isn't internal then load it from |path|. 269 // If the plugin isn't internal then load it from |path|.
269 base::ScopedNativeLibrary library; 270 base::ScopedNativeLibrary library;
270 if (plugin_entry_points_.initialize_module == NULL) { 271 if (plugin_entry_points_.initialize_module == NULL) {
271 // Load the plugin from the specified library. 272 // Load the plugin from the specified library.
272 std::string error; 273 base::NativeLibraryLoadError error;
273 library.Reset(base::LoadNativeLibrary(path, &error)); 274 library.Reset(base::LoadNativeLibrary(path, &error));
274 if (!library.is_valid()) { 275 if (!library.is_valid()) {
275 LOG(ERROR) << "Failed to load Pepper module from " 276 LOG(ERROR) << "Failed to load Pepper module from " << path.value()
276 << path.value() << " (error: " << error << ")"; 277 << " (error: " << error << ")";
277 ReportLoadResult(path, LOAD_FAILED); 278 ReportLoadResult(path, LOAD_FAILED);
279 // Report detailed reason for load failure.
280 ReportLoadErrorCode(path, error);
278 return; 281 return;
279 } 282 }
280 283
281 // Get the GetInterface function (required). 284 // Get the GetInterface function (required).
282 plugin_entry_points_.get_interface = 285 plugin_entry_points_.get_interface =
283 reinterpret_cast<PP_GetInterface_Func>( 286 reinterpret_cast<PP_GetInterface_Func>(
284 library.GetFunctionPointer("PPP_GetInterface")); 287 library.GetFunctionPointer("PPP_GetInterface"));
285 if (!plugin_entry_points_.get_interface) { 288 if (!plugin_entry_points_.get_interface) {
286 LOG(WARNING) << "No PPP_GetInterface in plugin library"; 289 LOG(WARNING) << "No PPP_GetInterface in plugin library";
287 ReportLoadResult(path, ENTRY_POINT_MISSING); 290 ReportLoadResult(path, ENTRY_POINT_MISSING);
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
495 // just a hook for setting the process name. 498 // just a hook for setting the process name.
496 if (GetContentClient()->plugin()) { 499 if (GetContentClient()->plugin()) {
497 GetContentClient()->plugin()->PluginProcessStarted( 500 GetContentClient()->plugin()->PluginProcessStarted(
498 path.BaseName().RemoveExtension().LossyDisplayName()); 501 path.BaseName().RemoveExtension().LossyDisplayName());
499 } 502 }
500 } 503 }
501 504
502 void PpapiThread::ReportLoadResult(const base::FilePath& path, 505 void PpapiThread::ReportLoadResult(const base::FilePath& path,
503 LoadResult result) { 506 LoadResult result) {
504 DCHECK_LT(result, LOAD_RESULT_MAX); 507 DCHECK_LT(result, LOAD_RESULT_MAX);
505 508 std::string histogram_name = std::string("Plugin.Ppapi") +
506 std::ostringstream histogram_name; 509 (is_broker_ ? "Broker" : "Plugin") +
507 histogram_name << "Plugin.Ppapi" << (is_broker_ ? "Broker" : "Plugin") 510 "LoadResult_" + path.BaseName().MaybeAsASCII();
508 << "LoadResult_" << path.BaseName().MaybeAsASCII();
509 511
510 // Note: This leaks memory, which is expected behavior. 512 // Note: This leaks memory, which is expected behavior.
511 base::HistogramBase* histogram = 513 base::HistogramBase* histogram =
512 base::LinearHistogram::FactoryGet( 514 base::LinearHistogram::FactoryGet(
513 histogram_name.str(), 515 histogram_name,
514 1, 516 1,
515 LOAD_RESULT_MAX, 517 LOAD_RESULT_MAX,
516 LOAD_RESULT_MAX + 1, 518 LOAD_RESULT_MAX + 1,
517 base::HistogramBase::kUmaTargetedHistogramFlag); 519 base::HistogramBase::kUmaTargetedHistogramFlag);
518 520
519 histogram->Add(result); 521 histogram->Add(result);
520 } 522 }
521 523
524 void PpapiThread::ReportLoadErrorCode(
ddorwin 2014/03/21 22:47:01 Maybe comment that this is only reported on Window
xhwang 2014/03/21 23:02:04 Done.
525 const base::FilePath& path,
526 const base::NativeLibraryLoadError& error) {
527 #if defined(OS_WIN)
528 std::string histogram_name =
529 std::string("Plugin.Ppapi") + (is_broker_ ? "Broker" : "Plugin") +
530 "LoadErrorCode_" + path.BaseName().MaybeAsASCII();
531
532 // For sparse histograms, we can use the macro, as it does not incorporate a
533 // static.
534 UMA_HISTOGRAM_SPARSE_SLOWLY(histogram_name, error.code);
535 #endif
536 }
537
522 } // namespace content 538 } // namespace content
OLDNEW
« no previous file with comments | « content/ppapi_plugin/ppapi_thread.h ('k') | content/zygote/zygote_main_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698