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/sync/profile_sync_service.h" | 5 #include "chrome/browser/sync/profile_sync_service.h" |
6 | 6 |
7 #include <cstddef> | 7 #include <cstddef> |
8 #include <map> | 8 #include <map> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
282 device_info_sync_service_.reset( | 282 device_info_sync_service_.reset( |
283 new DeviceInfoSyncService(local_device_.get())); | 283 new DeviceInfoSyncService(local_device_.get())); |
284 } | 284 } |
285 | 285 |
286 ProfileSyncService::~ProfileSyncService() { | 286 ProfileSyncService::~ProfileSyncService() { |
287 sync_prefs_.RemoveSyncPrefObserver(this); | 287 sync_prefs_.RemoveSyncPrefObserver(this); |
288 // Shutdown() should have been called before destruction. | 288 // Shutdown() should have been called before destruction. |
289 CHECK(!backend_initialized_); | 289 CHECK(!backend_initialized_); |
290 } | 290 } |
291 | 291 |
292 bool ProfileSyncService::IsSyncEnabledAndLoggedIn() { | 292 bool ProfileSyncService::CanSyncStart() const { |
293 // Exit if sync is not allowed or not requested. | 293 return IsSyncAllowed() && IsSyncRequested() && IsSignedIn(); |
294 if (!IsSyncAllowed() || !IsSyncRequested()) | |
295 return false; | |
296 | |
297 return IsSignedIn(); | |
298 } | 294 } |
299 | 295 |
300 bool ProfileSyncService::IsOAuthRefreshTokenAvailable() { | 296 bool ProfileSyncService::IsOAuthRefreshTokenAvailable() { |
301 if (!oauth2_token_service_) | 297 if (!oauth2_token_service_) |
302 return false; | 298 return false; |
303 | 299 |
304 return oauth2_token_service_->RefreshTokenIsAvailable( | 300 return oauth2_token_service_->RefreshTokenIsAvailable( |
305 signin_->GetAccountIdToUse()); | 301 signin_->GetAccountIdToUse()); |
306 } | 302 } |
307 | 303 |
(...skipping 2441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2749 } else { | 2745 } else { |
2750 UMA_HISTOGRAM_COUNTS("Sync.MemoryPressureWarningBeforeCleanShutdown", | 2746 UMA_HISTOGRAM_COUNTS("Sync.MemoryPressureWarningBeforeCleanShutdown", |
2751 warning_received); | 2747 warning_received); |
2752 } | 2748 } |
2753 } | 2749 } |
2754 sync_prefs_.SetMemoryPressureWarningCount(0); | 2750 sync_prefs_.SetMemoryPressureWarningCount(0); |
2755 // Will set to true during a clean shutdown, so crash or something else will | 2751 // Will set to true during a clean shutdown, so crash or something else will |
2756 // remain this as false. | 2752 // remain this as false. |
2757 sync_prefs_.SetCleanShutdown(false); | 2753 sync_prefs_.SetCleanShutdown(false); |
2758 } | 2754 } |
OLD | NEW |