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; | |
14 class ProfileOAuth2TokenService; | 13 class ProfileOAuth2TokenService; |
| 14 class SupervisedUserSigninManagerWrapper; |
15 | 15 |
16 namespace sync_driver { | 16 namespace sync_driver { |
17 class SyncPrefs; | 17 class SyncPrefs; |
18 } | 18 } |
19 | 19 |
20 namespace browser_sync { | 20 namespace browser_sync { |
21 | 21 |
22 // 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 |
23 // AUTO_START, the sync engine will automatically call SetSyncSetupCompleted() | 23 // AUTO_START, the sync engine will automatically call SetSyncSetupCompleted() |
24 // 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. |
25 // 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 |
26 // 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 |
27 // complete sync setup. | 27 // complete sync setup. |
28 enum ProfileSyncServiceStartBehavior { | 28 enum ProfileSyncServiceStartBehavior { |
29 AUTO_START, | 29 AUTO_START, |
30 MANUAL_START, | 30 MANUAL_START, |
31 }; | 31 }; |
32 | 32 |
33 // 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 |
34 // pertaining to initialization of the SyncBackendHost (colloquially referred | 34 // pertaining to initialization of the SyncBackendHost (colloquially referred |
35 // to as "the backend"). | 35 // to as "the backend"). |
36 class StartupController { | 36 class StartupController { |
37 public: | 37 public: |
38 StartupController(ProfileSyncServiceStartBehavior start_behavior, | 38 StartupController(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 ~StartupController(); | 43 ~StartupController(); |
44 | 44 |
45 // 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. |
46 // Returns true if these preconditions are met, although does not imply | 46 // Returns true if these preconditions are met, although does not imply |
47 // the backend was started. | 47 // the backend was started. |
48 bool TryStart(); | 48 bool TryStart(); |
49 | 49 |
50 // 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 |
51 // ASAP, presumably because a local change event has occurred but we're | 51 // ASAP, presumably because a local change event has occurred but we're |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 // If true, we want to automatically start sync signin whenever we have | 100 // If true, we want to automatically start sync signin whenever we have |
101 // credentials (user doesn't need to go through the startup flow). This is | 101 // credentials (user doesn't need to go through the startup flow). This is |
102 // typically enabled on platforms (like ChromeOS) that have their own | 102 // typically enabled on platforms (like ChromeOS) that have their own |
103 // distinct signin flow. | 103 // distinct signin flow. |
104 const bool auto_start_enabled_; | 104 const bool auto_start_enabled_; |
105 | 105 |
106 const sync_driver::SyncPrefs* sync_prefs_; | 106 const sync_driver::SyncPrefs* sync_prefs_; |
107 | 107 |
108 const ProfileOAuth2TokenService* token_service_; | 108 const ProfileOAuth2TokenService* token_service_; |
109 | 109 |
110 const ManagedUserSigninManagerWrapper* signin_; | 110 const SupervisedUserSigninManagerWrapper* signin_; |
111 | 111 |
112 // The callback we invoke when it's time to call expensive | 112 // The callback we invoke when it's time to call expensive |
113 // startup routines for the sync backend. | 113 // startup routines for the sync backend. |
114 base::Closure start_backend_; | 114 base::Closure start_backend_; |
115 | 115 |
116 // The time at which we invoked the start_backend_ callback. | 116 // The time at which we invoked the start_backend_ callback. |
117 base::Time start_backend_time_; | 117 base::Time start_backend_time_; |
118 | 118 |
119 base::TimeDelta fallback_timeout_; | 119 base::TimeDelta fallback_timeout_; |
120 | 120 |
121 // Used to compute preferred_types from SyncPrefs as-needed. | 121 // Used to compute preferred_types from SyncPrefs as-needed. |
122 syncer::ModelTypeSet registered_types_; | 122 syncer::ModelTypeSet registered_types_; |
123 | 123 |
124 base::WeakPtrFactory<StartupController> weak_factory_; | 124 base::WeakPtrFactory<StartupController> weak_factory_; |
125 }; | 125 }; |
126 | 126 |
127 } // namespace browser_sync | 127 } // namespace browser_sync |
128 | 128 |
129 #endif // CHROME_BROWSER_SYNC_STARTUP_CONTROLLER_H_ | 129 #endif // CHROME_BROWSER_SYNC_STARTUP_CONTROLLER_H_ |
OLD | NEW |