Index: ppapi/native_client/src/trusted/plugin/plugin.cc |
diff --git a/ppapi/native_client/src/trusted/plugin/plugin.cc b/ppapi/native_client/src/trusted/plugin/plugin.cc |
index f348b0fcc1e42193b21fbbf7a07f01278340333e..69cda163031adfc0fb674899ee8068aa38652050 100644 |
--- a/ppapi/native_client/src/trusted/plugin/plugin.cc |
+++ b/ppapi/native_client/src/trusted/plugin/plugin.cc |
@@ -34,7 +34,6 @@ |
#include "ppapi/c/ppb_var.h" |
#include "ppapi/c/ppp_instance.h" |
#include "ppapi/c/private/ppb_nacl_private.h" |
-#include "ppapi/c/private/ppb_uma_private.h" |
#include "ppapi/cpp/dev/url_util_dev.h" |
#include "ppapi/cpp/module.h" |
#include "ppapi/cpp/text_input_controller.h" |
@@ -78,6 +77,13 @@ const char* const kDevAttribute = "@dev"; |
const char* const kChromeExtensionUriScheme = "chrome-extension"; |
const char* const kDataUriScheme = "data"; |
+const PPB_NaCl_Private* GetNaClInterface() { |
+ pp::Module *module = pp::Module::Get(); |
+ CHECK(module); |
+ return static_cast<const PPB_NaCl_Private*>( |
+ module->GetBrowserInterface(PPB_NACL_PRIVATE_INTERFACE)); |
+} |
+ |
// Up to 20 seconds |
const int64_t kTimeSmallMin = 1; // in ms |
const int64_t kTimeSmallMax = 20000; // in ms |
@@ -97,70 +103,48 @@ const int64_t kSizeKBMin = 1; |
const int64_t kSizeKBMax = 512*1024; // very large .nexe |
const uint32_t kSizeKBBuckets = 100; |
-const PPB_NaCl_Private* GetNaClInterface() { |
- pp::Module *module = pp::Module::Get(); |
- CHECK(module); |
- return static_cast<const PPB_NaCl_Private*>( |
- module->GetBrowserInterface(PPB_NACL_PRIVATE_INTERFACE)); |
-} |
- |
-const PPB_UMA_Private* GetUMAInterface() { |
- pp::Module *module = pp::Module::Get(); |
- CHECK(module); |
- return static_cast<const PPB_UMA_Private*>( |
- module->GetBrowserInterface(PPB_UMA_PRIVATE_INTERFACE)); |
-} |
+} // namespace |
-void HistogramTimeSmall(const std::string& name, int64_t ms) { |
+void Plugin::HistogramTimeSmall(const std::string& name, |
yzshen1
2013/12/04 19:32:51
Please keep the definitions in the same order as d
elijahtaylor1
2013/12/21 02:26:21
These Histogram functions were in the correct orde
yzshen1
2014/01/08 00:26:24
Yeah. It is good enough for me. Thanks!
On 2013/12
|
+ int64_t ms) { |
if (ms < 0) return; |
- |
- const PPB_UMA_Private* ptr = GetUMAInterface(); |
- if (ptr == NULL) return; |
- |
- ptr->HistogramCustomTimes(pp::Var(name).pp_var(), |
- ms, |
- kTimeSmallMin, kTimeSmallMax, |
- kTimeSmallBuckets); |
+ uma_interface_.HistogramCustomTimes(name, |
+ ms, |
+ kTimeSmallMin, kTimeSmallMax, |
+ kTimeSmallBuckets); |
} |
-void HistogramTimeMedium(const std::string& name, int64_t ms) { |
+void Plugin::HistogramTimeMedium(const std::string& name, |
+ int64_t ms) { |
if (ms < 0) return; |
- |
- const PPB_UMA_Private* ptr = GetUMAInterface(); |
- if (ptr == NULL) return; |
- |
- ptr->HistogramCustomTimes(pp::Var(name).pp_var(), |
- ms, |
- kTimeMediumMin, kTimeMediumMax, |
- kTimeMediumBuckets); |
+ uma_interface_.HistogramCustomTimes(name, |
+ ms, |
+ kTimeMediumMin, kTimeMediumMax, |
+ kTimeMediumBuckets); |
} |
-void HistogramTimeLarge(const std::string& name, int64_t ms) { |
+void Plugin::HistogramTimeLarge(const std::string& name, |
+ int64_t ms) { |
if (ms < 0) return; |
- |
- const PPB_UMA_Private* ptr = GetUMAInterface(); |
- if (ptr == NULL) return; |
- |
- ptr->HistogramCustomTimes(pp::Var(name).pp_var(), |
- ms, |
- kTimeLargeMin, kTimeLargeMax, |
- kTimeLargeBuckets); |
+ uma_interface_.HistogramCustomTimes(name, |
+ ms, |
+ kTimeLargeMin, kTimeLargeMax, |
+ kTimeLargeBuckets); |
} |
-void HistogramSizeKB(const std::string& name, int32_t sample) { |
+void Plugin::HistogramSizeKB(const std::string& name, |
+ int32_t sample) { |
if (sample < 0) return; |
- |
- const PPB_UMA_Private* ptr = GetUMAInterface(); |
- if (ptr == NULL) return; |
- |
- ptr->HistogramCustomCounts(pp::Var(name).pp_var(), |
- sample, |
- kSizeKBMin, kSizeKBMax, |
- kSizeKBBuckets); |
+ uma_interface_.HistogramCustomCounts(name, |
+ sample, |
+ kSizeKBMin, kSizeKBMax, |
+ kSizeKBBuckets); |
} |
-void HistogramEnumerate(const std::string& name, int sample, int maximum, |
- int out_of_range_replacement) { |
+void Plugin::HistogramEnumerate(const std::string& name, |
+ int sample, |
+ int maximum, |
+ int out_of_range_replacement) { |
if (sample < 0 || sample >= maximum) { |
if (out_of_range_replacement < 0) |
// No replacement for bad input, abort. |
@@ -169,12 +153,10 @@ void HistogramEnumerate(const std::string& name, int sample, int maximum, |
// Use a specific value to signal a bad input. |
sample = out_of_range_replacement; |
} |
- const PPB_UMA_Private* ptr = GetUMAInterface(); |
- if (ptr == NULL) return; |
- ptr->HistogramEnumeration(pp::Var(name).pp_var(), sample, maximum); |
+ uma_interface_.HistogramEnumeration(name, sample, maximum); |
} |
-void HistogramEnumerateOsArch(const std::string& sandbox_isa) { |
+void Plugin::HistogramEnumerateOsArch(const std::string& sandbox_isa) { |
enum NaClOSArch { |
kNaClLinux32 = 0, |
kNaClLinux64, |
@@ -205,22 +187,21 @@ void HistogramEnumerateOsArch(const std::string& sandbox_isa) { |
HistogramEnumerate("NaCl.Client.OSArch", os_arch, kNaClOSArchMax, -1); |
} |
-void HistogramEnumerateLoadStatus(PluginErrorCode error_code, |
- bool is_installed) { |
+void Plugin::HistogramEnumerateLoadStatus(PluginErrorCode error_code, |
+ bool is_installed) { |
HistogramEnumerate("NaCl.LoadStatus.Plugin", error_code, ERROR_MAX, |
ERROR_UNKNOWN); |
// Gather data to see if being installed changes load outcomes. |
const char* name = is_installed ? "NaCl.LoadStatus.Plugin.InstalledApp" : |
"NaCl.LoadStatus.Plugin.NotInstalledApp"; |
- HistogramEnumerate(name, error_code, ERROR_MAX, |
- ERROR_UNKNOWN); |
+ HistogramEnumerate(name, error_code, ERROR_MAX, ERROR_UNKNOWN); |
} |
-void HistogramEnumerateSelLdrLoadStatus(NaClErrorCode error_code, |
- bool is_installed) { |
- HistogramEnumerate("NaCl.LoadStatus.SelLdr", error_code, NACL_ERROR_CODE_MAX, |
- LOAD_STATUS_UNKNOWN); |
+void Plugin::HistogramEnumerateSelLdrLoadStatus(NaClErrorCode error_code, |
+ bool is_installed) { |
+ HistogramEnumerate("NaCl.LoadStatus.SelLdr", error_code, |
+ NACL_ERROR_CODE_MAX, LOAD_STATUS_UNKNOWN); |
// Gather data to see if being installed changes load outcomes. |
const char* name = is_installed ? "NaCl.LoadStatus.SelLdr.InstalledApp" : |
@@ -229,11 +210,12 @@ void HistogramEnumerateSelLdrLoadStatus(NaClErrorCode error_code, |
LOAD_STATUS_UNKNOWN); |
} |
-void HistogramEnumerateManifestIsDataURI(bool is_data_uri) { |
+void Plugin::HistogramEnumerateManifestIsDataURI(bool is_data_uri) { |
HistogramEnumerate("NaCl.Manifest.IsDataURI", is_data_uri, 2, -1); |
} |
-void HistogramHTTPStatusCode(const std::string& name, int status) { |
+void Plugin::HistogramHTTPStatusCode(const std::string& name, |
+ int status) { |
// Log the status codes in rough buckets - 1XX, 2XX, etc. |
int sample = status / 100; |
// HTTP status codes only go up to 5XX, using "6" to indicate an internal |
@@ -244,8 +226,6 @@ void HistogramHTTPStatusCode(const std::string& name, int status) { |
HistogramEnumerate(name, sample, 7, 6); |
} |
-} // namespace |
- |
void Plugin::AddPropertyGet(const nacl::string& prop_name, |
Plugin::PropertyGetter getter) { |
PLUGIN_PRINTF(("Plugin::AddPropertyGet (prop_name='%s')\n", |
@@ -701,7 +681,8 @@ Plugin::Plugin(PP_Instance pp_instance) |
ready_time_(0), |
nexe_size_(0), |
time_of_last_progress_event_(0), |
- nacl_interface_(NULL) { |
+ nacl_interface_(NULL), |
+ uma_interface_(this) { |
PLUGIN_PRINTF(("Plugin::Plugin (this=%p, pp_instance=%" |
NACL_PRId32 ")\n", static_cast<void*>(this), pp_instance)); |
callback_factory_.Initialize(this); |
@@ -1355,7 +1336,6 @@ void Plugin::ReportLoadSuccess(LengthComputable length_computable, |
} |
-// TODO(ncbray): report UMA stats |
void Plugin::ReportLoadError(const ErrorInfo& error_info) { |
PLUGIN_PRINTF(("Plugin::ReportLoadError (error='%s')\n", |
error_info.message().c_str())); |