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

Side by Side Diff: chrome/browser/profiles/profile_impl.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: Uploading merges after sync 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 "chrome/browser/profiles/profile_impl.h" 5 #include "chrome/browser/profiles/profile_impl.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/environment.h" 9 #include "base/environment.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/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
13 #include "base/metrics/histogram.h"
14 #include "base/path_service.h" 13 #include "base/path_service.h"
15 #include "base/string_number_conversions.h" 14 #include "base/string_number_conversions.h"
16 #include "base/string_util.h" 15 #include "base/string_util.h"
17 #include "base/utf_string_conversions.h" 16 #include "base/utf_string_conversions.h"
18 #include "chrome/browser/autocomplete/autocomplete_classifier.h" 17 #include "chrome/browser/autocomplete/autocomplete_classifier.h"
19 #include "chrome/browser/autofill/personal_data_manager.h" 18 #include "chrome/browser/autofill/personal_data_manager.h"
20 #include "chrome/browser/background/background_contents_service_factory.h" 19 #include "chrome/browser/background/background_contents_service_factory.h"
21 #include "chrome/browser/background/background_mode_manager.h" 20 #include "chrome/browser/background/background_mode_manager.h"
22 #include "chrome/browser/bookmarks/bookmark_model.h" 21 #include "chrome/browser/bookmarks/bookmark_model.h"
23 #include "chrome/browser/browser_process.h" 22 #include "chrome/browser/browser_process.h"
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 } 212 }
214 213
215 FilePath GetCachePath(const FilePath& base) { 214 FilePath GetCachePath(const FilePath& base) {
216 return base.Append(chrome::kCacheDirname); 215 return base.Append(chrome::kCacheDirname);
217 } 216 }
218 217
219 FilePath GetMediaCachePath(const FilePath& base) { 218 FilePath GetMediaCachePath(const FilePath& base) {
220 return base.Append(chrome::kMediaCacheDirname); 219 return base.Append(chrome::kMediaCacheDirname);
221 } 220 }
222 221
223 // Simple task to log the size of the current profile.
224 class ProfileSizeTask : public Task {
225 public:
226 explicit ProfileSizeTask(const FilePath& path) : path_(path) {}
227 virtual ~ProfileSizeTask() {}
228
229 virtual void Run();
230 private:
231 FilePath path_;
232 };
233
234 void ProfileSizeTask::Run() {
235 int64 size = file_util::ComputeFilesSize(path_, FILE_PATH_LITERAL("*"));
236 int size_MB = static_cast<int>(size / (1024 * 1024));
237 UMA_HISTOGRAM_COUNTS_10000("Profile.TotalSize", size_MB);
238
239 size = file_util::ComputeFilesSize(path_, FILE_PATH_LITERAL("History"));
240 size_MB = static_cast<int>(size / (1024 * 1024));
241 UMA_HISTOGRAM_COUNTS_10000("Profile.HistorySize", size_MB);
242
243 size = file_util::ComputeFilesSize(path_, FILE_PATH_LITERAL("History*"));
244 size_MB = static_cast<int>(size / (1024 * 1024));
245 UMA_HISTOGRAM_COUNTS_10000("Profile.TotalHistorySize", size_MB);
246
247 size = file_util::ComputeFilesSize(path_, FILE_PATH_LITERAL("Cookies"));
248 size_MB = static_cast<int>(size / (1024 * 1024));
249 UMA_HISTOGRAM_COUNTS_10000("Profile.CookiesSize", size_MB);
250
251 size = file_util::ComputeFilesSize(path_, FILE_PATH_LITERAL("Bookmarks"));
252 size_MB = static_cast<int>(size / (1024 * 1024));
253 UMA_HISTOGRAM_COUNTS_10000("Profile.BookmarksSize", size_MB);
254
255 size = file_util::ComputeFilesSize(path_, FILE_PATH_LITERAL("Favicons"));
256 size_MB = static_cast<int>(size / (1024 * 1024));
257 UMA_HISTOGRAM_COUNTS_10000("Profile.FaviconsSize", size_MB);
258
259 size = file_util::ComputeFilesSize(path_, FILE_PATH_LITERAL("Top Sites"));
260 size_MB = static_cast<int>(size / (1024 * 1024));
261 UMA_HISTOGRAM_COUNTS_10000("Profile.TopSitesSize", size_MB);
262
263 size = file_util::ComputeFilesSize(path_, FILE_PATH_LITERAL("Visited Links"));
264 size_MB = static_cast<int>(size / (1024 * 1024));
265 UMA_HISTOGRAM_COUNTS_10000("Profile.VisitedLinksSize", size_MB);
266
267 size = file_util::ComputeFilesSize(path_, FILE_PATH_LITERAL("Web Data"));
268 size_MB = static_cast<int>(size / (1024 * 1024));
269 UMA_HISTOGRAM_COUNTS_10000("Profile.WebDataSize", size_MB);
270
271 size = file_util::ComputeFilesSize(path_, FILE_PATH_LITERAL("Extension*"));
272 size_MB = static_cast<int>(size / (1024 * 1024));
273 UMA_HISTOGRAM_COUNTS_10000("Profile.ExtensionSize", size_MB);
274 }
275
276 } // namespace 222 } // namespace
277 223
278 // static 224 // static
279 Profile* Profile::CreateProfile(const FilePath& path) { 225 Profile* Profile::CreateProfile(const FilePath& path) {
280 if (!file_util::PathExists(path)) { 226 if (!file_util::PathExists(path)) {
281 // TODO(tc): http://b/1094718 Bad things happen if we can't write to the 227 // TODO(tc): http://b/1094718 Bad things happen if we can't write to the
282 // profile directory. We should eventually be able to run in this 228 // profile directory. We should eventually be able to run in this
283 // situation. 229 // situation.
284 if (!file_util::CreateDirectory(path)) 230 if (!file_util::CreateDirectory(path))
285 return NULL; 231 return NULL;
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
431 377
432 clear_local_state_on_exit_ = prefs->GetBoolean(prefs::kClearSiteDataOnExit); 378 clear_local_state_on_exit_ = prefs->GetBoolean(prefs::kClearSiteDataOnExit);
433 if (clear_local_state_on_exit_) { 379 if (clear_local_state_on_exit_) {
434 UserMetrics::RecordAction( 380 UserMetrics::RecordAction(
435 UserMetricsAction("ClearSiteDataOnExitEnabled")); 381 UserMetricsAction("ClearSiteDataOnExitEnabled"));
436 } else { 382 } else {
437 UserMetrics::RecordAction( 383 UserMetrics::RecordAction(
438 UserMetricsAction("ClearSiteDataOnExitDisabled")); 384 UserMetricsAction("ClearSiteDataOnExitDisabled"));
439 } 385 }
440 386
441 // Log the profile size after a reasonable startup delay.
442 BrowserThread::PostDelayedTask(BrowserThread::FILE, FROM_HERE,
443 new ProfileSizeTask(path_), 112000);
444
445 InstantController::RecordMetrics(this); 387 InstantController::RecordMetrics(this);
446 388
447 // Instantiates Metrics object for spellchecking for use. 389 // Instantiates Metrics object for spellchecking for use.
448 if (g_browser_process->metrics_service() && 390 if (g_browser_process->metrics_service() &&
449 g_browser_process->metrics_service()->recording_active()) 391 g_browser_process->metrics_service()->recording_active())
450 GetSpellCheckProfile()->StartRecordingMetrics( 392 GetSpellCheckProfile()->StartRecordingMetrics(
451 GetPrefs()->GetBoolean(prefs::kEnableSpellCheck)); 393 GetPrefs()->GetBoolean(prefs::kEnableSpellCheck));
452 394
453 FilePath cookie_path = GetPath(); 395 FilePath cookie_path = GetPath();
454 cookie_path = cookie_path.Append(chrome::kCookieFilename); 396 cookie_path = cookie_path.Append(chrome::kCookieFilename);
(...skipping 1325 matching lines...) Expand 10 before | Expand all | Expand 10 after
1780 SpellCheckProfile* ProfileImpl::GetSpellCheckProfile() { 1722 SpellCheckProfile* ProfileImpl::GetSpellCheckProfile() {
1781 if (!spellcheck_profile_.get()) 1723 if (!spellcheck_profile_.get())
1782 spellcheck_profile_.reset(new SpellCheckProfile()); 1724 spellcheck_profile_.reset(new SpellCheckProfile());
1783 return spellcheck_profile_.get(); 1725 return spellcheck_profile_.get();
1784 } 1726 }
1785 1727
1786 void ProfileImpl::SetDownloadManagerDelegate( 1728 void ProfileImpl::SetDownloadManagerDelegate(
1787 ChromeDownloadManagerDelegate* delegate) { 1729 ChromeDownloadManagerDelegate* delegate) {
1788 download_manager_delegate_ = delegate; 1730 download_manager_delegate_ = delegate;
1789 } 1731 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698