| 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_impl.h" | 5 #include "chrome/browser/profiles/profile_impl.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/environment.h" | 10 #include "base/environment.h" |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 // | 117 // |
| 118 // If you don't know about this effort, please read: | 118 // If you don't know about this effort, please read: |
| 119 // https://sites.google.com/a/chromium.org/dev/developers/design-documents/pro
file-architecture | 119 // https://sites.google.com/a/chromium.org/dev/developers/design-documents/pro
file-architecture |
| 120 // | 120 // |
| 121 // REVIEWERS: Do not let anyone increment this. We need to drive the number of | 121 // REVIEWERS: Do not let anyone increment this. We need to drive the number of |
| 122 // raw accessed services down to zero. DO NOT LET PEOPLE REGRESS THIS UNLESS | 122 // raw accessed services down to zero. DO NOT LET PEOPLE REGRESS THIS UNLESS |
| 123 // THE PATCH ITSELF IS MAKING PROGRESS ON PKSF REFACTORING. | 123 // THE PATCH ITSELF IS MAKING PROGRESS ON PKSF REFACTORING. |
| 124 COMPILE_ASSERT(sizeof(ProfileImpl) <= 744u, profile_impl_size_unexpected); | 124 COMPILE_ASSERT(sizeof(ProfileImpl) <= 744u, profile_impl_size_unexpected); |
| 125 #endif | 125 #endif |
| 126 | 126 |
| 127 #if defined(ENABLE_SESSION_SERVICE) |
| 127 // Delay, in milliseconds, before we explicitly create the SessionService. | 128 // Delay, in milliseconds, before we explicitly create the SessionService. |
| 128 static const int kCreateSessionServiceDelayMS = 500; | 129 static const int kCreateSessionServiceDelayMS = 500; |
| 130 #endif |
| 129 | 131 |
| 130 // Text content of README file created in each profile directory. Both %s | 132 // Text content of README file created in each profile directory. Both %s |
| 131 // placeholders must contain the product name. This is not localizable and hence | 133 // placeholders must contain the product name. This is not localizable and hence |
| 132 // not in resources. | 134 // not in resources. |
| 133 static const char kReadmeText[] = | 135 static const char kReadmeText[] = |
| 134 "%s settings and storage represent user-selected preferences and " | 136 "%s settings and storage represent user-selected preferences and " |
| 135 "information and MUST not be extracted, overwritten or modified except " | 137 "information and MUST not be extracted, overwritten or modified except " |
| 136 "through %s defined APIs."; | 138 "through %s defined APIs."; |
| 137 | 139 |
| 138 // Helper method needed because PostTask cannot currently take a Callback | 140 // Helper method needed because PostTask cannot currently take a Callback |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 history_service_created_(false), | 228 history_service_created_(false), |
| 227 favicon_service_created_(false), | 229 favicon_service_created_(false), |
| 228 created_web_data_service_(false), | 230 created_web_data_service_(false), |
| 229 start_time_(Time::Now()), | 231 start_time_(Time::Now()), |
| 230 delegate_(delegate), | 232 delegate_(delegate), |
| 231 predictor_(NULL), | 233 predictor_(NULL), |
| 232 session_restore_enabled_(false) { | 234 session_restore_enabled_(false) { |
| 233 DCHECK(!path.empty()) << "Using an empty path will attempt to write " << | 235 DCHECK(!path.empty()) << "Using an empty path will attempt to write " << |
| 234 "profile files to the root directory!"; | 236 "profile files to the root directory!"; |
| 235 | 237 |
| 238 #if defined(ENABLE_SESSION_SERVICE) |
| 236 create_session_service_timer_.Start(FROM_HERE, | 239 create_session_service_timer_.Start(FROM_HERE, |
| 237 TimeDelta::FromMilliseconds(kCreateSessionServiceDelayMS), this, | 240 TimeDelta::FromMilliseconds(kCreateSessionServiceDelayMS), this, |
| 238 &ProfileImpl::EnsureSessionServiceCreated); | 241 &ProfileImpl::EnsureSessionServiceCreated); |
| 242 #endif |
| 239 | 243 |
| 240 // Determine if prefetch is enabled for this profile. | 244 // Determine if prefetch is enabled for this profile. |
| 241 // If not profile_manager is present, it means we are in a unittest. | 245 // If not profile_manager is present, it means we are in a unittest. |
| 242 const CommandLine* command_line = CommandLine::ForCurrentProcess(); | 246 const CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 243 predictor_ = chrome_browser_net::Predictor::CreatePredictor( | 247 predictor_ = chrome_browser_net::Predictor::CreatePredictor( |
| 244 !command_line->HasSwitch(switches::kDisablePreconnect), | 248 !command_line->HasSwitch(switches::kDisablePreconnect), |
| 245 g_browser_process->profile_manager() == NULL); | 249 g_browser_process->profile_manager() == NULL); |
| 246 | 250 |
| 247 session_restore_enabled_ = | 251 session_restore_enabled_ = |
| 248 !command_line->HasSwitch(switches::kDisableRestoreSessionState); | 252 !command_line->HasSwitch(switches::kDisableRestoreSessionState); |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 452 content::Source<Profile>(this), | 456 content::Source<Profile>(this), |
| 453 content::NotificationService::NoDetails()); | 457 content::NotificationService::NoDetails()); |
| 454 SessionStartupPref pref = SessionStartupPref::GetStartupPref(this); | 458 SessionStartupPref pref = SessionStartupPref::GetStartupPref(this); |
| 455 // Honor the "clear local state" setting. If it's not set, keep the session | 459 // Honor the "clear local state" setting. If it's not set, keep the session |
| 456 // data if we're going to continue the session upon startup. | 460 // data if we're going to continue the session upon startup. |
| 457 if (clear_local_state_on_exit_) | 461 if (clear_local_state_on_exit_) |
| 458 BrowserContext::ClearLocalOnDestruction(this); | 462 BrowserContext::ClearLocalOnDestruction(this); |
| 459 else if (session_restore_enabled_ && pref.type == SessionStartupPref::LAST) | 463 else if (session_restore_enabled_ && pref.type == SessionStartupPref::LAST) |
| 460 BrowserContext::SaveSessionState(this); | 464 BrowserContext::SaveSessionState(this); |
| 461 | 465 |
| 466 #if defined(ENABLE_SESSION_SERVICE) |
| 462 StopCreateSessionServiceTimer(); | 467 StopCreateSessionServiceTimer(); |
| 468 #endif |
| 463 | 469 |
| 464 // Remove pref observers | 470 // Remove pref observers |
| 465 pref_change_registrar_.RemoveAll(); | 471 pref_change_registrar_.RemoveAll(); |
| 466 | 472 |
| 467 ChromePluginServiceFilter::GetInstance()->UnregisterResourceContext( | 473 ChromePluginServiceFilter::GetInstance()->UnregisterResourceContext( |
| 468 io_data_.GetResourceContextNoInit()); | 474 io_data_.GetResourceContextNoInit()); |
| 469 | 475 |
| 470 if (io_data_.HasMainRequestContext() && | 476 if (io_data_.HasMainRequestContext() && |
| 471 default_request_context_ == GetRequestContext()) { | 477 default_request_context_ == GetRequestContext()) { |
| 472 default_request_context_ = NULL; | 478 default_request_context_ = NULL; |
| (...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 955 host, Value::CreateDoubleValue(level)); | 961 host, Value::CreateDoubleValue(level)); |
| 956 } | 962 } |
| 957 } | 963 } |
| 958 break; | 964 break; |
| 959 } | 965 } |
| 960 default: | 966 default: |
| 961 NOTREACHED(); | 967 NOTREACHED(); |
| 962 } | 968 } |
| 963 } | 969 } |
| 964 | 970 |
| 971 #if defined(ENABLE_SESSION_SERVICE) |
| 965 void ProfileImpl::StopCreateSessionServiceTimer() { | 972 void ProfileImpl::StopCreateSessionServiceTimer() { |
| 966 create_session_service_timer_.Stop(); | 973 create_session_service_timer_.Stop(); |
| 967 } | 974 } |
| 968 | 975 |
| 969 void ProfileImpl::EnsureSessionServiceCreated() { | 976 void ProfileImpl::EnsureSessionServiceCreated() { |
| 970 SessionServiceFactory::GetForProfile(this); | 977 SessionServiceFactory::GetForProfile(this); |
| 971 } | 978 } |
| 979 #endif |
| 972 | 980 |
| 973 ChromeURLDataManager* ProfileImpl::GetChromeURLDataManager() { | 981 ChromeURLDataManager* ProfileImpl::GetChromeURLDataManager() { |
| 974 if (!chrome_url_data_manager_.get()) | 982 if (!chrome_url_data_manager_.get()) |
| 975 chrome_url_data_manager_.reset(new ChromeURLDataManager( | 983 chrome_url_data_manager_.reset(new ChromeURLDataManager( |
| 976 io_data_.GetChromeURLDataManagerBackendGetter())); | 984 io_data_.GetChromeURLDataManagerBackendGetter())); |
| 977 return chrome_url_data_manager_.get(); | 985 return chrome_url_data_manager_.get(); |
| 978 } | 986 } |
| 979 | 987 |
| 980 #if defined(OS_CHROMEOS) | 988 #if defined(OS_CHROMEOS) |
| 981 void ProfileImpl::ChangeAppLocale( | 989 void ProfileImpl::ChangeAppLocale( |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1156 FilePath* cache_path, | 1164 FilePath* cache_path, |
| 1157 int* max_size) { | 1165 int* max_size) { |
| 1158 DCHECK(cache_path); | 1166 DCHECK(cache_path); |
| 1159 DCHECK(max_size); | 1167 DCHECK(max_size); |
| 1160 FilePath path(prefs_->GetFilePath(prefs::kDiskCacheDir)); | 1168 FilePath path(prefs_->GetFilePath(prefs::kDiskCacheDir)); |
| 1161 if (!path.empty()) | 1169 if (!path.empty()) |
| 1162 *cache_path = path; | 1170 *cache_path = path; |
| 1163 *max_size = is_media_context ? prefs_->GetInteger(prefs::kMediaCacheSize) : | 1171 *max_size = is_media_context ? prefs_->GetInteger(prefs::kMediaCacheSize) : |
| 1164 prefs_->GetInteger(prefs::kDiskCacheSize); | 1172 prefs_->GetInteger(prefs::kDiskCacheSize); |
| 1165 } | 1173 } |
| OLD | NEW |