| 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 #ifndef COMPONENTS_SYNC_DRIVER_STARTUP_CONTROLLER_H_ | 5 #ifndef COMPONENTS_SYNC_DRIVER_STARTUP_CONTROLLER_H_ |
| 6 #define COMPONENTS_SYNC_DRIVER_STARTUP_CONTROLLER_H_ | 6 #define COMPONENTS_SYNC_DRIVER_STARTUP_CONTROLLER_H_ |
| 7 | 7 |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
| 10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 void OnDataTypeRequestsSyncStartup(syncer::ModelType type); | 54 void OnDataTypeRequestsSyncStartup(syncer::ModelType type); |
| 55 | 55 |
| 56 // Prepares this object for a new attempt to start sync, forgetting | 56 // Prepares this object for a new attempt to start sync, forgetting |
| 57 // whether or not preconditions were previously met. | 57 // whether or not preconditions were previously met. |
| 58 // NOTE: This resets internal state managed by this class, but does not | 58 // NOTE: This resets internal state managed by this class, but does not |
| 59 // touch values that are explicitly set and reset by higher layers to | 59 // touch values that are explicitly set and reset by higher layers to |
| 60 // tell this class whether a setup UI dialog is being shown to the user. | 60 // tell this class whether a setup UI dialog is being shown to the user. |
| 61 // See setup_in_progress_. | 61 // See setup_in_progress_. |
| 62 void Reset(const syncer::ModelTypeSet registered_types); | 62 void Reset(const syncer::ModelTypeSet registered_types); |
| 63 | 63 |
| 64 void set_setup_in_progress(bool in_progress); | 64 // Sets the setup in progress flag and tries to start sync if it's true. |
| 65 void SetSetupInProgress(bool setup_in_progress); |
| 66 |
| 65 bool IsSetupInProgress() const { return setup_in_progress_; } | 67 bool IsSetupInProgress() const { return setup_in_progress_; } |
| 66 base::Time start_backend_time() const { return start_backend_time_; } | 68 base::Time start_backend_time() const { return start_backend_time_; } |
| 67 std::string GetBackendInitializationStateString() const; | 69 std::string GetBackendInitializationStateString() const; |
| 68 | 70 |
| 69 void OverrideFallbackTimeoutForTest(const base::TimeDelta& timeout); | 71 void OverrideFallbackTimeoutForTest(const base::TimeDelta& timeout); |
| 70 | 72 |
| 71 private: | 73 private: |
| 72 enum StartUpDeferredOption { | 74 enum StartUpDeferredOption { |
| 73 STARTUP_BACKEND_DEFERRED, | 75 STARTUP_BACKEND_DEFERRED, |
| 74 STARTUP_IMMEDIATE | 76 STARTUP_IMMEDIATE |
| (...skipping 11 matching lines...) Expand all Loading... |
| 86 | 88 |
| 87 // The time that StartUp() is called. This is used to calculate time spent | 89 // The time that StartUp() is called. This is used to calculate time spent |
| 88 // in the deferred state; that is, after StartUp and before invoking the | 90 // in the deferred state; that is, after StartUp and before invoking the |
| 89 // start_backend_ callback. | 91 // start_backend_ callback. |
| 90 base::Time start_up_time_; | 92 base::Time start_up_time_; |
| 91 | 93 |
| 92 // If |true|, there is setup UI visible so we should not start downloading | 94 // If |true|, there is setup UI visible so we should not start downloading |
| 93 // data types. | 95 // data types. |
| 94 // Note: this is explicitly controlled by higher layers (UI) and is meant to | 96 // Note: this is explicitly controlled by higher layers (UI) and is meant to |
| 95 // reflect what the UI claims the setup state to be. Therefore, only set this | 97 // reflect what the UI claims the setup state to be. Therefore, only set this |
| 96 // due to explicit requests to do so via set_setup_in_progress. | 98 // due to explicit requests to do so via SetSetupInProgress. |
| 97 bool setup_in_progress_; | 99 bool setup_in_progress_; |
| 98 | 100 |
| 99 const sync_driver::SyncPrefs* sync_prefs_; | 101 const sync_driver::SyncPrefs* sync_prefs_; |
| 100 | 102 |
| 101 const ProfileOAuth2TokenService* token_service_; | 103 const ProfileOAuth2TokenService* token_service_; |
| 102 | 104 |
| 103 const SigninManagerWrapper* signin_; | 105 const SigninManagerWrapper* signin_; |
| 104 | 106 |
| 105 // The callback we invoke when it's time to call expensive | 107 // The callback we invoke when it's time to call expensive |
| 106 // startup routines for the sync backend. | 108 // startup routines for the sync backend. |
| 107 base::Closure start_backend_; | 109 base::Closure start_backend_; |
| 108 | 110 |
| 109 // The time at which we invoked the start_backend_ callback. | 111 // The time at which we invoked the start_backend_ callback. |
| 110 base::Time start_backend_time_; | 112 base::Time start_backend_time_; |
| 111 | 113 |
| 112 base::TimeDelta fallback_timeout_; | 114 base::TimeDelta fallback_timeout_; |
| 113 | 115 |
| 114 // Used to compute preferred_types from SyncPrefs as-needed. | 116 // Used to compute preferred_types from SyncPrefs as-needed. |
| 115 syncer::ModelTypeSet registered_types_; | 117 syncer::ModelTypeSet registered_types_; |
| 116 | 118 |
| 117 base::WeakPtrFactory<StartupController> weak_factory_; | 119 base::WeakPtrFactory<StartupController> weak_factory_; |
| 118 }; | 120 }; |
| 119 | 121 |
| 120 } // namespace browser_sync | 122 } // namespace browser_sync |
| 121 | 123 |
| 122 #endif // COMPONENTS_SYNC_DRIVER_STARTUP_CONTROLLER_H_ | 124 #endif // COMPONENTS_SYNC_DRIVER_STARTUP_CONTROLLER_H_ |
| OLD | NEW |