OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_SYNC_SERVICE_H_ | 5 #ifndef COMPONENTS_SYNC_DRIVER_SYNC_SERVICE_H_ |
6 #define COMPONENTS_SYNC_DRIVER_SYNC_SERVICE_H_ | 6 #define COMPONENTS_SYNC_DRIVER_SYNC_SERVICE_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/callback.h" | 11 #include "base/callback_forward.h" |
12 #include "base/location.h" | 12 #include "base/location.h" |
13 #include "base/macros.h" | 13 #include "base/macros.h" |
14 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
15 #include "base/time/time.h" | 15 #include "base/time/time.h" |
16 #include "components/sync_driver/data_type_encryption_handler.h" | 16 #include "components/sync_driver/data_type_encryption_handler.h" |
17 #include "components/sync_driver/sync_service_observer.h" | 17 #include "components/sync_driver/sync_service_observer.h" |
18 #include "google_apis/gaia/google_service_auth_error.h" | 18 #include "google_apis/gaia/google_service_auth_error.h" |
19 #include "sync/internal_api/public/base/model_type.h" | 19 #include "sync/internal_api/public/base/model_type.h" |
20 #include "sync/internal_api/public/connection_status.h" | 20 #include "sync/internal_api/public/connection_status.h" |
21 | 21 |
(...skipping 17 matching lines...) Expand all Loading... |
39 | 39 |
40 } // namespace syncer | 40 } // namespace syncer |
41 | 41 |
42 namespace sync_driver { | 42 namespace sync_driver { |
43 | 43 |
44 class DataTypeController; | 44 class DataTypeController; |
45 class LocalDeviceInfoProvider; | 45 class LocalDeviceInfoProvider; |
46 class OpenTabsUIDelegate; | 46 class OpenTabsUIDelegate; |
47 class SyncClient; | 47 class SyncClient; |
48 | 48 |
49 // UIs that need to prevent Sync startup should hold an instance of this class | |
50 // until the user has finished modifying sync settings. This is not an inner | |
51 // class of SyncService to enable forward declarations. | |
52 class SyncSetupInProgressHandle { | |
53 public: | |
54 // UIs should not construct this directly, but instead call | |
55 // SyncService::GetSetupInProgress(). | |
56 explicit SyncSetupInProgressHandle(base::Closure on_destroy); | |
57 | |
58 ~SyncSetupInProgressHandle(); | |
59 | |
60 private: | |
61 base::Closure on_destroy_; | |
62 }; | |
63 | |
64 class SyncService : public DataTypeEncryptionHandler { | 49 class SyncService : public DataTypeEncryptionHandler { |
65 public: | 50 public: |
66 // Used to specify the kind of passphrase with which sync data is encrypted. | 51 // Used to specify the kind of passphrase with which sync data is encrypted. |
67 enum PassphraseType { | 52 enum PassphraseType { |
68 IMPLICIT, // The user did not provide a custom passphrase for encryption. | 53 IMPLICIT, // The user did not provide a custom passphrase for encryption. |
69 // We implicitly use the GAIA password in such cases. | 54 // We implicitly use the GAIA password in such cases. |
70 EXPLICIT, // The user selected the "use custom passphrase" radio button | 55 EXPLICIT, // The user selected the "use custom passphrase" radio button |
71 // during sync setup and provided a passphrase. | 56 // during sync setup and provided a passphrase. |
72 }; | 57 }; |
73 | 58 |
74 // Passed as an argument to RequestStop to control whether or not the sync | 59 // Passed as an argument to RequestStop to control whether or not the sync |
75 // backend should clear its data directory when it shuts down. See | 60 // backend should clear its data directory when it shuts down. See |
76 // RequestStop for more information. | 61 // RequestStop for more information. |
77 enum SyncStopDataFate { | 62 enum SyncStopDataFate { |
78 KEEP_DATA, | 63 KEEP_DATA, |
79 CLEAR_DATA, | 64 CLEAR_DATA, |
80 }; | 65 }; |
81 | 66 |
82 // Status of sync server connection, sync token and token request. | 67 // Status of sync server connection, sync token and token request. |
83 struct SyncTokenStatus { | 68 struct SyncTokenStatus { |
84 SyncTokenStatus(); | 69 SyncTokenStatus(); |
| 70 ~SyncTokenStatus(); |
85 | 71 |
86 // Sync server connection status reported by sync backend. | 72 // Sync server connection status reported by sync backend. |
87 base::Time connection_status_update_time; | 73 base::Time connection_status_update_time; |
88 syncer::ConnectionStatus connection_status; | 74 syncer::ConnectionStatus connection_status; |
89 | 75 |
90 // Times when OAuth2 access token is requested and received. | 76 // Times when OAuth2 access token is requested and received. |
91 base::Time token_request_time; | 77 base::Time token_request_time; |
92 base::Time token_receive_time; | 78 base::Time token_receive_time; |
93 | 79 |
94 // Error returned by OAuth2TokenService for token request and time when | 80 // Error returned by OAuth2TokenService for token request and time when |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 | 169 |
184 // Returns true if initial sync setup is in progress (does not return true | 170 // Returns true if initial sync setup is in progress (does not return true |
185 // if the user is customizing sync after already completing setup once). | 171 // if the user is customizing sync after already completing setup once). |
186 // SyncService uses this to determine if it's OK to start syncing, or if the | 172 // SyncService uses this to determine if it's OK to start syncing, or if the |
187 // user is still setting up the initial sync configuration. | 173 // user is still setting up the initial sync configuration. |
188 virtual bool IsFirstSetupInProgress() const = 0; | 174 virtual bool IsFirstSetupInProgress() const = 0; |
189 | 175 |
190 // Called by the UI to notify the SyncService that UI is visible so it will | 176 // Called by the UI to notify the SyncService that UI is visible so it will |
191 // not start syncing. This tells sync whether it's safe to start downloading | 177 // not start syncing. This tells sync whether it's safe to start downloading |
192 // data types yet (we don't start syncing until after sync setup is complete). | 178 // data types yet (we don't start syncing until after sync setup is complete). |
193 // The UI calls this and holds onto the instance for as long as any part of | 179 // The UI calls this as soon as any part of the signin wizard is displayed |
194 // the signin wizard is displayed (even just the login UI). | 180 // (even just the login UI). |
195 // When the last outstanding handle is deleted, this kicks off the sync engine | 181 // If |setup_in_progress| is false, this also kicks the sync engine to ensure |
196 // to ensure that data download starts. In this case, | 182 // that data download starts. In this case, |ReconfigureDatatypeManager| will |
197 // |ReconfigureDatatypeManager| will get triggered. | 183 // get triggered. |
198 virtual std::unique_ptr<SyncSetupInProgressHandle> | 184 virtual void SetSetupInProgress(bool setup_in_progress) = 0; |
199 GetSetupInProgressHandle() = 0; | |
200 | 185 |
201 // Used by tests. | 186 // Used by tests. |
202 virtual bool IsSetupInProgress() const = 0; | 187 virtual bool IsSetupInProgress() const = 0; |
203 | 188 |
204 // Whether the data types active for the current mode have finished | 189 // Whether the data types active for the current mode have finished |
205 // configuration. | 190 // configuration. |
206 virtual bool ConfigurationDone() const = 0; | 191 virtual bool ConfigurationDone() const = 0; |
207 | 192 |
208 virtual const GoogleServiceAuthError& GetAuthError() const = 0; | 193 virtual const GoogleServiceAuthError& GetAuthError() const = 0; |
209 virtual bool HasUnrecoverableError() const = 0; | 194 virtual bool HasUnrecoverableError() const = 0; |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
342 protected: | 327 protected: |
343 SyncService() {} | 328 SyncService() {} |
344 | 329 |
345 private: | 330 private: |
346 DISALLOW_COPY_AND_ASSIGN(SyncService); | 331 DISALLOW_COPY_AND_ASSIGN(SyncService); |
347 }; | 332 }; |
348 | 333 |
349 } // namespace sync_driver | 334 } // namespace sync_driver |
350 | 335 |
351 #endif // COMPONENTS_SYNC_DRIVER_SYNC_SERVICE_H_ | 336 #endif // COMPONENTS_SYNC_DRIVER_SYNC_SERVICE_H_ |
OLD | NEW |