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

Unified Diff: chrome/browser/profile.cc

Issue 2778006: Add histograms to track the size of the profile data.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 10 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/file_util_unittest.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/profile.cc
===================================================================
--- chrome/browser/profile.cc (revision 49439)
+++ chrome/browser/profile.cc (working copy)
@@ -179,6 +179,56 @@
#endif
return false;
}
+
+// 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("Thumbnails"));
+ size_MB = static_cast<int>(size / (1024 * 1024));
+ UMA_HISTOGRAM_COUNTS_10000("Profile.ThumbnailsSize", 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
// A pointer to the request context for the default profile. See comments on
@@ -262,11 +312,10 @@
}
virtual ~OffTheRecordProfileImpl() {
- NotificationService::current()->Notify(
- NotificationType::PROFILE_DESTROYED,
- Source<Profile>(this),
- NotificationService::NoDetails());
- CleanupRequestContext(request_context_);
+ NotificationService::current()->Notify(NotificationType::PROFILE_DESTROYED,
+ Source<Profile>(this),
+ NotificationService::NoDetails());
+ CleanupRequestContext(request_context_);
}
virtual ProfileId GetRuntimeId() {
@@ -749,6 +798,10 @@
#endif
pinned_tab_service_.reset(new PinnedTabService(this));
+
+ // Log the profile size after a reasonable startup delay.
+ ChromeThread::PostDelayedTask(ChromeThread::FILE, FROM_HERE,
+ new ProfileSizeTask(path_), 112000);
}
void ProfileImpl::InitExtensions() {
« no previous file with comments | « base/file_util_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698