| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/plugin/chrome_content_plugin_client.h" | 5 #include "chrome/plugin/chrome_content_plugin_client.h" |
| 6 | 6 |
| 7 #include <sstream> |
| 8 |
| 9 #include "base/metrics/histogram.h" |
| 10 #include "chrome/common/chrome_constants.h" |
| 11 #include "third_party/widevine/cdm/widevine_cdm_common.h" |
| 12 |
| 7 #if defined(ENABLE_REMOTING) | 13 #if defined(ENABLE_REMOTING) |
| 8 #include "base/files/file_path.h" | 14 #include "base/files/file_path.h" |
| 9 #include "base/path_service.h" | 15 #include "base/path_service.h" |
| 10 #include "content/public/common/content_paths.h" | 16 #include "content/public/common/content_paths.h" |
| 11 #include "media/base/media.h" | 17 #include "media/base/media.h" |
| 12 #if defined(OS_WIN) | 18 #if defined(OS_WIN) |
| 13 #include "base/logging.h" | 19 #include "base/logging.h" |
| 14 #include "base/native_library.h" | 20 #include "base/native_library.h" |
| 15 #elif defined(OS_POSIX) && !defined(OS_MACOSX) && defined(USE_NSS) | 21 #elif defined(OS_POSIX) && !defined(OS_MACOSX) && defined(USE_NSS) |
| 16 #include "crypto/nss_util.h" | 22 #include "crypto/nss_util.h" |
| 17 #endif | 23 #endif // defined(OS_WIN) |
| 18 #endif | 24 #endif // defined(ENABLE_REMOTING) |
| 19 | 25 |
| 20 #if defined(OS_MACOSX) | 26 #if defined(OS_MACOSX) |
| 21 #include "base/mac/mac_util.h" | 27 #include "base/mac/mac_util.h" |
| 22 #include "base/mac/scoped_cftyperef.h" | 28 #include "base/mac/scoped_cftyperef.h" |
| 23 #include "base/strings/sys_string_conversions.h" | 29 #include "base/strings/sys_string_conversions.h" |
| 24 #include "grit/chromium_strings.h" | 30 #include "grit/chromium_strings.h" |
| 25 #include "ui/base/l10n/l10n_util.h" | 31 #include "ui/base/l10n/l10n_util.h" |
| 26 #endif | 32 #endif // defined(OS_MACOSX) |
| 27 | 33 |
| 28 namespace chrome { | 34 namespace chrome { |
| 29 | 35 |
| 30 void ChromeContentPluginClient::PreSandboxInitialization() { | 36 void ChromeContentPluginClient::PreSandboxInitialization() { |
| 31 #if defined(ENABLE_REMOTING) | 37 #if defined(ENABLE_REMOTING) |
| 32 | 38 |
| 33 // Load crypto libraries for the Chromoting client plugin. | 39 // Load crypto libraries for the Chromoting client plugin. |
| 34 #if defined(OS_POSIX) && !defined(OS_MACOSX) && defined(USE_NSS) | 40 #if defined(OS_POSIX) && !defined(OS_MACOSX) && defined(USE_NSS) |
| 35 // On platforms where we use system NSS libraries, the .so's must be loaded | 41 // On platforms where we use system NSS libraries, the .so's must be loaded |
| 36 // before the sandbox is initialized. | 42 // before the sandbox is initialized. |
| (...skipping 23 matching lines...) Expand all Loading... |
| 60 base::mac::ScopedCFTypeRef<CFStringRef> app_name( | 66 base::mac::ScopedCFTypeRef<CFStringRef> app_name( |
| 61 base::SysUTF16ToCFStringRef( | 67 base::SysUTF16ToCFStringRef( |
| 62 l10n_util::GetStringUTF16(IDS_SHORT_PLUGIN_APP_NAME))); | 68 l10n_util::GetStringUTF16(IDS_SHORT_PLUGIN_APP_NAME))); |
| 63 base::mac::ScopedCFTypeRef<CFStringRef> process_name( | 69 base::mac::ScopedCFTypeRef<CFStringRef> process_name( |
| 64 CFStringCreateWithFormat(kCFAllocatorDefault, NULL, CFSTR("%@ (%@)"), | 70 CFStringCreateWithFormat(kCFAllocatorDefault, NULL, CFSTR("%@ (%@)"), |
| 65 cf_plugin_name.get(), app_name.get())); | 71 cf_plugin_name.get(), app_name.get())); |
| 66 base::mac::SetProcessName(process_name); | 72 base::mac::SetProcessName(process_name); |
| 67 #endif | 73 #endif |
| 68 } | 74 } |
| 69 | 75 |
| 76 static void ReportPluginLoadUMA(const std::string& plugin_name, |
| 77 bool is_broker, |
| 78 int result) { |
| 79 DCHECK_LT(result, content::ContentPluginClient::LOAD_RESULT_MAX); |
| 80 |
| 81 std::ostringstream histogram_name; |
| 82 histogram_name << "Plugin." << (is_broker ? "Broker" : "Plugin") |
| 83 << "LoadResult." << plugin_name; |
| 84 |
| 85 // Note: This leaks memory, which is expected behavior. |
| 86 base::HistogramBase* histogram = |
| 87 base::LinearHistogram::FactoryGet( |
| 88 histogram_name.str(), |
| 89 1, |
| 90 content::ContentPluginClient::LOAD_RESULT_MAX, |
| 91 content::ContentPluginClient::LOAD_RESULT_MAX + 1, |
| 92 base::HistogramBase::kUmaTargetedHistogramFlag); |
| 93 |
| 94 histogram->Add(result); |
| 95 } |
| 96 |
| 97 void ChromeContentPluginClient::PluginLoaded(const base::FilePath& plugin_path, |
| 98 bool is_broker, |
| 99 PluginLoadResult result) { |
| 100 base::FilePath::StringType plugin_name = plugin_path.BaseName().value(); |
| 101 if (plugin_name == kPepperFlashPluginFilename) { |
| 102 ReportPluginLoadUMA("PepperFlash", is_broker, result); |
| 103 } else if (plugin_name == kWidevineCdmPluginFileName) { |
| 104 ReportPluginLoadUMA("WidevineCDM", is_broker, result); |
| 105 } |
| 106 } |
| 107 |
| 70 } // namespace chrome | 108 } // namespace chrome |
| OLD | NEW |