Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 std::string error_message; |
| 273 library.Reset(base::LoadNativeLibrary(path, &error)); | 274 uint32 error_code = 0; |
| 275 library.Reset(base::LoadNativeLibrary(path, &error_message, &error_code)); | |
| 274 if (!library.is_valid()) { | 276 if (!library.is_valid()) { |
| 275 LOG(ERROR) << "Failed to load Pepper module from " | 277 LOG(ERROR) << "Failed to load Pepper module from " << path.value() |
| 276 << path.value() << " (error: " << error << ")"; | 278 << " (error: " << error_code << " - " << error_message << ")"; |
| 277 ReportLoadResult(path, LOAD_FAILED); | 279 ReportLoadResult(path, LOAD_FAILED); |
| 280 // Report detailed reason for load failure. | |
| 281 ReportLoadErrorCode(path, error_code); | |
| 278 return; | 282 return; |
| 279 } | 283 } |
| 280 | 284 |
| 281 // Get the GetInterface function (required). | 285 // Get the GetInterface function (required). |
| 282 plugin_entry_points_.get_interface = | 286 plugin_entry_points_.get_interface = |
| 283 reinterpret_cast<PP_GetInterface_Func>( | 287 reinterpret_cast<PP_GetInterface_Func>( |
| 284 library.GetFunctionPointer("PPP_GetInterface")); | 288 library.GetFunctionPointer("PPP_GetInterface")); |
| 285 if (!plugin_entry_points_.get_interface) { | 289 if (!plugin_entry_points_.get_interface) { |
| 286 LOG(WARNING) << "No PPP_GetInterface in plugin library"; | 290 LOG(WARNING) << "No PPP_GetInterface in plugin library"; |
| 287 ReportLoadResult(path, ENTRY_POINT_MISSING); | 291 ReportLoadResult(path, ENTRY_POINT_MISSING); |
| (...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 512 base::LinearHistogram::FactoryGet( | 516 base::LinearHistogram::FactoryGet( |
| 513 histogram_name.str(), | 517 histogram_name.str(), |
| 514 1, | 518 1, |
| 515 LOAD_RESULT_MAX, | 519 LOAD_RESULT_MAX, |
| 516 LOAD_RESULT_MAX + 1, | 520 LOAD_RESULT_MAX + 1, |
| 517 base::HistogramBase::kUmaTargetedHistogramFlag); | 521 base::HistogramBase::kUmaTargetedHistogramFlag); |
| 518 | 522 |
| 519 histogram->Add(result); | 523 histogram->Add(result); |
| 520 } | 524 } |
| 521 | 525 |
| 526 void PpapiThread::ReportLoadErrorCode(const base::FilePath& path, | |
| 527 uint32 error_code) { | |
| 528 std::ostringstream histogram_name; | |
|
jar (doing other things)
2014/03/21 17:21:56
nit: I think that cleaner (probably faster) and ve
xhwang
2014/03/21 19:00:54
Done.
| |
| 529 histogram_name << "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.str(), error_code); | |
|
jar (doing other things)
2014/03/21 17:21:56
nit: Don't turn this into a str(). Just pass the
xhwang
2014/03/21 19:00:54
Done.
| |
| 535 } | |
| 536 | |
| 522 } // namespace content | 537 } // namespace content |
| OLD | NEW |