| OLD | NEW |
| 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 "chrome/browser/autocomplete/autocomplete_classifier.h" | 16 #include "chrome/browser/autocomplete/autocomplete_classifier.h" |
| 18 #include "chrome/browser/autofill/personal_data_manager.h" | 17 #include "chrome/browser/autofill/personal_data_manager.h" |
| 19 #include "chrome/browser/background/background_contents_service_factory.h" | 18 #include "chrome/browser/background/background_contents_service_factory.h" |
| 20 #include "chrome/browser/background/background_mode_manager.h" | 19 #include "chrome/browser/background/background_mode_manager.h" |
| 21 #include "chrome/browser/bookmarks/bookmark_model.h" | 20 #include "chrome/browser/bookmarks/bookmark_model.h" |
| 22 #include "chrome/browser/browser_process.h" | 21 #include "chrome/browser/browser_process.h" |
| 23 #include "chrome/browser/browsing_data_remover.h" | 22 #include "chrome/browser/browsing_data_remover.h" |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 } | 209 } |
| 211 | 210 |
| 212 FilePath GetCachePath(const FilePath& base) { | 211 FilePath GetCachePath(const FilePath& base) { |
| 213 return base.Append(chrome::kCacheDirname); | 212 return base.Append(chrome::kCacheDirname); |
| 214 } | 213 } |
| 215 | 214 |
| 216 FilePath GetMediaCachePath(const FilePath& base) { | 215 FilePath GetMediaCachePath(const FilePath& base) { |
| 217 return base.Append(chrome::kMediaCacheDirname); | 216 return base.Append(chrome::kMediaCacheDirname); |
| 218 } | 217 } |
| 219 | 218 |
| 220 // Simple task to log the size of the current profile. | |
| 221 class ProfileSizeTask : public Task { | |
| 222 public: | |
| 223 explicit ProfileSizeTask(const FilePath& path) : path_(path) {} | |
| 224 virtual ~ProfileSizeTask() {} | |
| 225 | |
| 226 virtual void Run(); | |
| 227 private: | |
| 228 FilePath path_; | |
| 229 }; | |
| 230 | |
| 231 void ProfileSizeTask::Run() { | |
| 232 int64 size = file_util::ComputeFilesSize(path_, FILE_PATH_LITERAL("*")); | |
| 233 int size_MB = static_cast<int>(size / (1024 * 1024)); | |
| 234 UMA_HISTOGRAM_COUNTS_10000("Profile.TotalSize", size_MB); | |
| 235 | |
| 236 size = file_util::ComputeFilesSize(path_, FILE_PATH_LITERAL("History")); | |
| 237 size_MB = static_cast<int>(size / (1024 * 1024)); | |
| 238 UMA_HISTOGRAM_COUNTS_10000("Profile.HistorySize", size_MB); | |
| 239 | |
| 240 size = file_util::ComputeFilesSize(path_, FILE_PATH_LITERAL("History*")); | |
| 241 size_MB = static_cast<int>(size / (1024 * 1024)); | |
| 242 UMA_HISTOGRAM_COUNTS_10000("Profile.TotalHistorySize", size_MB); | |
| 243 | |
| 244 size = file_util::ComputeFilesSize(path_, FILE_PATH_LITERAL("Cookies")); | |
| 245 size_MB = static_cast<int>(size / (1024 * 1024)); | |
| 246 UMA_HISTOGRAM_COUNTS_10000("Profile.CookiesSize", size_MB); | |
| 247 | |
| 248 size = file_util::ComputeFilesSize(path_, FILE_PATH_LITERAL("Bookmarks")); | |
| 249 size_MB = static_cast<int>(size / (1024 * 1024)); | |
| 250 UMA_HISTOGRAM_COUNTS_10000("Profile.BookmarksSize", size_MB); | |
| 251 | |
| 252 size = file_util::ComputeFilesSize(path_, FILE_PATH_LITERAL("Favicons")); | |
| 253 size_MB = static_cast<int>(size / (1024 * 1024)); | |
| 254 UMA_HISTOGRAM_COUNTS_10000("Profile.FaviconsSize", size_MB); | |
| 255 | |
| 256 size = file_util::ComputeFilesSize(path_, FILE_PATH_LITERAL("Top Sites")); | |
| 257 size_MB = static_cast<int>(size / (1024 * 1024)); | |
| 258 UMA_HISTOGRAM_COUNTS_10000("Profile.TopSitesSize", size_MB); | |
| 259 | |
| 260 size = file_util::ComputeFilesSize(path_, FILE_PATH_LITERAL("Visited Links")); | |
| 261 size_MB = static_cast<int>(size / (1024 * 1024)); | |
| 262 UMA_HISTOGRAM_COUNTS_10000("Profile.VisitedLinksSize", size_MB); | |
| 263 | |
| 264 size = file_util::ComputeFilesSize(path_, FILE_PATH_LITERAL("Web Data")); | |
| 265 size_MB = static_cast<int>(size / (1024 * 1024)); | |
| 266 UMA_HISTOGRAM_COUNTS_10000("Profile.WebDataSize", size_MB); | |
| 267 | |
| 268 size = file_util::ComputeFilesSize(path_, FILE_PATH_LITERAL("Extension*")); | |
| 269 size_MB = static_cast<int>(size / (1024 * 1024)); | |
| 270 UMA_HISTOGRAM_COUNTS_10000("Profile.ExtensionSize", size_MB); | |
| 271 } | |
| 272 | |
| 273 } // namespace | 219 } // namespace |
| 274 | 220 |
| 275 // static | 221 // static |
| 276 Profile* Profile::CreateProfile(const FilePath& path) { | 222 Profile* Profile::CreateProfile(const FilePath& path) { |
| 277 if (!file_util::PathExists(path)) { | 223 if (!file_util::PathExists(path)) { |
| 278 // TODO(tc): http://b/1094718 Bad things happen if we can't write to the | 224 // TODO(tc): http://b/1094718 Bad things happen if we can't write to the |
| 279 // profile directory. We should eventually be able to run in this | 225 // profile directory. We should eventually be able to run in this |
| 280 // situation. | 226 // situation. |
| 281 if (!file_util::CreateDirectory(path)) | 227 if (!file_util::CreateDirectory(path)) |
| 282 return NULL; | 228 return NULL; |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 428 | 374 |
| 429 clear_local_state_on_exit_ = prefs->GetBoolean(prefs::kClearSiteDataOnExit); | 375 clear_local_state_on_exit_ = prefs->GetBoolean(prefs::kClearSiteDataOnExit); |
| 430 if (clear_local_state_on_exit_) { | 376 if (clear_local_state_on_exit_) { |
| 431 UserMetrics::RecordAction( | 377 UserMetrics::RecordAction( |
| 432 UserMetricsAction("ClearSiteDataOnExitEnabled")); | 378 UserMetricsAction("ClearSiteDataOnExitEnabled")); |
| 433 } else { | 379 } else { |
| 434 UserMetrics::RecordAction( | 380 UserMetrics::RecordAction( |
| 435 UserMetricsAction("ClearSiteDataOnExitDisabled")); | 381 UserMetricsAction("ClearSiteDataOnExitDisabled")); |
| 436 } | 382 } |
| 437 | 383 |
| 438 // Log the profile size after a reasonable startup delay. | |
| 439 BrowserThread::PostDelayedTask(BrowserThread::FILE, FROM_HERE, | |
| 440 new ProfileSizeTask(path_), 112000); | |
| 441 | |
| 442 InstantController::RecordMetrics(this); | 384 InstantController::RecordMetrics(this); |
| 443 | 385 |
| 444 // Instantiates Metrics object for spellchecking for use. | 386 // Instantiates Metrics object for spellchecking for use. |
| 445 if (g_browser_process->metrics_service() && | 387 if (g_browser_process->metrics_service() && |
| 446 g_browser_process->metrics_service()->recording_active()) | 388 g_browser_process->metrics_service()->recording_active()) |
| 447 GetSpellCheckProfile()->StartRecordingMetrics( | 389 GetSpellCheckProfile()->StartRecordingMetrics( |
| 448 GetPrefs()->GetBoolean(prefs::kEnableSpellCheck)); | 390 GetPrefs()->GetBoolean(prefs::kEnableSpellCheck)); |
| 449 | 391 |
| 450 speech_input::ChromeSpeechInputManager::GetInstance()->set_censor_results( | 392 speech_input::ChromeSpeechInputManager::GetInstance()->set_censor_results( |
| 451 prefs->GetBoolean(prefs::kSpeechInputCensorResults)); | 393 prefs->GetBoolean(prefs::kSpeechInputCensorResults)); |
| (...skipping 1312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1764 SpellCheckProfile* ProfileImpl::GetSpellCheckProfile() { | 1706 SpellCheckProfile* ProfileImpl::GetSpellCheckProfile() { |
| 1765 if (!spellcheck_profile_.get()) | 1707 if (!spellcheck_profile_.get()) |
| 1766 spellcheck_profile_.reset(new SpellCheckProfile()); | 1708 spellcheck_profile_.reset(new SpellCheckProfile()); |
| 1767 return spellcheck_profile_.get(); | 1709 return spellcheck_profile_.get(); |
| 1768 } | 1710 } |
| 1769 | 1711 |
| 1770 void ProfileImpl::SetDownloadManagerDelegate( | 1712 void ProfileImpl::SetDownloadManagerDelegate( |
| 1771 ChromeDownloadManagerDelegate* delegate) { | 1713 ChromeDownloadManagerDelegate* delegate) { |
| 1772 download_manager_delegate_ = delegate; | 1714 download_manager_delegate_ = delegate; |
| 1773 } | 1715 } |
| OLD | NEW |