diff options
author | erikkay@chromium.org <erikkay@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-06 17:24:36 +0000 |
---|---|---|
committer | erikkay@chromium.org <erikkay@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-06 17:24:36 +0000 |
commit | cc2c343ff3ef0e546c6a4788c182d29b4f8341eb (patch) | |
tree | c9d90b7ae6569cb549f7f91f7cee7636435ff5eb | |
parent | 7b032aa6098222270f9f78ede822e1256e672a08 (diff) | |
download | chromium_src-cc2c343ff3ef0e546c6a4788c182d29b4f8341eb.zip chromium_src-cc2c343ff3ef0e546c6a4788c182d29b4f8341eb.tar.gz chromium_src-cc2c343ff3ef0e546c6a4788c182d29b4f8341eb.tar.bz2 |
add some histograms to extensions
TEST=none
BUG=none
Review URL: http://codereview.chromium.org/372005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@31241 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/extensions/extension_host.cc | 10 | ||||
-rw-r--r-- | chrome/browser/extensions/extension_host.h | 4 | ||||
-rw-r--r-- | chrome/browser/extensions/extension_updater.cc | 46 | ||||
-rw-r--r-- | chrome/browser/extensions/extensions_service.cc | 45 | ||||
-rw-r--r-- | chrome/renderer/user_script_slave.cc | 18 |
5 files changed, 119 insertions, 4 deletions
diff --git a/chrome/browser/extensions/extension_host.cc b/chrome/browser/extensions/extension_host.cc index e2cea15..541c4a9 100644 --- a/chrome/browser/extensions/extension_host.cc +++ b/chrome/browser/extensions/extension_host.cc @@ -373,6 +373,16 @@ void ExtensionHost::DidStopLoading() { NotificationType::EXTENSION_HOST_DID_STOP_LOADING, Source<Profile>(profile_), Details<ExtensionHost>(this)); + if (extension_host_type_ == ViewType::EXTENSION_BACKGROUND_PAGE) { + UMA_HISTOGRAM_TIMES("Extensions.BackgroundPageLoadTime", + since_created_.Elapsed()); + } else if (extension_host_type_ == ViewType::EXTENSION_POPUP) { + UMA_HISTOGRAM_TIMES("Extensions.PopupLoadTime", + since_created_.Elapsed()); + } else if (extension_host_type_ == ViewType::EXTENSION_TOOLSTRIP) { + UMA_HISTOGRAM_TIMES("Extensions.ToolstripLoadTime", + since_created_.Elapsed()); + } } } diff --git a/chrome/browser/extensions/extension_host.h b/chrome/browser/extensions/extension_host.h index 22279a1..e9b414d 100644 --- a/chrome/browser/extensions/extension_host.h +++ b/chrome/browser/extensions/extension_host.h @@ -7,6 +7,7 @@ #include <string> +#include "base/perftimer.h" #include "base/scoped_ptr.h" #include "chrome/browser/extensions/extension_function_dispatcher.h" #include "chrome/browser/jsmessage_box_client.h" @@ -251,6 +252,9 @@ class ExtensionHost : // NOLINT // are used here, others are not hosted by ExtensionHost. ViewType::Type extension_host_type_; + // Used to measure how long it's been since the host was created. + PerfTimer since_created_; + DISALLOW_COPY_AND_ASSIGN(ExtensionHost); }; diff --git a/chrome/browser/extensions/extension_updater.cc b/chrome/browser/extensions/extension_updater.cc index 7cf0e4d..28958be 100644 --- a/chrome/browser/extensions/extension_updater.cc +++ b/chrome/browser/extensions/extension_updater.cc @@ -462,6 +462,21 @@ void ExtensionUpdater::ScheduleNextCheck(const TimeDelta& target_delay) { void ExtensionUpdater::TimerFired() { CheckNow(); + // If the user has overridden the update frequency, don't bother reporting + // this. + if (frequency_seconds_ == ExtensionsService::kDefaultUpdateFrequencySeconds) { + Time last = Time::FromInternalValue(prefs_->GetInt64( + kLastExtensionsUpdateCheck)); + if (last.ToInternalValue() != 0) { + // Use counts rather than time so we can use minutes rather than millis. + UMA_HISTOGRAM_CUSTOM_COUNTS("Extensions.UpdateCheckGap", + (Time::Now() - last).InMinutes(), + base::TimeDelta::FromSeconds(kStartupWaitSeconds).InMinutes(), + base::TimeDelta::FromDays(40).InMinutes(), + 50); // 50 buckets seems to be the default. + } + } + // Save the last check time, and schedule the next check. int64 now = Time::Now().ToInternalValue(); prefs_->SetInt64(kLastExtensionsUpdateCheck, now); @@ -477,14 +492,32 @@ void ExtensionUpdater::CheckNow() { prefs_->GetString(kExtensionBlacklistUpdateVersion))); } + int no_url_count = 0; + int google_url_count = 0; + int other_url_count = 0; + int theme_count = 0; + const ExtensionList* extensions = service_->extensions(); for (ExtensionList::const_iterator iter = extensions->begin(); iter != extensions->end(); ++iter) { Extension* extension = (*iter); const GURL& update_url = extension->update_url(); - if (update_url.is_empty() || extension->id().empty()) { + const std::string google_suffix = ".google.com"; + size_t suffix_index = update_url.host().length() - google_suffix.length(); + if (update_url.host().find(google_suffix) == suffix_index) { + google_url_count++; + } else if (update_url.is_empty() || extension->id().empty()) { + // TODO(asargent) when a default URL is added, make sure to update + // the total histogram below. Also, make sure to skip extensions that + // are "converted_from_user_script". + if (!extension->converted_from_user_script()) + no_url_count++; continue; + } else { + other_url_count++; } + if (extension->IsTheme()) + theme_count++; DCHECK(update_url.is_valid()); DCHECK(!update_url.has_ref()); @@ -509,6 +542,17 @@ void ExtensionUpdater::CheckNow() { // scheduled, so we don't need to check before calling it. StartUpdateCheck(*iter); } + + UMA_HISTOGRAM_COUNTS_100("Extensions.UpdateCheckExtensions", + google_url_count + other_url_count - theme_count); + UMA_HISTOGRAM_COUNTS_100("Extensions.UpdateCheckTheme", + theme_count); + UMA_HISTOGRAM_COUNTS_100("Extensions.UpdateCheckGoogleUrl", + google_url_count); + UMA_HISTOGRAM_COUNTS_100("Extensions.UpdateCheckOtherUrl", + other_url_count); + UMA_HISTOGRAM_COUNTS_100("Extensions.UpdateCheckNoUrl", + no_url_count); } diff --git a/chrome/browser/extensions/extensions_service.cc b/chrome/browser/extensions/extensions_service.cc index dcca59e..accb9cb 100644 --- a/chrome/browser/extensions/extensions_service.cc +++ b/chrome/browser/extensions/extensions_service.cc @@ -6,7 +6,9 @@ #include "base/command_line.h" #include "base/file_util.h" +#include "base/histogram.h" #include "base/string_util.h" +#include "base/time.h" #include "base/values.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/chrome_thread.h" @@ -265,12 +267,55 @@ void ExtensionsService::LoadExtension(const FilePath& extension_path) { } void ExtensionsService::LoadAllExtensions() { + base::TimeTicks start_time = base::TimeTicks::Now(); + // Load the previously installed extensions. scoped_ptr<InstalledExtensions> installed( new InstalledExtensions(extension_prefs_.get())); installed->VisitInstalledExtensions( NewCallback(this, &ExtensionsService::LoadInstalledExtension)); OnLoadedInstalledExtensions(); + + UMA_HISTOGRAM_COUNTS_100("Extensions.LoadAll", extensions_.size()); + UMA_HISTOGRAM_COUNTS_100("Extensions.Disabled", disabled_extensions_.size()); + + if (extensions_.size()) { + UMA_HISTOGRAM_TIMES("Extensions.LoadAllTime", + base::TimeTicks::Now() - start_time); + + int user_script_count = 0; + int extension_count = 0; + int theme_count = 0; + int external_count = 0; + int page_action_count = 0; + int browser_action_count = 0; + ExtensionList::iterator ex; + for (ex = extensions_.begin(); ex != extensions_.end(); ++ex) { + if ((*ex)->IsTheme()) { + theme_count++; + } else if ((*ex)->converted_from_user_script()) { + user_script_count++; + } else { + extension_count++; + } + if (Extension::IsExternalLocation((*ex)->location())) { + external_count++; + } + if ((*ex)->page_action() != NULL) { + page_action_count++; + } + if ((*ex)->browser_action() != NULL) { + browser_action_count++; + } + } + UMA_HISTOGRAM_COUNTS_100("Extensions.LoadExtension", extension_count); + UMA_HISTOGRAM_COUNTS_100("Extensions.LoadUserScript", user_script_count); + UMA_HISTOGRAM_COUNTS_100("Extensions.LoadTheme", theme_count); + UMA_HISTOGRAM_COUNTS_100("Extensions.LoadExternal", external_count); + UMA_HISTOGRAM_COUNTS_100("Extensions.LoadPageAction", page_action_count); + UMA_HISTOGRAM_COUNTS_100("Extensions.LoadBrowserAction", + browser_action_count); + } } void ExtensionsService::LoadInstalledExtension( diff --git a/chrome/renderer/user_script_slave.cc b/chrome/renderer/user_script_slave.cc index 473cda8..9fff626 100644 --- a/chrome/renderer/user_script_slave.cc +++ b/chrome/renderer/user_script_slave.cc @@ -140,9 +140,11 @@ bool UserScriptSlave::InjectScripts(WebFrame* frame, if (location == UserScript::DOCUMENT_START) { num_css += script->css_scripts().size(); for (size_t j = 0; j < script->css_scripts().size(); ++j) { + PerfTimer insert_timer; UserScript::File& file = script->css_scripts()[j]; frame->insertStyleText( WebString::fromUTF8(file.GetContent().as_string()), WebString()); + UMA_HISTOGRAM_TIMES("Extensions.InjectCssTime", insert_timer.Elapsed()); } } if (script->run_location() == location) { @@ -179,9 +181,11 @@ bool UserScriptSlave::InjectScripts(WebFrame* frame, isolated_world_id = GetIsolatedWorldId(script->extension_id()); } + PerfTimer exec_timer; frame->executeScriptInIsolatedWorld( isolated_world_id, &sources.front(), sources.size(), EXTENSION_GROUP_CONTENT_SCRIPTS); + UMA_HISTOGRAM_TIMES("Extensions.InjectScriptTime", exec_timer.Elapsed()); } } @@ -189,10 +193,18 @@ bool UserScriptSlave::InjectScripts(WebFrame* frame, if (location == UserScript::DOCUMENT_START) { UMA_HISTOGRAM_COUNTS_100("Extensions.InjectStart_CssCount", num_css); UMA_HISTOGRAM_COUNTS_100("Extensions.InjectStart_ScriptCount", num_scripts); - UMA_HISTOGRAM_TIMES("Extensions.InjectStart_Time", timer.Elapsed()); - } else { + if (num_css || num_scripts) + UMA_HISTOGRAM_TIMES("Extensions.InjectStart_Time", timer.Elapsed()); + } else if (location == UserScript::DOCUMENT_END) { UMA_HISTOGRAM_COUNTS_100("Extensions.InjectEnd_ScriptCount", num_scripts); - UMA_HISTOGRAM_TIMES("Extensions.InjectEnd_Time", timer.Elapsed()); + if (num_scripts) + UMA_HISTOGRAM_TIMES("Extensions.InjectEnd_Time", timer.Elapsed()); + } else if (location == UserScript::DOCUMENT_IDLE) { + UMA_HISTOGRAM_COUNTS_100("Extensions.InjectIdle_ScriptCount", num_scripts); + if (num_scripts) + UMA_HISTOGRAM_TIMES("Extensions.InjectIdle_Time", timer.Elapsed()); + } else { + NOTREACHED(); } LOG(INFO) << "Injected " << num_scripts << " scripts and " << num_css << |