| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/profile.h" | 5 #include "chrome/browser/profile.h" |
| 6 | 6 |
| 7 #include "app/resource_bundle.h" | 7 #include "app/resource_bundle.h" |
| 8 #include "app/theme_provider.h" | 8 #include "app/theme_provider.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/env_var.h" | 10 #include "base/env_var.h" |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 bool IncludeDefaultApps() { | 172 bool IncludeDefaultApps() { |
| 173 #if defined(OS_WIN) | 173 #if defined(OS_WIN) |
| 174 std::string user_domain; | 174 std::string user_domain; |
| 175 return base::EnvVarGetter::Create()->GetEnv("USERDOMAIN", &user_domain) && | 175 return base::EnvVarGetter::Create()->GetEnv("USERDOMAIN", &user_domain) && |
| 176 user_domain == "GOOGLE"; | 176 user_domain == "GOOGLE"; |
| 177 #elif defined(OS_CHROMEOS) && defined(GOOGLE_CHROME_BUILD) | 177 #elif defined(OS_CHROMEOS) && defined(GOOGLE_CHROME_BUILD) |
| 178 return true; | 178 return true; |
| 179 #endif | 179 #endif |
| 180 return false; | 180 return false; |
| 181 } | 181 } |
| 182 |
| 183 // Simple task to log the size of the current profile. |
| 184 class ProfileSizeTask : public Task { |
| 185 public: |
| 186 explicit ProfileSizeTask(const FilePath& path) : path_(path) {} |
| 187 virtual ~ProfileSizeTask() {} |
| 188 |
| 189 virtual void Run(); |
| 190 private: |
| 191 FilePath path_; |
| 192 }; |
| 193 |
| 194 void ProfileSizeTask::Run() { |
| 195 int64 size = file_util::ComputeFilesSize(path_, FILE_PATH_LITERAL("*")); |
| 196 int size_MB = static_cast<int>(size / (1024 * 1024)); |
| 197 UMA_HISTOGRAM_COUNTS_10000("Profile.TotalSize", size_MB); |
| 198 |
| 199 size = file_util::ComputeFilesSize(path_, FILE_PATH_LITERAL("History")); |
| 200 size_MB = static_cast<int>(size / (1024 * 1024)); |
| 201 UMA_HISTOGRAM_COUNTS_10000("Profile.HistorySize", size_MB); |
| 202 |
| 203 size = file_util::ComputeFilesSize(path_, FILE_PATH_LITERAL("History*")); |
| 204 size_MB = static_cast<int>(size / (1024 * 1024)); |
| 205 UMA_HISTOGRAM_COUNTS_10000("Profile.TotalHistorySize", size_MB); |
| 206 |
| 207 size = file_util::ComputeFilesSize(path_, FILE_PATH_LITERAL("Cookies")); |
| 208 size_MB = static_cast<int>(size / (1024 * 1024)); |
| 209 UMA_HISTOGRAM_COUNTS_10000("Profile.CookiesSize", size_MB); |
| 210 |
| 211 size = file_util::ComputeFilesSize(path_, FILE_PATH_LITERAL("Bookmarks")); |
| 212 size_MB = static_cast<int>(size / (1024 * 1024)); |
| 213 UMA_HISTOGRAM_COUNTS_10000("Profile.BookmarksSize", size_MB); |
| 214 |
| 215 size = file_util::ComputeFilesSize(path_, FILE_PATH_LITERAL("Thumbnails")); |
| 216 size_MB = static_cast<int>(size / (1024 * 1024)); |
| 217 UMA_HISTOGRAM_COUNTS_10000("Profile.ThumbnailsSize", size_MB); |
| 218 |
| 219 size = file_util::ComputeFilesSize(path_, FILE_PATH_LITERAL("Visited Links")); |
| 220 size_MB = static_cast<int>(size / (1024 * 1024)); |
| 221 UMA_HISTOGRAM_COUNTS_10000("Profile.VisitedLinksSize", size_MB); |
| 222 |
| 223 size = file_util::ComputeFilesSize(path_, FILE_PATH_LITERAL("Web Data")); |
| 224 size_MB = static_cast<int>(size / (1024 * 1024)); |
| 225 UMA_HISTOGRAM_COUNTS_10000("Profile.WebDataSize", size_MB); |
| 226 |
| 227 size = file_util::ComputeFilesSize(path_, FILE_PATH_LITERAL("Extension*")); |
| 228 size_MB = static_cast<int>(size / (1024 * 1024)); |
| 229 UMA_HISTOGRAM_COUNTS_10000("Profile.ExtensionSize", size_MB); |
| 230 } |
| 231 |
| 182 } // namespace | 232 } // namespace |
| 183 | 233 |
| 184 // A pointer to the request context for the default profile. See comments on | 234 // A pointer to the request context for the default profile. See comments on |
| 185 // Profile::GetDefaultRequestContext. | 235 // Profile::GetDefaultRequestContext. |
| 186 URLRequestContextGetter* Profile::default_request_context_; | 236 URLRequestContextGetter* Profile::default_request_context_; |
| 187 | 237 |
| 188 static void CleanupRequestContext(ChromeURLRequestContextGetter* context) { | 238 static void CleanupRequestContext(ChromeURLRequestContextGetter* context) { |
| 189 if (context) | 239 if (context) |
| 190 context->CleanupOnUIThread(); | 240 context->CleanupOnUIThread(); |
| 191 } | 241 } |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 255 request_context_ = ChromeURLRequestContextGetter::CreateOffTheRecord(this); | 305 request_context_ = ChromeURLRequestContextGetter::CreateOffTheRecord(this); |
| 256 | 306 |
| 257 // Register for browser close notifications so we can detect when the last | 307 // Register for browser close notifications so we can detect when the last |
| 258 // off-the-record window is closed, in which case we can clean our states | 308 // off-the-record window is closed, in which case we can clean our states |
| 259 // (cookies, downloads...). | 309 // (cookies, downloads...). |
| 260 registrar_.Add(this, NotificationType::BROWSER_CLOSED, | 310 registrar_.Add(this, NotificationType::BROWSER_CLOSED, |
| 261 NotificationService::AllSources()); | 311 NotificationService::AllSources()); |
| 262 } | 312 } |
| 263 | 313 |
| 264 virtual ~OffTheRecordProfileImpl() { | 314 virtual ~OffTheRecordProfileImpl() { |
| 265 NotificationService::current()->Notify( | 315 NotificationService::current()->Notify(NotificationType::PROFILE_DESTROYED, |
| 266 NotificationType::PROFILE_DESTROYED, | 316 Source<Profile>(this), |
| 267 Source<Profile>(this), | 317 NotificationService::NoDetails()); |
| 268 NotificationService::NoDetails()); | 318 CleanupRequestContext(request_context_); |
| 269 CleanupRequestContext(request_context_); | |
| 270 } | 319 } |
| 271 | 320 |
| 272 virtual ProfileId GetRuntimeId() { | 321 virtual ProfileId GetRuntimeId() { |
| 273 return reinterpret_cast<ProfileId>(this); | 322 return reinterpret_cast<ProfileId>(this); |
| 274 } | 323 } |
| 275 | 324 |
| 276 virtual FilePath GetPath() { return profile_->GetPath(); } | 325 virtual FilePath GetPath() { return profile_->GetPath(); } |
| 277 | 326 |
| 278 virtual bool IsOffTheRecord() { | 327 virtual bool IsOffTheRecord() { |
| 279 return true; | 328 return true; |
| (...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 742 Source<Profile>(this)); | 791 Source<Profile>(this)); |
| 743 | 792 |
| 744 ssl_config_service_manager_.reset( | 793 ssl_config_service_manager_.reset( |
| 745 SSLConfigServiceManager::CreateDefaultManager(this)); | 794 SSLConfigServiceManager::CreateDefaultManager(this)); |
| 746 | 795 |
| 747 #if defined(OS_CHROMEOS) | 796 #if defined(OS_CHROMEOS) |
| 748 chromeos_preferences_.Init(prefs); | 797 chromeos_preferences_.Init(prefs); |
| 749 #endif | 798 #endif |
| 750 | 799 |
| 751 pinned_tab_service_.reset(new PinnedTabService(this)); | 800 pinned_tab_service_.reset(new PinnedTabService(this)); |
| 801 |
| 802 // Log the profile size after a reasonable startup delay. |
| 803 ChromeThread::PostDelayedTask(ChromeThread::FILE, FROM_HERE, |
| 804 new ProfileSizeTask(path_), 112000); |
| 752 } | 805 } |
| 753 | 806 |
| 754 void ProfileImpl::InitExtensions() { | 807 void ProfileImpl::InitExtensions() { |
| 755 if (user_script_master_ || extensions_service_) | 808 if (user_script_master_ || extensions_service_) |
| 756 return; // Already initialized. | 809 return; // Already initialized. |
| 757 | 810 |
| 758 const CommandLine* command_line = CommandLine::ForCurrentProcess(); | 811 const CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 759 if (command_line->HasSwitch( | 812 if (command_line->HasSwitch( |
| 760 switches::kEnableExtensionTimelineApi)) { | 813 switches::kEnableExtensionTimelineApi)) { |
| 761 extension_devtools_manager_ = new ExtensionDevToolsManager(this); | 814 extension_devtools_manager_ = new ExtensionDevToolsManager(this); |
| (...skipping 792 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1554 CommandLine::ForCurrentProcess())); | 1607 CommandLine::ForCurrentProcess())); |
| 1555 sync_service_.reset( | 1608 sync_service_.reset( |
| 1556 profile_sync_factory_->CreateProfileSyncService()); | 1609 profile_sync_factory_->CreateProfileSyncService()); |
| 1557 sync_service_->Initialize(); | 1610 sync_service_->Initialize(); |
| 1558 } | 1611 } |
| 1559 | 1612 |
| 1560 void ProfileImpl::InitCloudPrintProxyService() { | 1613 void ProfileImpl::InitCloudPrintProxyService() { |
| 1561 cloud_print_proxy_service_.reset(new CloudPrintProxyService(this)); | 1614 cloud_print_proxy_service_.reset(new CloudPrintProxyService(this)); |
| 1562 cloud_print_proxy_service_->Initialize(); | 1615 cloud_print_proxy_service_->Initialize(); |
| 1563 } | 1616 } |
| OLD | NEW |