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" |
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
262 if (plugins[i].is_internal && plugins[i].path == path) { | 262 if (plugins[i].is_internal && plugins[i].path == path) { |
263 // An internal plugin is being loaded, so fetch the entry points. | 263 // An internal plugin is being loaded, so fetch the entry points. |
264 plugin_entry_points_ = plugins[i].internal_entry_points; | 264 plugin_entry_points_ = plugins[i].internal_entry_points; |
265 } | 265 } |
266 } | 266 } |
267 | 267 |
268 // If the plugin isn't internal then load it from |path|. | 268 // If the plugin isn't internal then load it from |path|. |
269 base::ScopedNativeLibrary library; | 269 base::ScopedNativeLibrary library; |
270 if (plugin_entry_points_.initialize_module == NULL) { | 270 if (plugin_entry_points_.initialize_module == NULL) { |
271 // Load the plugin from the specified library. | 271 // Load the plugin from the specified library. |
272 std::string error; | 272 std::string error_message; |
273 library.Reset(base::LoadNativeLibrary(path, &error)); | 273 uint32 error_code = 0; |
274 library.Reset(base::LoadNativeLibrary(path, &error_message, &error_code)); | |
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 " |
276 << path.value() << " (error: " << error << ")"; | 277 << path.value() << " (error: " << error_message << " with error code " |
ddorwin
2014/03/20 22:01:12
nit: You could also do something like "error 'code
xhwang
2014/03/21 01:42:58
Done.
| |
278 << error_code << ")"; | |
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 // See http://msdn.microsoft.com/en-us/library/ms681381.aspx | |
ddorwin
2014/03/20 22:01:12
This is based on only Win reporting an error code.
xhwang
2014/03/21 01:42:58
Not required since we use sparse histogram.
| |
529 static const uint32 kMaxLoadErrorCode = 16000; | |
530 | |
531 std::ostringstream histogram_name; | |
532 histogram_name << "Plugin.Ppapi" << (is_broker_ ? "Broker" : "Plugin") | |
533 << "LoadErrorCode_" << path.BaseName().MaybeAsASCII(); | |
534 | |
535 // Note: This leaks memory, which is expected behavior. | |
536 base::HistogramBase* histogram = | |
537 base::LinearHistogram::FactoryGet( | |
ddorwin
2014/03/20 22:01:12
Should this be sparse?
xhwang
2014/03/21 01:42:58
Good point. Done.
| |
538 histogram_name.str(), | |
539 1, | |
540 kMaxLoadErrorCode, | |
541 kMaxLoadErrorCode + 1, | |
542 base::HistogramBase::kUmaTargetedHistogramFlag); | |
543 | |
544 histogram->Add(error_code); | |
545 } | |
546 | |
522 } // namespace content | 547 } // namespace content |
OLD | NEW |