| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_manager.h" | 5 #include "chrome/browser/profiles/profile_manager.h" |
| 6 | 6 |
| 7 #include <stdint.h> |
| 8 |
| 7 #include <set> | 9 #include <set> |
| 8 | 10 |
| 9 #include "base/bind.h" | 11 #include "base/bind.h" |
| 10 #include "base/command_line.h" | 12 #include "base/command_line.h" |
| 11 #include "base/deferred_sequenced_task_runner.h" | 13 #include "base/deferred_sequenced_task_runner.h" |
| 12 #include "base/files/file_enumerator.h" | 14 #include "base/files/file_enumerator.h" |
| 13 #include "base/files/file_path.h" | 15 #include "base/files/file_path.h" |
| 14 #include "base/files/file_util.h" | 16 #include "base/files/file_util.h" |
| 15 #include "base/metrics/histogram_macros.h" | 17 #include "base/metrics/histogram_macros.h" |
| 16 #include "base/prefs/pref_service.h" | 18 #include "base/prefs/pref_service.h" |
| 17 #include "base/prefs/scoped_user_pref_update.h" | 19 #include "base/prefs/scoped_user_pref_update.h" |
| 18 #include "base/profiler/scoped_profile.h" | 20 #include "base/profiler/scoped_profile.h" |
| 19 #include "base/strings/string_number_conversions.h" | 21 #include "base/strings/string_number_conversions.h" |
| 20 #include "base/strings/string_util.h" | 22 #include "base/strings/string_util.h" |
| 21 #include "base/strings/utf_string_conversions.h" | 23 #include "base/strings/utf_string_conversions.h" |
| 22 #include "base/trace_event/trace_event.h" | 24 #include "base/trace_event/trace_event.h" |
| 25 #include "build/build_config.h" |
| 23 #include "chrome/browser/bookmarks/bookmark_model_factory.h" | 26 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
| 24 #include "chrome/browser/bookmarks/startup_task_runner_service_factory.h" | 27 #include "chrome/browser/bookmarks/startup_task_runner_service_factory.h" |
| 25 #include "chrome/browser/browser_process.h" | 28 #include "chrome/browser/browser_process.h" |
| 26 #include "chrome/browser/chrome_notification_types.h" | 29 #include "chrome/browser/chrome_notification_types.h" |
| 27 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" | 30 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" |
| 28 #include "chrome/browser/download/download_service.h" | 31 #include "chrome/browser/download/download_service.h" |
| 29 #include "chrome/browser/download/download_service_factory.h" | 32 #include "chrome/browser/download/download_service_factory.h" |
| 30 #include "chrome/browser/invalidation/profile_invalidation_provider_factory.h" | 33 #include "chrome/browser/invalidation/profile_invalidation_provider_factory.h" |
| 31 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings.h" | 34 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings.h" |
| 32 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings_fact
ory.h" | 35 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings_fact
ory.h" |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 using content::BrowserThread; | 125 using content::BrowserThread; |
| 123 | 126 |
| 124 namespace { | 127 namespace { |
| 125 | 128 |
| 126 // Profiles that should be deleted on shutdown. | 129 // Profiles that should be deleted on shutdown. |
| 127 std::vector<base::FilePath>& ProfilesToDelete() { | 130 std::vector<base::FilePath>& ProfilesToDelete() { |
| 128 CR_DEFINE_STATIC_LOCAL(std::vector<base::FilePath>, profiles_to_delete, ()); | 131 CR_DEFINE_STATIC_LOCAL(std::vector<base::FilePath>, profiles_to_delete, ()); |
| 129 return profiles_to_delete; | 132 return profiles_to_delete; |
| 130 } | 133 } |
| 131 | 134 |
| 132 int64 ComputeFilesSize(const base::FilePath& directory, | 135 int64_t ComputeFilesSize(const base::FilePath& directory, |
| 133 const base::FilePath::StringType& pattern) { | 136 const base::FilePath::StringType& pattern) { |
| 134 int64 running_size = 0; | 137 int64_t running_size = 0; |
| 135 base::FileEnumerator iter(directory, false, base::FileEnumerator::FILES, | 138 base::FileEnumerator iter(directory, false, base::FileEnumerator::FILES, |
| 136 pattern); | 139 pattern); |
| 137 while (!iter.Next().empty()) | 140 while (!iter.Next().empty()) |
| 138 running_size += iter.GetInfo().GetSize(); | 141 running_size += iter.GetInfo().GetSize(); |
| 139 return running_size; | 142 return running_size; |
| 140 } | 143 } |
| 141 | 144 |
| 142 // Simple task to log the size of the current profile. | 145 // Simple task to log the size of the current profile. |
| 143 void ProfileSizeTask(const base::FilePath& path, int enabled_app_count) { | 146 void ProfileSizeTask(const base::FilePath& path, int enabled_app_count) { |
| 144 DCHECK_CURRENTLY_ON(BrowserThread::FILE); | 147 DCHECK_CURRENTLY_ON(BrowserThread::FILE); |
| 145 const int64 kBytesInOneMB = 1024 * 1024; | 148 const int64_t kBytesInOneMB = 1024 * 1024; |
| 146 | 149 |
| 147 int64 size = ComputeFilesSize(path, FILE_PATH_LITERAL("*")); | 150 int64_t size = ComputeFilesSize(path, FILE_PATH_LITERAL("*")); |
| 148 int size_MB = static_cast<int>(size / kBytesInOneMB); | 151 int size_MB = static_cast<int>(size / kBytesInOneMB); |
| 149 UMA_HISTOGRAM_COUNTS_10000("Profile.TotalSize", size_MB); | 152 UMA_HISTOGRAM_COUNTS_10000("Profile.TotalSize", size_MB); |
| 150 | 153 |
| 151 size = ComputeFilesSize(path, FILE_PATH_LITERAL("History")); | 154 size = ComputeFilesSize(path, FILE_PATH_LITERAL("History")); |
| 152 size_MB = static_cast<int>(size / kBytesInOneMB); | 155 size_MB = static_cast<int>(size / kBytesInOneMB); |
| 153 UMA_HISTOGRAM_COUNTS_10000("Profile.HistorySize", size_MB); | 156 UMA_HISTOGRAM_COUNTS_10000("Profile.HistorySize", size_MB); |
| 154 | 157 |
| 155 size = ComputeFilesSize(path, FILE_PATH_LITERAL("History*")); | 158 size = ComputeFilesSize(path, FILE_PATH_LITERAL("History*")); |
| 156 size_MB = static_cast<int>(size / kBytesInOneMB); | 159 size_MB = static_cast<int>(size / kBytesInOneMB); |
| 157 UMA_HISTOGRAM_COUNTS_10000("Profile.TotalHistorySize", size_MB); | 160 UMA_HISTOGRAM_COUNTS_10000("Profile.TotalHistorySize", size_MB); |
| (...skipping 1355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1513 | 1516 |
| 1514 FinishDeletingProfile(profile_to_delete_path, new_active_profile_path); | 1517 FinishDeletingProfile(profile_to_delete_path, new_active_profile_path); |
| 1515 if (!original_callback.is_null()) | 1518 if (!original_callback.is_null()) |
| 1516 original_callback.Run(loaded_profile, status); | 1519 original_callback.Run(loaded_profile, status); |
| 1517 } | 1520 } |
| 1518 #endif // !defined(OS_ANDROID) && !defined(OS_IOS) | 1521 #endif // !defined(OS_ANDROID) && !defined(OS_IOS) |
| 1519 | 1522 |
| 1520 ProfileManagerWithoutInit::ProfileManagerWithoutInit( | 1523 ProfileManagerWithoutInit::ProfileManagerWithoutInit( |
| 1521 const base::FilePath& user_data_dir) : ProfileManager(user_data_dir) { | 1524 const base::FilePath& user_data_dir) : ProfileManager(user_data_dir) { |
| 1522 } | 1525 } |
| OLD | NEW |