| 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 CHROME_BROWSER_SYNC_STARTUP_CONTROLLER_H_ | 5 #ifndef CHROME_BROWSER_SYNC_STARTUP_CONTROLLER_H_ |
| 6 #define CHROME_BROWSER_SYNC_STARTUP_CONTROLLER_H_ | 6 #define CHROME_BROWSER_SYNC_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" |
| 11 #include "sync/internal_api/public/base/model_type.h" | 11 #include "sync/internal_api/public/base/model_type.h" |
| 12 | 12 |
| 13 class ManagedUserSigninManagerWrapper; | 13 class ManagedUserSigninManagerWrapper; |
| 14 class ProfileOAuth2TokenService; | 14 class ProfileOAuth2TokenService; |
| 15 | 15 |
| 16 namespace sync_driver { |
| 17 class SyncPrefs; |
| 18 } |
| 19 |
| 16 namespace browser_sync { | 20 namespace browser_sync { |
| 17 | 21 |
| 18 class SyncPrefs; | |
| 19 | |
| 20 // Defines the type of behavior the sync engine should use. If configured for | 22 // Defines the type of behavior the sync engine should use. If configured for |
| 21 // AUTO_START, the sync engine will automatically call SetSyncSetupCompleted() | 23 // AUTO_START, the sync engine will automatically call SetSyncSetupCompleted() |
| 22 // and start downloading data types as soon as sync credentials are available. | 24 // and start downloading data types as soon as sync credentials are available. |
| 23 // If configured for MANUAL_START, sync will not start until the user | 25 // If configured for MANUAL_START, sync will not start until the user |
| 24 // completes sync setup, at which point the UI makes an explicit call to | 26 // completes sync setup, at which point the UI makes an explicit call to |
| 25 // complete sync setup. | 27 // complete sync setup. |
| 26 enum ProfileSyncServiceStartBehavior { | 28 enum ProfileSyncServiceStartBehavior { |
| 27 AUTO_START, | 29 AUTO_START, |
| 28 MANUAL_START, | 30 MANUAL_START, |
| 29 }; | 31 }; |
| 30 | 32 |
| 31 // This class is used by ProfileSyncService to manage all logic and state | 33 // This class is used by ProfileSyncService to manage all logic and state |
| 32 // pertaining to initialization of the SyncBackendHost (colloquially referred | 34 // pertaining to initialization of the SyncBackendHost (colloquially referred |
| 33 // to as "the backend"). | 35 // to as "the backend"). |
| 34 class StartupController { | 36 class StartupController { |
| 35 public: | 37 public: |
| 36 StartupController(ProfileSyncServiceStartBehavior start_behavior, | 38 StartupController(ProfileSyncServiceStartBehavior start_behavior, |
| 37 const ProfileOAuth2TokenService* token_service, | 39 const ProfileOAuth2TokenService* token_service, |
| 38 const browser_sync::SyncPrefs* sync_prefs, | 40 const sync_driver::SyncPrefs* sync_prefs, |
| 39 const ManagedUserSigninManagerWrapper* signin, | 41 const ManagedUserSigninManagerWrapper* signin, |
| 40 base::Closure start_backend); | 42 base::Closure start_backend); |
| 41 ~StartupController(); | 43 ~StartupController(); |
| 42 | 44 |
| 43 // Starts up sync if it is not suppressed and preconditions are met. | 45 // Starts up sync if it is not suppressed and preconditions are met. |
| 44 // Returns true if these preconditions are met, although does not imply | 46 // Returns true if these preconditions are met, although does not imply |
| 45 // the backend was started. | 47 // the backend was started. |
| 46 bool TryStart(); | 48 bool TryStart(); |
| 47 | 49 |
| 48 // Called when a datatype (SyncableService) has a need for sync to start | 50 // Called when a datatype (SyncableService) has a need for sync to start |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 // If |true|, there is setup UI visible so we should not start downloading | 86 // If |true|, there is setup UI visible so we should not start downloading |
| 85 // data types. | 87 // data types. |
| 86 bool setup_in_progress_; | 88 bool setup_in_progress_; |
| 87 | 89 |
| 88 // If true, we want to automatically start sync signin whenever we have | 90 // If true, we want to automatically start sync signin whenever we have |
| 89 // credentials (user doesn't need to go through the startup flow). This is | 91 // credentials (user doesn't need to go through the startup flow). This is |
| 90 // typically enabled on platforms (like ChromeOS) that have their own | 92 // typically enabled on platforms (like ChromeOS) that have their own |
| 91 // distinct signin flow. | 93 // distinct signin flow. |
| 92 const bool auto_start_enabled_; | 94 const bool auto_start_enabled_; |
| 93 | 95 |
| 94 const browser_sync::SyncPrefs* sync_prefs_; | 96 const sync_driver::SyncPrefs* sync_prefs_; |
| 95 | 97 |
| 96 const ProfileOAuth2TokenService* token_service_; | 98 const ProfileOAuth2TokenService* token_service_; |
| 97 | 99 |
| 98 const ManagedUserSigninManagerWrapper* signin_; | 100 const ManagedUserSigninManagerWrapper* signin_; |
| 99 | 101 |
| 100 // The callback we invoke when it's time to call expensive | 102 // The callback we invoke when it's time to call expensive |
| 101 // startup routines for the sync backend. | 103 // startup routines for the sync backend. |
| 102 base::Closure start_backend_; | 104 base::Closure start_backend_; |
| 103 | 105 |
| 104 // The time at which we invoked the start_backend_ callback. | 106 // The time at which we invoked the start_backend_ callback. |
| 105 base::Time start_backend_time_; | 107 base::Time start_backend_time_; |
| 106 | 108 |
| 107 base::TimeDelta fallback_timeout_; | 109 base::TimeDelta fallback_timeout_; |
| 108 | 110 |
| 109 // Used to compute preferred_types from SyncPrefs as-needed. | 111 // Used to compute preferred_types from SyncPrefs as-needed. |
| 110 syncer::ModelTypeSet registered_types_; | 112 syncer::ModelTypeSet registered_types_; |
| 111 | 113 |
| 112 base::WeakPtrFactory<StartupController> weak_factory_; | 114 base::WeakPtrFactory<StartupController> weak_factory_; |
| 113 }; | 115 }; |
| 114 | 116 |
| 115 } // namespace browser_sync | 117 } // namespace browser_sync |
| 116 | 118 |
| 117 #endif // CHROME_BROWSER_SYNC_STARTUP_CONTROLLER_H_ | 119 #endif // CHROME_BROWSER_SYNC_STARTUP_CONTROLLER_H_ |
| OLD | NEW |