diff options
author | vitalybuka@chromium.org <vitalybuka@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-12-03 20:32:07 +0000 |
---|---|---|
committer | vitalybuka@chromium.org <vitalybuka@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-12-03 20:32:07 +0000 |
commit | 5e04fb58560009c5555ff7fb9040521863403c74 (patch) | |
tree | bd1cc200e484ba7015d5dfdcadf29684471429e2 /ceee | |
parent | c4a1dc65ee5c402923c8e58ae29c502c58cbe0c1 (diff) | |
download | chromium_src-5e04fb58560009c5555ff7fb9040521863403c74.zip chromium_src-5e04fb58560009c5555ff7fb9040521863403c74.tar.gz chromium_src-5e04fb58560009c5555ff7fb9040521863403c74.tar.bz2 |
Adde histograms for addon NavTime.
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/5545002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@68207 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ceee')
-rw-r--r-- | ceee/ie/common/ie_util.cc | 19 | ||||
-rw-r--r-- | ceee/ie/common/ie_util.h | 8 | ||||
-rw-r--r-- | ceee/ie/common/ie_util_unittest.cc | 4 | ||||
-rw-r--r-- | ceee/ie/plugin/bho/browser_helper_object.cc | 26 | ||||
-rw-r--r-- | ceee/ie/plugin/bho/browser_helper_object.h | 5 |
5 files changed, 42 insertions, 20 deletions
diff --git a/ceee/ie/common/ie_util.cc b/ceee/ie/common/ie_util.cc index 2bc7a0c..7c1707d 100644 --- a/ceee/ie/common/ie_util.cc +++ b/ceee/ie/common/ie_util.cc @@ -141,7 +141,8 @@ HRESULT GetIEIsInProtectedMode(bool* is_protected_mode) { return hr; } -int GetAverageAddonLoadTimeMs(const CLSID& addon_id) { +int GetAverageAddonTimeMs(const CLSID& addon_id, + const std::wstring& time_prefix) { if (GetIeVersion() < IEVERSION_IE8) return kInvalidTime; @@ -164,19 +165,21 @@ int GetAverageAddonLoadTimeMs(const CLSID& addon_id) { DWORD load_time = 0; if (GetIeVersion() < IEVERSION_IE9) { - if (!stats_key.ReadValueDW(L"LoadTime", &load_time)) { - LOG(ERROR) << "Can't read LoadTime."; + if (!stats_key.ReadValueDW(time_prefix.c_str(), &load_time)) { + VLOG(1) << "Can't read time: " << time_prefix; return kInvalidTime; } } else { + std::wstring value_name(time_prefix); + value_name += L"Array"; DWORD count = 0; int32 values[100]; DWORD data_size = sizeof(values); DWORD data_type = REG_NONE; - if (!stats_key.ReadValue(L"LoadTimeArray", &values, &data_size, + if (!stats_key.ReadValue(value_name.c_str(), &values, &data_size, &data_type)) { - LOG(ERROR) << "Can't read LoadTime."; + VLOG(1) << "Can't read time: " << value_name; return kInvalidTime; } @@ -202,19 +205,19 @@ int GetAverageAddonLoadTimeMs(const CLSID& addon_id) { if (count < 2) { // IE9 shows performance warning only after second run. - LOG(INFO) << "Not enough data."; + VLOG(1) << "Not enough data. " << addon_id_str; return kInvalidTime; } load_time /= count; } + VLOG(1) << addon_id_str << "." << time_prefix << " = " << load_time << "ms"; + if (load_time < 0) { LOG(ERROR) << "Invalid time:" << load_time; return kInvalidTime; } - LOG(INFO) << "Average add-on " << addon_id_str << "load time: " << - load_time << "ms"; return load_time; } diff --git a/ceee/ie/common/ie_util.h b/ceee/ie/common/ie_util.h index 67e1762..7b3f7d8 100644 --- a/ceee/ie/common/ie_util.h +++ b/ceee/ie/common/ie_util.h @@ -47,10 +47,12 @@ bool GetIEIsInPrivateBrowsing(); HRESULT GetIEIsInProtectedMode(bool* is_protected_mode); const int kInvalidTime = -1; -// Returns average add-on load time measured by IE. Returns kInvalidTime if time -// cannot be calculated. +// Returns time spent on a given activity for this addon as measured by IE. +// Returns kInvalidTime if time cannot be calculated. // @param addon_id is class id which you can find in IE add-on manager. -int GetAverageAddonLoadTimeMs(const CLSID& addon_id); +// @param time_prefix specifies activity type. +int GetAverageAddonTimeMs(const CLSID& addon_id, + const std::wstring& time_prefix); } // namespace ie_util diff --git a/ceee/ie/common/ie_util_unittest.cc b/ceee/ie/common/ie_util_unittest.cc index 238bfd5..0d0eda9 100644 --- a/ceee/ie/common/ie_util_unittest.cc +++ b/ceee/ie/common/ie_util_unittest.cc @@ -44,6 +44,10 @@ class IeUtilTest : public testing::Test { registry_override_.reset(); } + int GetAverageAddonLoadTimeMs(const CLSID& addon_id) const { + return GetAverageAddonTimeMs(addon_id, L"LoadTime"); + } + scoped_ptr<testing::ScopedRegistryOverride> registry_override_; }; diff --git a/ceee/ie/plugin/bho/browser_helper_object.cc b/ceee/ie/plugin/bho/browser_helper_object.cc index 634facd..ae4222d 100644 --- a/ceee/ie/plugin/bho/browser_helper_object.cc +++ b/ceee/ie/plugin/bho/browser_helper_object.cc @@ -131,15 +131,24 @@ void BrowserHelperObject::FinalRelease() { web_browser_.Release(); } -void BrowserHelperObject::ReportAddonLoadTime(const char* addon_name, - const CLSID& addon_id) { - int time = ie_util::GetAverageAddonLoadTimeMs(addon_id); +void BrowserHelperObject::ReportAddonTimes(const char* name, + const CLSID& clsid) { + ReportSingleAddonTime(name, clsid, "LoadTime"); + ReportSingleAddonTime(name, clsid, "NavTime"); +} + +void BrowserHelperObject::ReportSingleAddonTime(const char* name, + const CLSID& clsid, + const char* type) { + int time = ie_util::GetAverageAddonTimeMs(clsid, ASCIIToWide(type)); if (time == ie_util::kInvalidTime) return; DCHECK(ie_util::GetIeVersion() >= ie_util::IEVERSION_IE8); - std::string counter_name = "ceee/AddonLoadTime."; - counter_name += addon_name; + std::string counter_name = "ceee/Addon"; + counter_name += type; + counter_name += "."; + counter_name += name; counter_name += ".IE"; switch (ie_util::GetIeVersion()) { case ie_util::IEVERSION_IE8: @@ -152,6 +161,7 @@ void BrowserHelperObject::ReportAddonLoadTime(const char* addon_name, counter_name += 'x'; break; } + VLOG(1) << counter_name << "=" << time; broker_rpc().SendUmaHistogramTimes(counter_name.c_str(), time); } @@ -172,9 +182,9 @@ STDMETHODIMP BrowserHelperObject::SetSite(IUnknown* site) { // TODO(vitalybuka@chromium.org): switch to sampling when we have enough // users. - ReportAddonLoadTime("BHO", CLSID_BrowserHelperObject); - ReportAddonLoadTime("ChromeFrameBHO", CLSID_ChromeFrameBHO); - ReportAddonLoadTime("Toolband", CLSID_ToolBand); + ReportAddonTimes("BHO", CLSID_BrowserHelperObject); + ReportAddonTimes("ChromeFrameBHO", CLSID_ChromeFrameBHO); + ReportAddonTimes("Toolband", CLSID_ToolBand); // We're being torn down. TearDown(); diff --git a/ceee/ie/plugin/bho/browser_helper_object.h b/ceee/ie/plugin/bho/browser_helper_object.h index 726f8ee..32be1b6 100644 --- a/ceee/ie/plugin/bho/browser_helper_object.h +++ b/ceee/ie/plugin/bho/browser_helper_object.h @@ -406,7 +406,10 @@ class ATL_NO_VTABLE BrowserHelperObject IWebBrowser2* root_browser); // Send metrics histograms about the average load time of IE addons. - void ReportAddonLoadTime(const char* addon_name, const CLSID& addon_id); + void ReportAddonTimes(const char* name, const CLSID& clsid); + void ReportSingleAddonTime(const char* name, + const CLSID& clsid, + const char* type); // This class is used as a replacement for the BrokerRpcClient for the // event funnels contained inside a BHO. When sending an event, this will |