Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(133)

Side by Side Diff: chrome/browser/profiles/profile_manager.cc

Issue 8086002: Add metrics to help measure effects of installing default apps in a profile. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Remove DCHECK, since this does happen in unit test AvatarMenuModelTest.InitialCreation Created 9 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 <set> 5 #include <set>
6 6
7 #include "chrome/browser/profiles/profile_manager.h" 7 #include "chrome/browser/profiles/profile_manager.h"
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/file_path.h" 10 #include "base/file_path.h"
11 #include "base/file_util.h" 11 #include "base/file_util.h"
12 #include "base/metrics/field_trial.h"
13 #include "base/metrics/histogram.h"
12 #include "base/stl_util.h" 14 #include "base/stl_util.h"
13 #include "base/string_number_conversions.h" 15 #include "base/string_number_conversions.h"
14 #include "base/string_util.h" 16 #include "base/string_util.h"
15 #include "base/utf_string_conversions.h" 17 #include "base/utf_string_conversions.h"
16 #include "chrome/browser/browser_process.h" 18 #include "chrome/browser/browser_process.h"
19 #include "chrome/browser/extensions/default_apps_trial.h"
20 #include "chrome/browser/extensions/extension_service.h"
17 #include "chrome/browser/prefs/pref_service.h" 21 #include "chrome/browser/prefs/pref_service.h"
18 #include "chrome/browser/prefs/scoped_user_pref_update.h" 22 #include "chrome/browser/prefs/scoped_user_pref_update.h"
19 #include "chrome/browser/profiles/profile_info_cache.h" 23 #include "chrome/browser/profiles/profile_info_cache.h"
20 #include "chrome/browser/sessions/session_service_factory.h" 24 #include "chrome/browser/sessions/session_service_factory.h"
21 #include "chrome/browser/sync/profile_sync_service.h" 25 #include "chrome/browser/sync/profile_sync_service.h"
22 #include "chrome/browser/ui/browser_window.h" 26 #include "chrome/browser/ui/browser_window.h"
23 #include "chrome/common/chrome_notification_types.h" 27 #include "chrome/common/chrome_notification_types.h"
24 #include "chrome/common/chrome_constants.h" 28 #include "chrome/common/chrome_constants.h"
25 #include "chrome/common/chrome_switches.h" 29 #include "chrome/common/chrome_switches.h"
26 #include "chrome/common/logging_chrome.h" 30 #include "chrome/common/logging_chrome.h"
(...skipping 16 matching lines...) Expand all
43 namespace { 47 namespace {
44 48
45 void DeleteProfileDirectories(const std::vector<FilePath>& paths) { 49 void DeleteProfileDirectories(const std::vector<FilePath>& paths) {
46 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 50 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
47 for (std::vector<FilePath>::const_iterator it = paths.begin(); 51 for (std::vector<FilePath>::const_iterator it = paths.begin();
48 it != paths.end(); ++it) { 52 it != paths.end(); ++it) {
49 file_util::Delete(*it, true); 53 file_util::Delete(*it, true);
50 } 54 }
51 } 55 }
52 56
57 // Simple task to log the size of the current profile.
58 class ProfileSizeTask : public Task {
59 public:
60 explicit ProfileSizeTask(Profile* profile);
61 virtual ~ProfileSizeTask() {}
62
63 virtual void Run();
64 private:
65 FilePath path_;
66 int extension_count_;
67 };
68
69 ProfileSizeTask::ProfileSizeTask(Profile* profile)
70 : path_(profile->GetPath()), extension_count_(-1) {
71 // This object should not remember the profile pointer since it should not
72 // be accessed from IO thread.
73
74 // Count number of extensions in this profile.
75 ExtensionService* extension_service = profile->GetExtensionService();
76 if (extension_service)
77 extension_count_ = extension_service->GetAppIds().size();
78 }
79
80 void ProfileSizeTask::Run() {
81 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
82
83 int64 size = file_util::ComputeFilesSize(path_, FILE_PATH_LITERAL("*"));
84 int size_MB = static_cast<int>(size / (1024 * 1024));
85 UMA_HISTOGRAM_COUNTS_10000("Profile.TotalSize", size_MB);
86
87 size = file_util::ComputeFilesSize(path_, FILE_PATH_LITERAL("History"));
88 size_MB = static_cast<int>(size / (1024 * 1024));
89 UMA_HISTOGRAM_COUNTS_10000("Profile.HistorySize", size_MB);
90
91 size = file_util::ComputeFilesSize(path_, FILE_PATH_LITERAL("History*"));
92 size_MB = static_cast<int>(size / (1024 * 1024));
93 UMA_HISTOGRAM_COUNTS_10000("Profile.TotalHistorySize", size_MB);
94
95 size = file_util::ComputeFilesSize(path_, FILE_PATH_LITERAL("Cookies"));
96 size_MB = static_cast<int>(size / (1024 * 1024));
97 UMA_HISTOGRAM_COUNTS_10000("Profile.CookiesSize", size_MB);
98
99 size = file_util::ComputeFilesSize(path_, FILE_PATH_LITERAL("Bookmarks"));
100 size_MB = static_cast<int>(size / (1024 * 1024));
101 UMA_HISTOGRAM_COUNTS_10000("Profile.BookmarksSize", size_MB);
102
103 size = file_util::ComputeFilesSize(path_, FILE_PATH_LITERAL("Favicons"));
104 size_MB = static_cast<int>(size / (1024 * 1024));
105 UMA_HISTOGRAM_COUNTS_10000("Profile.FaviconsSize", size_MB);
106
107 size = file_util::ComputeFilesSize(path_, FILE_PATH_LITERAL("Top Sites"));
108 size_MB = static_cast<int>(size / (1024 * 1024));
109 UMA_HISTOGRAM_COUNTS_10000("Profile.TopSitesSize", size_MB);
110
111 size = file_util::ComputeFilesSize(path_, FILE_PATH_LITERAL("Visited Links"));
112 size_MB = static_cast<int>(size / (1024 * 1024));
113 UMA_HISTOGRAM_COUNTS_10000("Profile.VisitedLinksSize", size_MB);
114
115 size = file_util::ComputeFilesSize(path_, FILE_PATH_LITERAL("Web Data"));
116 size_MB = static_cast<int>(size / (1024 * 1024));
117 UMA_HISTOGRAM_COUNTS_10000("Profile.WebDataSize", size_MB);
118
119 size = file_util::ComputeFilesSize(path_, FILE_PATH_LITERAL("Extension*"));
120 size_MB = static_cast<int>(size / (1024 * 1024));
121 UMA_HISTOGRAM_COUNTS_10000("Profile.ExtensionSize", size_MB);
122
123 // Count number of extensions in this profile, if we know.
124 if (extension_count_ != -1) {
125 UMA_HISTOGRAM_COUNTS_10000("Profile.AppCount", extension_count_);
126
127 static bool default_apps_trial_exists = base::FieldTrialList::TrialExists(
128 kDefaultAppsTrial_Name);
129 if (default_apps_trial_exists) {
130 UMA_HISTOGRAM_COUNTS_10000(
131 base::FieldTrial::MakeName("Profile.AppCount",
132 kDefaultAppsTrial_Name),
133 extension_count_);
134 }
135 }
136 }
137
53 } // namespace 138 } // namespace
54 139
55 bool ProfileManagerObserver::DeleteAfter() { 140 bool ProfileManagerObserver::DeleteAfter() {
56 return false; 141 return false;
57 } 142 }
58 143
59 // The NewProfileLauncher class is created when to wait for a multi-profile 144 // The NewProfileLauncher class is created when to wait for a multi-profile
60 // to be created asynchronously. Upon completion of profile creation, the 145 // to be created asynchronously. Upon completion of profile creation, the
61 // NPL takes care of launching a new browser window and signing the user 146 // NPL takes care of launching a new browser window and signing the user
62 // in to their Google account. 147 // in to their Google account.
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 last_active->GetPath().BaseName().MaybeAsASCII()); 436 last_active->GetPath().BaseName().MaybeAsASCII());
352 } 437 }
353 } 438 }
354 439
355 void ProfileManager::DoFinalInit(Profile* profile, bool go_off_the_record) { 440 void ProfileManager::DoFinalInit(Profile* profile, bool go_off_the_record) {
356 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); 441 const CommandLine& command_line = *CommandLine::ForCurrentProcess();
357 profile->InitExtensions(!go_off_the_record); 442 profile->InitExtensions(!go_off_the_record);
358 if (!command_line.HasSwitch(switches::kDisableWebResources)) 443 if (!command_line.HasSwitch(switches::kDisableWebResources))
359 profile->InitPromoResources(); 444 profile->InitPromoResources();
360 AddProfileToCache(profile); 445 AddProfileToCache(profile);
446
447 // Log the profile size after a reasonable startup delay.
448 BrowserThread::PostDelayedTask(BrowserThread::FILE, FROM_HERE,
449 new ProfileSizeTask(profile), 112000);
361 } 450 }
362 451
363 Profile* ProfileManager::CreateProfile(const FilePath& path) { 452 Profile* ProfileManager::CreateProfile(const FilePath& path) {
364 return Profile::CreateProfile(path); 453 return Profile::CreateProfile(path);
365 } 454 }
366 455
367 void ProfileManager::OnProfileCreated(Profile* profile, bool success) { 456 void ProfileManager::OnProfileCreated(Profile* profile, bool success) {
368 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 457 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
369 458
370 ProfilesInfoMap::iterator iter = profiles_info_.find(profile->GetPath()); 459 ProfilesInfoMap::iterator iter = profiles_info_.find(profile->GetPath());
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
521 ProfileManagerWithoutInit::ProfileManagerWithoutInit( 610 ProfileManagerWithoutInit::ProfileManagerWithoutInit(
522 const FilePath& user_data_dir) : ProfileManager(user_data_dir) { 611 const FilePath& user_data_dir) : ProfileManager(user_data_dir) {
523 } 612 }
524 613
525 void ProfileManager::RegisterTestingProfile(Profile* profile, 614 void ProfileManager::RegisterTestingProfile(Profile* profile,
526 bool add_to_cache) { 615 bool add_to_cache) {
527 RegisterProfile(profile, true); 616 RegisterProfile(profile, true);
528 if (add_to_cache) 617 if (add_to_cache)
529 AddProfileToCache(profile); 618 AddProfileToCache(profile);
530 } 619 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698