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/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 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 | 225 |
226 ProfileImpl::ProfileImpl(const FilePath& path, | 226 ProfileImpl::ProfileImpl(const FilePath& path, |
227 Profile::Delegate* delegate) | 227 Profile::Delegate* delegate) |
228 : path_(path), | 228 : path_(path), |
229 ALLOW_THIS_IN_INITIALIZER_LIST(visited_link_event_listener_( | 229 ALLOW_THIS_IN_INITIALIZER_LIST(visited_link_event_listener_( |
230 new VisitedLinkEventListener(this))), | 230 new VisitedLinkEventListener(this))), |
231 ALLOW_THIS_IN_INITIALIZER_LIST(io_data_(this)), | 231 ALLOW_THIS_IN_INITIALIZER_LIST(io_data_(this)), |
232 extension_devtools_manager_(NULL), | 232 extension_devtools_manager_(NULL), |
233 host_content_settings_map_(NULL), | 233 host_content_settings_map_(NULL), |
234 host_zoom_map_(NULL), | 234 host_zoom_map_(NULL), |
| 235 profile_sync_service_created_(false), |
235 history_service_created_(false), | 236 history_service_created_(false), |
236 favicon_service_created_(false), | 237 favicon_service_created_(false), |
237 created_web_data_service_(false), | 238 created_web_data_service_(false), |
238 created_password_store_(false), | 239 created_password_store_(false), |
239 start_time_(Time::Now()), | 240 start_time_(Time::Now()), |
240 #if defined(OS_WIN) | 241 #if defined(OS_WIN) |
241 checked_instant_promo_(false), | 242 checked_instant_promo_(false), |
242 #endif | 243 #endif |
243 delegate_(delegate), | 244 delegate_(delegate), |
244 predictor_(NULL), | 245 predictor_(NULL), |
(...skipping 1135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1380 } | 1381 } |
1381 #endif | 1382 #endif |
1382 return GetProfileSyncService(""); | 1383 return GetProfileSyncService(""); |
1383 } | 1384 } |
1384 | 1385 |
1385 ProfileSyncService* ProfileImpl::GetProfileSyncService( | 1386 ProfileSyncService* ProfileImpl::GetProfileSyncService( |
1386 const std::string& cros_user) { | 1387 const std::string& cros_user) { |
1387 | 1388 |
1388 if (!ProfileSyncService::IsSyncEnabled()) | 1389 if (!ProfileSyncService::IsSyncEnabled()) |
1389 return NULL; | 1390 return NULL; |
1390 if (!sync_service_.get()) | 1391 if (!profile_sync_service_created_) { |
| 1392 profile_sync_service_created_ = true; |
1391 InitSyncService(cros_user); | 1393 InitSyncService(cros_user); |
| 1394 } |
1392 return sync_service_.get(); | 1395 return sync_service_.get(); |
1393 } | 1396 } |
1394 | 1397 |
1395 void ProfileImpl::InitSyncService(const std::string& cros_user) { | 1398 void ProfileImpl::InitSyncService(const std::string& cros_user) { |
1396 profile_sync_factory_.reset( | 1399 profile_sync_factory_.reset( |
1397 new ProfileSyncComponentsFactoryImpl(this, | 1400 new ProfileSyncComponentsFactoryImpl(this, |
1398 CommandLine::ForCurrentProcess())); | 1401 CommandLine::ForCurrentProcess())); |
1399 sync_service_.reset( | 1402 sync_service_.reset( |
1400 profile_sync_factory_->CreateProfileSyncService(cros_user)); | 1403 profile_sync_factory_->CreateProfileSyncService(cros_user)); |
1401 profile_sync_factory_->RegisterDataTypes(sync_service_.get()); | 1404 profile_sync_factory_->RegisterDataTypes(sync_service_.get()); |
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1638 FilePath* cache_path, | 1641 FilePath* cache_path, |
1639 int* max_size) { | 1642 int* max_size) { |
1640 DCHECK(cache_path); | 1643 DCHECK(cache_path); |
1641 DCHECK(max_size); | 1644 DCHECK(max_size); |
1642 FilePath path(prefs_->GetFilePath(prefs::kDiskCacheDir)); | 1645 FilePath path(prefs_->GetFilePath(prefs::kDiskCacheDir)); |
1643 if (!path.empty()) | 1646 if (!path.empty()) |
1644 *cache_path = path; | 1647 *cache_path = path; |
1645 *max_size = is_media_context ? prefs_->GetInteger(prefs::kMediaCacheSize) : | 1648 *max_size = is_media_context ? prefs_->GetInteger(prefs::kMediaCacheSize) : |
1646 prefs_->GetInteger(prefs::kDiskCacheSize); | 1649 prefs_->GetInteger(prefs::kDiskCacheSize); |
1647 } | 1650 } |
OLD | NEW |