| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/startup_controller.h" | 5 #include "chrome/browser/sync/startup_controller.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
| 10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
| 11 #include "chrome/browser/sync/managed_user_signin_manager_wrapper.h" | 11 #include "chrome/browser/sync/supervised_user_signin_manager_wrapper.h" |
| 12 #include "chrome/common/chrome_switches.h" | 12 #include "chrome/common/chrome_switches.h" |
| 13 #include "components/signin/core/browser/profile_oauth2_token_service.h" | 13 #include "components/signin/core/browser/profile_oauth2_token_service.h" |
| 14 #include "components/sync_driver/sync_prefs.h" | 14 #include "components/sync_driver/sync_prefs.h" |
| 15 | 15 |
| 16 namespace browser_sync { | 16 namespace browser_sync { |
| 17 | 17 |
| 18 namespace { | 18 namespace { |
| 19 | 19 |
| 20 // The amount of time we'll wait to initialize sync if no data type triggers | 20 // The amount of time we'll wait to initialize sync if no data type triggers |
| 21 // initialization via a StartSyncFlare. | 21 // initialization via a StartSyncFlare. |
| 22 const int kDeferredInitFallbackSeconds = 10; | 22 const int kDeferredInitFallbackSeconds = 10; |
| 23 | 23 |
| 24 // Enum (for UMA, primarily) defining different events that cause us to | 24 // Enum (for UMA, primarily) defining different events that cause us to |
| 25 // exit the "deferred" state of initialization and invoke start_backend. | 25 // exit the "deferred" state of initialization and invoke start_backend. |
| 26 enum DeferredInitTrigger { | 26 enum DeferredInitTrigger { |
| 27 // We have received a signal from a SyncableService requesting that sync | 27 // We have received a signal from a SyncableService requesting that sync |
| 28 // starts as soon as possible. | 28 // starts as soon as possible. |
| 29 TRIGGER_DATA_TYPE_REQUEST, | 29 TRIGGER_DATA_TYPE_REQUEST, |
| 30 // No data type requested sync to start and our fallback timer expired. | 30 // No data type requested sync to start and our fallback timer expired. |
| 31 TRIGGER_FALLBACK_TIMER, | 31 TRIGGER_FALLBACK_TIMER, |
| 32 MAX_TRIGGER_VALUE | 32 MAX_TRIGGER_VALUE |
| 33 }; | 33 }; |
| 34 | 34 |
| 35 } // namespace | 35 } // namespace |
| 36 | 36 |
| 37 StartupController::StartupController( | 37 StartupController::StartupController( |
| 38 ProfileSyncServiceStartBehavior start_behavior, | 38 ProfileSyncServiceStartBehavior start_behavior, |
| 39 const ProfileOAuth2TokenService* token_service, | 39 const ProfileOAuth2TokenService* token_service, |
| 40 const sync_driver::SyncPrefs* sync_prefs, | 40 const sync_driver::SyncPrefs* sync_prefs, |
| 41 const ManagedUserSigninManagerWrapper* signin, | 41 const SupervisedUserSigninManagerWrapper* signin, |
| 42 base::Closure start_backend) | 42 base::Closure start_backend) |
| 43 : received_start_request_(false), | 43 : received_start_request_(false), |
| 44 setup_in_progress_(false), | 44 setup_in_progress_(false), |
| 45 auto_start_enabled_(start_behavior == AUTO_START), | 45 auto_start_enabled_(start_behavior == AUTO_START), |
| 46 sync_prefs_(sync_prefs), | 46 sync_prefs_(sync_prefs), |
| 47 token_service_(token_service), | 47 token_service_(token_service), |
| 48 signin_(signin), | 48 signin_(signin), |
| 49 start_backend_(start_backend), | 49 start_backend_(start_backend), |
| 50 fallback_timeout_( | 50 fallback_timeout_( |
| 51 base::TimeDelta::FromSeconds(kDeferredInitFallbackSeconds)), | 51 base::TimeDelta::FromSeconds(kDeferredInitFallbackSeconds)), |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 syncer::MODEL_TYPE_COUNT); | 222 syncer::MODEL_TYPE_COUNT); |
| 223 UMA_HISTOGRAM_ENUMERATION("Sync.Startup.DeferredInitTrigger", | 223 UMA_HISTOGRAM_ENUMERATION("Sync.Startup.DeferredInitTrigger", |
| 224 TRIGGER_DATA_TYPE_REQUEST, | 224 TRIGGER_DATA_TYPE_REQUEST, |
| 225 MAX_TRIGGER_VALUE); | 225 MAX_TRIGGER_VALUE); |
| 226 } | 226 } |
| 227 received_start_request_ = true; | 227 received_start_request_ = true; |
| 228 TryStart(); | 228 TryStart(); |
| 229 } | 229 } |
| 230 | 230 |
| 231 } // namespace browser_sync | 231 } // namespace browser_sync |
| OLD | NEW |