diff options
author | rogerta@chromium.org <rogerta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-13 03:47:18 +0000 |
---|---|---|
committer | rogerta@chromium.org <rogerta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-13 03:47:18 +0000 |
commit | 49098f7091448e437190f23cc67a705df4abd079 (patch) | |
tree | 948238a61382ad33d98e4eccaaad256b98add8e5 /chrome | |
parent | 9bbc8241cae7b253ce22864fbe0f925f31a58eee (diff) | |
download | chromium_src-49098f7091448e437190f23cc67a705df4abd079.zip chromium_src-49098f7091448e437190f23cc67a705df4abd079.tar.gz chromium_src-49098f7091448e437190f23cc67a705df4abd079.tar.bz2 |
Add metrics to help measure effects of installing default apps in a profile
for the defaults field trial.
Evan: please review the webui changes.
Antony: plase review the extension changes.
Miranda: please review the profile changes.
Scott: please review the browser.cc
BUG=94920
TEST=No user visible change. New metrics should be available in UMA.
Review URL: http://codereview.chromium.org/8086002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@105253 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/extensions/crx_installer.cc | 14 | ||||
-rw-r--r-- | chrome/browser/extensions/extension_service.cc | 14 | ||||
-rw-r--r-- | chrome/browser/profiles/profile_impl.cc | 58 | ||||
-rw-r--r-- | chrome/browser/profiles/profile_manager.cc | 89 | ||||
-rw-r--r-- | chrome/browser/ui/browser.cc | 13 | ||||
-rw-r--r-- | chrome/browser/ui/webui/ntp/new_tab_page_handler.cc | 54 | ||||
-rw-r--r-- | chrome/browser/ui/webui/ntp/new_tab_page_handler.h | 11 |
7 files changed, 175 insertions, 78 deletions
diff --git a/chrome/browser/extensions/crx_installer.cc b/chrome/browser/extensions/crx_installer.cc index db0a1c0..9eced99 100644 --- a/chrome/browser/extensions/crx_installer.cc +++ b/chrome/browser/extensions/crx_installer.cc @@ -9,6 +9,7 @@ #include "base/file_util.h" #include "base/lazy_instance.h" +#include "base/metrics/field_trial.h" #include "base/metrics/histogram.h" #include "base/path_service.h" #include "base/scoped_temp_dir.h" @@ -22,6 +23,7 @@ #include "chrome/browser/browser_process.h" #include "chrome/browser/extensions/convert_user_script.h" #include "chrome/browser/extensions/convert_web_app.h" +#include "chrome/browser/extensions/default_apps_trial.h" #include "chrome/browser/extensions/extension_error_reporter.h" #include "chrome/browser/extensions/extension_service.h" #include "chrome/browser/shell_integration.h" @@ -542,8 +544,16 @@ void CrxInstaller::ReportSuccessFromFileThread() { // Tracking number of extensions installed by users if (install_cause() == extension_misc::INSTALL_CAUSE_USER_DOWNLOAD) { - UserMetrics::RecordAction( - UserMetricsAction("Extensions.ExtensionInstalled")); + UMA_HISTOGRAM_ENUMERATION("Extensions.ExtensionInstalled", 1, 2); + + static bool default_apps_trial_exists = + base::FieldTrialList::TrialExists(kDefaultAppsTrial_Name); + if (default_apps_trial_exists) { + UMA_HISTOGRAM_ENUMERATION( + base::FieldTrial::MakeName("Extensions.ExtensionInstalled", + kDefaultAppsTrial_Name), + 1, 2); + } } if (!BrowserThread::PostTask( diff --git a/chrome/browser/extensions/extension_service.cc b/chrome/browser/extensions/extension_service.cc index 8fcddd3..6fe755b 100644 --- a/chrome/browser/extensions/extension_service.cc +++ b/chrome/browser/extensions/extension_service.cc @@ -13,6 +13,7 @@ #include "base/file_util.h" #include "base/json/json_value_serializer.h" #include "base/logging.h" +#include "base/metrics/field_trial.h" #include "base/metrics/histogram.h" #include "base/path_service.h" #include "base/stl_util.h" @@ -30,6 +31,7 @@ #include "chrome/browser/extensions/app_notification_manager.h" #include "chrome/browser/extensions/apps_promo.h" #include "chrome/browser/extensions/crx_installer.h" +#include "chrome/browser/extensions/default_apps_trial.h" #include "chrome/browser/extensions/extension_accessibility_api.h" #include "chrome/browser/extensions/extension_bookmarks_module.h" #include "chrome/browser/extensions/extension_browser_event_router.h" @@ -970,8 +972,16 @@ bool ExtensionService::UninstallExtension( } // Track the uninstallation. - UserMetrics::RecordAction( - UserMetricsAction("Extensions.ExtensionUninstalled")); + UMA_HISTOGRAM_ENUMERATION("Extensions.ExtensionUninstalled", 1, 2); + + static bool default_apps_trial_exists = + base::FieldTrialList::TrialExists(kDefaultAppsTrial_Name); + if (default_apps_trial_exists) { + UMA_HISTOGRAM_ENUMERATION( + base::FieldTrial::MakeName("Extensions.ExtensionUninstalled", + kDefaultAppsTrial_Name), + 1, 2); + } // Uninstalling one extension might have solved the problems of others. // Therefore, we clear warnings of this type for all extensions. diff --git a/chrome/browser/profiles/profile_impl.cc b/chrome/browser/profiles/profile_impl.cc index a7afe78..956fc0c 100644 --- a/chrome/browser/profiles/profile_impl.cc +++ b/chrome/browser/profiles/profile_impl.cc @@ -10,7 +10,6 @@ #include "base/file_path.h" #include "base/file_util.h" #include "base/memory/scoped_ptr.h" -#include "base/metrics/histogram.h" #include "base/path_service.h" #include "base/string_number_conversions.h" #include "base/string_util.h" @@ -219,59 +218,6 @@ FilePath GetMediaCachePath(const FilePath& base) { return base.Append(chrome::kMediaCacheDirname); } -// Simple task to log the size of the current profile. -class ProfileSizeTask : public Task { - public: - explicit ProfileSizeTask(const FilePath& path) : path_(path) {} - virtual ~ProfileSizeTask() {} - - virtual void Run(); - private: - FilePath path_; -}; - -void ProfileSizeTask::Run() { - int64 size = file_util::ComputeFilesSize(path_, FILE_PATH_LITERAL("*")); - int size_MB = static_cast<int>(size / (1024 * 1024)); - UMA_HISTOGRAM_COUNTS_10000("Profile.TotalSize", size_MB); - - size = file_util::ComputeFilesSize(path_, FILE_PATH_LITERAL("History")); - size_MB = static_cast<int>(size / (1024 * 1024)); - UMA_HISTOGRAM_COUNTS_10000("Profile.HistorySize", size_MB); - - size = file_util::ComputeFilesSize(path_, FILE_PATH_LITERAL("History*")); - size_MB = static_cast<int>(size / (1024 * 1024)); - UMA_HISTOGRAM_COUNTS_10000("Profile.TotalHistorySize", size_MB); - - size = file_util::ComputeFilesSize(path_, FILE_PATH_LITERAL("Cookies")); - size_MB = static_cast<int>(size / (1024 * 1024)); - UMA_HISTOGRAM_COUNTS_10000("Profile.CookiesSize", size_MB); - - size = file_util::ComputeFilesSize(path_, FILE_PATH_LITERAL("Bookmarks")); - size_MB = static_cast<int>(size / (1024 * 1024)); - UMA_HISTOGRAM_COUNTS_10000("Profile.BookmarksSize", size_MB); - - size = file_util::ComputeFilesSize(path_, FILE_PATH_LITERAL("Favicons")); - size_MB = static_cast<int>(size / (1024 * 1024)); - UMA_HISTOGRAM_COUNTS_10000("Profile.FaviconsSize", size_MB); - - size = file_util::ComputeFilesSize(path_, FILE_PATH_LITERAL("Top Sites")); - size_MB = static_cast<int>(size / (1024 * 1024)); - UMA_HISTOGRAM_COUNTS_10000("Profile.TopSitesSize", size_MB); - - size = file_util::ComputeFilesSize(path_, FILE_PATH_LITERAL("Visited Links")); - size_MB = static_cast<int>(size / (1024 * 1024)); - UMA_HISTOGRAM_COUNTS_10000("Profile.VisitedLinksSize", size_MB); - - size = file_util::ComputeFilesSize(path_, FILE_PATH_LITERAL("Web Data")); - size_MB = static_cast<int>(size / (1024 * 1024)); - UMA_HISTOGRAM_COUNTS_10000("Profile.WebDataSize", size_MB); - - size = file_util::ComputeFilesSize(path_, FILE_PATH_LITERAL("Extension*")); - size_MB = static_cast<int>(size / (1024 * 1024)); - UMA_HISTOGRAM_COUNTS_10000("Profile.ExtensionSize", size_MB); -} - } // namespace // static @@ -436,10 +382,6 @@ void ProfileImpl::DoFinalInit() { UserMetricsAction("ClearSiteDataOnExitDisabled")); } - // Log the profile size after a reasonable startup delay. - BrowserThread::PostDelayedTask(BrowserThread::FILE, FROM_HERE, - new ProfileSizeTask(path_), 112000); - InstantController::RecordMetrics(this); // Instantiates Metrics object for spellchecking for use. diff --git a/chrome/browser/profiles/profile_manager.cc b/chrome/browser/profiles/profile_manager.cc index bf88997c..2dff47a 100644 --- a/chrome/browser/profiles/profile_manager.cc +++ b/chrome/browser/profiles/profile_manager.cc @@ -9,11 +9,15 @@ #include "base/command_line.h" #include "base/file_path.h" #include "base/file_util.h" +#include "base/metrics/field_trial.h" +#include "base/metrics/histogram.h" #include "base/stl_util.h" #include "base/string_number_conversions.h" #include "base/string_util.h" #include "base/utf_string_conversions.h" #include "chrome/browser/browser_process.h" +#include "chrome/browser/extensions/default_apps_trial.h" +#include "chrome/browser/extensions/extension_service.h" #include "chrome/browser/prefs/pref_service.h" #include "chrome/browser/prefs/scoped_user_pref_update.h" #include "chrome/browser/profiles/profile_info_cache.h" @@ -51,6 +55,87 @@ std::vector<FilePath>& ProfilesToDelete() { return profiles_to_delete; } +// Simple task to log the size of the current profile. +class ProfileSizeTask : public Task { + public: + explicit ProfileSizeTask(Profile* profile); + virtual ~ProfileSizeTask() {} + + virtual void Run(); + private: + FilePath path_; + int extension_count_; +}; + +ProfileSizeTask::ProfileSizeTask(Profile* profile) + : path_(profile->GetPath()), extension_count_(-1) { + // This object should not remember the profile pointer since it should not + // be accessed from IO thread. + + // Count number of extensions in this profile. + ExtensionService* extension_service = profile->GetExtensionService(); + if (extension_service) + extension_count_ = extension_service->GetAppIds().size(); +} + +void ProfileSizeTask::Run() { + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); + + int64 size = file_util::ComputeFilesSize(path_, FILE_PATH_LITERAL("*")); + int size_MB = static_cast<int>(size / (1024 * 1024)); + UMA_HISTOGRAM_COUNTS_10000("Profile.TotalSize", size_MB); + + size = file_util::ComputeFilesSize(path_, FILE_PATH_LITERAL("History")); + size_MB = static_cast<int>(size / (1024 * 1024)); + UMA_HISTOGRAM_COUNTS_10000("Profile.HistorySize", size_MB); + + size = file_util::ComputeFilesSize(path_, FILE_PATH_LITERAL("History*")); + size_MB = static_cast<int>(size / (1024 * 1024)); + UMA_HISTOGRAM_COUNTS_10000("Profile.TotalHistorySize", size_MB); + + size = file_util::ComputeFilesSize(path_, FILE_PATH_LITERAL("Cookies")); + size_MB = static_cast<int>(size / (1024 * 1024)); + UMA_HISTOGRAM_COUNTS_10000("Profile.CookiesSize", size_MB); + + size = file_util::ComputeFilesSize(path_, FILE_PATH_LITERAL("Bookmarks")); + size_MB = static_cast<int>(size / (1024 * 1024)); + UMA_HISTOGRAM_COUNTS_10000("Profile.BookmarksSize", size_MB); + + size = file_util::ComputeFilesSize(path_, FILE_PATH_LITERAL("Favicons")); + size_MB = static_cast<int>(size / (1024 * 1024)); + UMA_HISTOGRAM_COUNTS_10000("Profile.FaviconsSize", size_MB); + + size = file_util::ComputeFilesSize(path_, FILE_PATH_LITERAL("Top Sites")); + size_MB = static_cast<int>(size / (1024 * 1024)); + UMA_HISTOGRAM_COUNTS_10000("Profile.TopSitesSize", size_MB); + + size = file_util::ComputeFilesSize(path_, FILE_PATH_LITERAL("Visited Links")); + size_MB = static_cast<int>(size / (1024 * 1024)); + UMA_HISTOGRAM_COUNTS_10000("Profile.VisitedLinksSize", size_MB); + + size = file_util::ComputeFilesSize(path_, FILE_PATH_LITERAL("Web Data")); + size_MB = static_cast<int>(size / (1024 * 1024)); + UMA_HISTOGRAM_COUNTS_10000("Profile.WebDataSize", size_MB); + + size = file_util::ComputeFilesSize(path_, FILE_PATH_LITERAL("Extension*")); + size_MB = static_cast<int>(size / (1024 * 1024)); + UMA_HISTOGRAM_COUNTS_10000("Profile.ExtensionSize", size_MB); + + // Count number of extensions in this profile, if we know. + if (extension_count_ != -1) { + UMA_HISTOGRAM_COUNTS_10000("Profile.AppCount", extension_count_); + + static bool default_apps_trial_exists = base::FieldTrialList::TrialExists( + kDefaultAppsTrial_Name); + if (default_apps_trial_exists) { + UMA_HISTOGRAM_COUNTS_10000( + base::FieldTrial::MakeName("Profile.AppCount", + kDefaultAppsTrial_Name), + extension_count_); + } + } +} + void QueueProfileDirectoryForDeletion(const FilePath& path) { ProfilesToDelete().push_back(path); } @@ -383,6 +468,10 @@ void ProfileManager::DoFinalInit(Profile* profile, bool go_off_the_record) { if (!command_line.HasSwitch(switches::kDisableWebResources)) profile->InitPromoResources(); AddProfileToCache(profile); + + // Log the profile size after a reasonable startup delay. + BrowserThread::PostDelayedTask(BrowserThread::FILE, FROM_HERE, + new ProfileSizeTask(profile), 112000); } Profile* ProfileManager::CreateProfile(const FilePath& path) { diff --git a/chrome/browser/ui/browser.cc b/chrome/browser/ui/browser.cc index 0b10414..fec04b7 100644 --- a/chrome/browser/ui/browser.cc +++ b/chrome/browser/ui/browser.cc @@ -15,6 +15,7 @@ #include "base/base_paths.h" #include "base/command_line.h" #include "base/logging.h" +#include "base/metrics/field_trial.h" #include "base/metrics/histogram.h" #include "base/path_service.h" #include "base/string_number_conversions.h" @@ -43,6 +44,7 @@ #include "chrome/browser/download/download_service_factory.h" #include "chrome/browser/download/download_started_animation.h" #include "chrome/browser/extensions/crx_installer.h" +#include "chrome/browser/extensions/default_apps_trial.h" #include "chrome/browser/extensions/extension_browser_event_router.h" #include "chrome/browser/extensions/extension_disabled_infobar_delegate.h" #include "chrome/browser/extensions/extension_host.h" @@ -690,9 +692,14 @@ TabContents* Browser::OpenApplicationTab(Profile* profile, extension->id(), ExtensionPrefs::LAUNCH_DEFAULT); UMA_HISTOGRAM_ENUMERATION("Extensions.AppTabLaunchType", launch_type, 100); - // Track launches of the webstore specifically. - if (extension->id() == extension_misc::kWebStoreAppId) - UserMetrics::RecordAction(UserMetricsAction("Extensions.WebStoreLaunch")); + static bool default_apps_trial_exists = + base::FieldTrialList::TrialExists(kDefaultAppsTrial_Name); + if (default_apps_trial_exists) { + UMA_HISTOGRAM_ENUMERATION( + base::FieldTrial::MakeName("Extensions.AppTabLaunchType", + kDefaultAppsTrial_Name), + launch_type, 100); + } int add_type = TabStripModel::ADD_ACTIVE; if (launch_type == ExtensionPrefs::LAUNCH_PINNED) diff --git a/chrome/browser/ui/webui/ntp/new_tab_page_handler.cc b/chrome/browser/ui/webui/ntp/new_tab_page_handler.cc index 8906916..0a8b5aa 100644 --- a/chrome/browser/ui/webui/ntp/new_tab_page_handler.cc +++ b/chrome/browser/ui/webui/ntp/new_tab_page_handler.cc @@ -6,6 +6,9 @@ #include "base/bind.h" #include "base/bind_helpers.h" +#include "base/metrics/field_trial.h" +#include "base/metrics/histogram.h" +#include "chrome/browser/extensions/default_apps_trial.h" #include "chrome/browser/prefs/pref_service.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/sync/profile_sync_service.h" @@ -24,27 +27,47 @@ static const int kIntroDisplayMax = 10; static const char kNTP4IntroURL[] = "http://www.google.com/support/chrome/bin/answer.py?answer=95451"; +WebUIMessageHandler* NewTabPageHandler::Attach(WebUI* web_ui) { + // Record an open of the NTP with its default page type. + PrefService* prefs = Profile::FromWebUI(web_ui)->GetPrefs(); + int shown_page_type = prefs->GetInteger(prefs::kNTPShownPage) >> + kPageIdOffset; + UMA_HISTOGRAM_ENUMERATION("NewTabPage.DefaultPageType", + shown_page_type, 4); + + static bool default_apps_trial_exists = + base::FieldTrialList::TrialExists(kDefaultAppsTrial_Name); + if (default_apps_trial_exists) { + UMA_HISTOGRAM_ENUMERATION( + base::FieldTrial::MakeName("NewTabPage.DefaultPageType", + kDefaultAppsTrial_Name), + shown_page_type, 4); + } + + return WebUIMessageHandler::Attach(web_ui); +} + void NewTabPageHandler::RegisterMessages() { - web_ui_->RegisterMessageCallback("closeNotificationPromo", + web_ui()->RegisterMessageCallback("closeNotificationPromo", base::Bind(&NewTabPageHandler::HandleCloseNotificationPromo, base::Unretained(this))); - web_ui_->RegisterMessageCallback("notificationPromoViewed", + web_ui()->RegisterMessageCallback("notificationPromoViewed", base::Bind(&NewTabPageHandler::HandleNotificationPromoViewed, base::Unretained(this))); - web_ui_->RegisterMessageCallback("pageSelected", + web_ui()->RegisterMessageCallback("pageSelected", base::Bind(&NewTabPageHandler::HandlePageSelected, base::Unretained(this))); - web_ui_->RegisterMessageCallback("introMessageDismissed", + web_ui()->RegisterMessageCallback("introMessageDismissed", base::Bind(&NewTabPageHandler::HandleIntroMessageDismissed, base::Unretained(this))); - web_ui_->RegisterMessageCallback("introMessageSeen", + web_ui()->RegisterMessageCallback("introMessageSeen", base::Bind(&NewTabPageHandler::HandleIntroMessageSeen, base::Unretained(this))); } void NewTabPageHandler::HandleCloseNotificationPromo(const ListValue* args) { NotificationPromo notification_promo( - Profile::FromWebUI(web_ui_)->GetPrefs(), NULL); + Profile::FromWebUI(web_ui())->GetPrefs(), NULL); notification_promo.HandleClosed(); NotifyPromoResourceChanged(); } @@ -66,17 +89,30 @@ void NewTabPageHandler::HandlePageSelected(const ListValue* args) { CHECK(args->GetDouble(1, &index_double)); int index = static_cast<int>(index_double); - PrefService* prefs = Profile::FromWebUI(web_ui_)->GetPrefs(); + PrefService* prefs = Profile::FromWebUI(web_ui())->GetPrefs(); prefs->SetInteger(prefs::kNTPShownPage, page_id | index); + + int shown_page_type = page_id >> kPageIdOffset; + UMA_HISTOGRAM_ENUMERATION("NewTabPage.SelectedPageType", + shown_page_type, 4); + + static bool default_apps_trial_exists = + base::FieldTrialList::TrialExists(kDefaultAppsTrial_Name); + if (default_apps_trial_exists) { + UMA_HISTOGRAM_ENUMERATION( + base::FieldTrial::MakeName("NewTabPage.SelectedPageType", + kDefaultAppsTrial_Name), + shown_page_type, 4); + } } void NewTabPageHandler::HandleIntroMessageDismissed(const ListValue* args) { - PrefService* prefs = Profile::FromWebUI(web_ui_)->GetPrefs(); + PrefService* prefs = Profile::FromWebUI(web_ui())->GetPrefs(); prefs->SetInteger(prefs::kNTP4IntroDisplayCount, kIntroDisplayMax + 1); } void NewTabPageHandler::HandleIntroMessageSeen(const ListValue* args) { - PrefService* prefs = Profile::FromWebUI(web_ui_)->GetPrefs(); + PrefService* prefs = Profile::FromWebUI(web_ui())->GetPrefs(); int intro_displays = prefs->GetInteger(prefs::kNTP4IntroDisplayCount); prefs->SetInteger(prefs::kNTP4IntroDisplayCount, intro_displays + 1); } diff --git a/chrome/browser/ui/webui/ntp/new_tab_page_handler.h b/chrome/browser/ui/webui/ntp/new_tab_page_handler.h index 6f556ea..cd10dcf 100644 --- a/chrome/browser/ui/webui/ntp/new_tab_page_handler.h +++ b/chrome/browser/ui/webui/ntp/new_tab_page_handler.h @@ -19,6 +19,7 @@ class NewTabPageHandler : public WebUIMessageHandler { virtual ~NewTabPageHandler() {} // WebUIMessageHandler implementation. + virtual WebUIMessageHandler* Attach(WebUI* web_ui) OVERRIDE; virtual void RegisterMessages() OVERRIDE; // Callback for "closeNotificationPromo". @@ -52,11 +53,13 @@ class NewTabPageHandler : public WebUIMessageHandler { // The lower 10 bits of kNTPShownPage are used for the index within the page // group, and the rest of the bits are used for the page group ID (defined // here). + static const int kPageIdOffset = 10; enum { - INDEX_MASK = (1 << 10) - 1, - MOST_VISITED_PAGE_ID = 1 << 10, - APPS_PAGE_ID = 2 << 10, - BOOKMARKS_PAGE_ID = 3 << 10, + INDEX_MASK = (1 << kPageIdOffset) - 1, + MOST_VISITED_PAGE_ID = 1 << kPageIdOffset, + APPS_PAGE_ID = 2 << kPageIdOffset, + BOOKMARKS_PAGE_ID = 3 << kPageIdOffset, + LAST_PAGE_ID = BOOKMARKS_PAGE_ID }; // Helper to send out promo resource change notification. |