| 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 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 public: | 57 public: |
| 58 // Used to specify the kind of passphrase with which sync data is encrypted. | 58 // Used to specify the kind of passphrase with which sync data is encrypted. |
| 59 enum PassphraseType { | 59 enum PassphraseType { |
| 60 IMPLICIT, // The user did not provide a custom passphrase for encryption. | 60 IMPLICIT, // The user did not provide a custom passphrase for encryption. |
| 61 // We implicitly use the GAIA password in such cases. | 61 // We implicitly use the GAIA password in such cases. |
| 62 EXPLICIT, // The user selected the "use custom passphrase" radio button | 62 EXPLICIT, // The user selected the "use custom passphrase" radio button |
| 63 // during sync setup and provided a passphrase. | 63 // during sync setup and provided a passphrase. |
| 64 }; | 64 }; |
| 65 | 65 |
| 66 // Passed as an argument to RequestStop to control whether or not the sync | 66 // Passed as an argument to RequestStop to control whether or not the sync |
| 67 // backend should clear its data directory when it shuts down. See | 67 // engine should clear its data directory when it shuts down. See |
| 68 // RequestStop for more information. | 68 // RequestStop for more information. |
| 69 enum SyncStopDataFate { | 69 enum SyncStopDataFate { |
| 70 KEEP_DATA, | 70 KEEP_DATA, |
| 71 CLEAR_DATA, | 71 CLEAR_DATA, |
| 72 }; | 72 }; |
| 73 | 73 |
| 74 // Status of sync server connection, sync token and token request. | 74 // Status of sync server connection, sync token and token request. |
| 75 struct SyncTokenStatus { | 75 struct SyncTokenStatus { |
| 76 SyncTokenStatus(); | 76 SyncTokenStatus(); |
| 77 | 77 |
| 78 // Sync server connection status reported by sync backend. | 78 // Sync server connection status reported by sync engine. |
| 79 base::Time connection_status_update_time; | 79 base::Time connection_status_update_time; |
| 80 ConnectionStatus connection_status; | 80 ConnectionStatus connection_status; |
| 81 | 81 |
| 82 // Times when OAuth2 access token is requested and received. | 82 // Times when OAuth2 access token is requested and received. |
| 83 base::Time token_request_time; | 83 base::Time token_request_time; |
| 84 base::Time token_receive_time; | 84 base::Time token_receive_time; |
| 85 | 85 |
| 86 // Error returned by OAuth2TokenService for token request and time when | 86 // Error returned by OAuth2TokenService for token request and time when |
| 87 // next request is scheduled. | 87 // next request is scheduled. |
| 88 GoogleServiceAuthError last_get_token_error; | 88 GoogleServiceAuthError last_get_token_error; |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 // told to MergeDataAndStartSyncing yet. | 140 // told to MergeDataAndStartSyncing yet. |
| 141 virtual void OnDataTypeRequestsSyncStartup(ModelType type) = 0; | 141 virtual void OnDataTypeRequestsSyncStartup(ModelType type) = 0; |
| 142 | 142 |
| 143 // Returns true if sync is allowed, requested, and the user is logged in. | 143 // Returns true if sync is allowed, requested, and the user is logged in. |
| 144 // (being logged in does not mean that tokens are available - tokens may | 144 // (being logged in does not mean that tokens are available - tokens may |
| 145 // be missing because they have not loaded yet, or because they were deleted | 145 // be missing because they have not loaded yet, or because they were deleted |
| 146 // due to http://crbug.com/121755). | 146 // due to http://crbug.com/121755). |
| 147 virtual bool CanSyncStart() const = 0; | 147 virtual bool CanSyncStart() const = 0; |
| 148 | 148 |
| 149 // Stops sync at the user's request. |data_fate| controls whether the sync | 149 // Stops sync at the user's request. |data_fate| controls whether the sync |
| 150 // backend should clear its data directory when it shuts down. Generally | 150 // engine should clear its data directory when it shuts down. Generally |
| 151 // KEEP_DATA is used when the user just stops sync, and CLEAR_DATA is used | 151 // KEEP_DATA is used when the user just stops sync, and CLEAR_DATA is used |
| 152 // when they sign out of the profile entirely. | 152 // when they sign out of the profile entirely. |
| 153 virtual void RequestStop(SyncStopDataFate data_fate) = 0; | 153 virtual void RequestStop(SyncStopDataFate data_fate) = 0; |
| 154 | 154 |
| 155 // The user requests that sync start. This only actually starts sync if | 155 // The user requests that sync start. This only actually starts sync if |
| 156 // IsSyncAllowed is true and the user is signed in. Once sync starts, | 156 // IsSyncAllowed is true and the user is signed in. Once sync starts, |
| 157 // other things such as IsFirstSetupComplete being false can still prevent | 157 // other things such as IsFirstSetupComplete being false can still prevent |
| 158 // it from moving into the "active" state. | 158 // it from moving into the "active" state. |
| 159 virtual void RequestStart() = 0; | 159 virtual void RequestStart() = 0; |
| 160 | 160 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 virtual bool IsSetupInProgress() const = 0; | 194 virtual bool IsSetupInProgress() const = 0; |
| 195 | 195 |
| 196 // Whether the data types active for the current mode have finished | 196 // Whether the data types active for the current mode have finished |
| 197 // configuration. | 197 // configuration. |
| 198 virtual bool ConfigurationDone() const = 0; | 198 virtual bool ConfigurationDone() const = 0; |
| 199 | 199 |
| 200 virtual const GoogleServiceAuthError& GetAuthError() const = 0; | 200 virtual const GoogleServiceAuthError& GetAuthError() const = 0; |
| 201 virtual bool HasUnrecoverableError() const = 0; | 201 virtual bool HasUnrecoverableError() const = 0; |
| 202 | 202 |
| 203 // Returns true if the SyncEngine has told us it's ready to accept changes. | 203 // Returns true if the SyncEngine has told us it's ready to accept changes. |
| 204 virtual bool IsBackendInitialized() const = 0; | 204 virtual bool IsEngineInitialized() const = 0; |
| 205 | 205 |
| 206 // Return the active OpenTabsUIDelegate. If open/proxy tabs is not enabled or | 206 // Return the active OpenTabsUIDelegate. If open/proxy tabs is not enabled or |
| 207 // not currently syncing, returns nullptr. | 207 // not currently syncing, returns nullptr. |
| 208 virtual sync_sessions::OpenTabsUIDelegate* GetOpenTabsUIDelegate() = 0; | 208 virtual sync_sessions::OpenTabsUIDelegate* GetOpenTabsUIDelegate() = 0; |
| 209 | 209 |
| 210 // Returns true if OnPassphraseRequired has been called for decryption and | 210 // Returns true if OnPassphraseRequired has been called for decryption and |
| 211 // we have an encrypted data type enabled. | 211 // we have an encrypted data type enabled. |
| 212 virtual bool IsPassphraseRequiredForDecryption() const = 0; | 212 virtual bool IsPassphraseRequiredForDecryption() const = 0; |
| 213 | 213 |
| 214 // Returns the time the current explicit passphrase (if any), was set. | 214 // Returns the time the current explicit passphrase (if any), was set. |
| 215 // If no secondary passphrase is in use, or no time is available, returns an | 215 // If no secondary passphrase is in use, or no time is available, returns an |
| 216 // unset base::Time. | 216 // unset base::Time. |
| 217 virtual base::Time GetExplicitPassphraseTime() const = 0; | 217 virtual base::Time GetExplicitPassphraseTime() const = 0; |
| 218 | 218 |
| 219 // Returns true if a secondary (explicit) passphrase is being used. It is not | 219 // Returns true if a secondary (explicit) passphrase is being used. It is not |
| 220 // legal to call this method before the backend is initialized. | 220 // legal to call this method before the engine is initialized. |
| 221 virtual bool IsUsingSecondaryPassphrase() const = 0; | 221 virtual bool IsUsingSecondaryPassphrase() const = 0; |
| 222 | 222 |
| 223 // Turns on encryption for all data. Callers must call OnUserChoseDatatypes() | 223 // Turns on encryption for all data. Callers must call OnUserChoseDatatypes() |
| 224 // after calling this to force the encryption to occur. | 224 // after calling this to force the encryption to occur. |
| 225 virtual void EnableEncryptEverything() = 0; | 225 virtual void EnableEncryptEverything() = 0; |
| 226 | 226 |
| 227 // Returns true if we are currently set to encrypt all the sync data. | 227 // Returns true if we are currently set to encrypt all the sync data. |
| 228 virtual bool IsEncryptEverythingEnabled() const = 0; | 228 virtual bool IsEncryptEverythingEnabled() const = 0; |
| 229 | 229 |
| 230 // Asynchronously sets the passphrase to |passphrase| for encryption. |type| | 230 // Asynchronously sets the passphrase to |passphrase| for encryption. |type| |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 266 // not change the preferred state of a datatype, and is not persisted across | 266 // not change the preferred state of a datatype, and is not persisted across |
| 267 // restarts. | 267 // restarts. |
| 268 virtual void ReenableDatatype(ModelType type) = 0; | 268 virtual void ReenableDatatype(ModelType type) = 0; |
| 269 | 269 |
| 270 // Return sync token status. | 270 // Return sync token status. |
| 271 virtual SyncTokenStatus GetSyncTokenStatus() const = 0; | 271 virtual SyncTokenStatus GetSyncTokenStatus() const = 0; |
| 272 | 272 |
| 273 // Get a description of the sync status for displaying in the user interface. | 273 // Get a description of the sync status for displaying in the user interface. |
| 274 virtual std::string QuerySyncStatusSummaryString() = 0; | 274 virtual std::string QuerySyncStatusSummaryString() = 0; |
| 275 | 275 |
| 276 // Initializes a struct of status indicators with data from the backend. | 276 // Initializes a struct of status indicators with data from the engine. |
| 277 // Returns false if the backend was not available for querying; in that case | 277 // Returns false if the engine was not available for querying; in that case |
| 278 // the struct will be filled with default data. | 278 // the struct will be filled with default data. |
| 279 virtual bool QueryDetailedSyncStatus(SyncStatus* result) = 0; | 279 virtual bool QueryDetailedSyncStatus(SyncStatus* result) = 0; |
| 280 | 280 |
| 281 // Returns a user-friendly string form of last synced time (in minutes). | 281 // Returns a user-friendly string form of last synced time (in minutes). |
| 282 virtual base::string16 GetLastSyncedTimeString() const = 0; | 282 virtual base::string16 GetLastSyncedTimeString() const = 0; |
| 283 | 283 |
| 284 // Returns a human readable string describing backend initialization state. | 284 // Returns a human readable string describing engine initialization state. |
| 285 virtual std::string GetBackendInitializationStateString() const = 0; | 285 virtual std::string GetEngineInitializationStateString() const = 0; |
| 286 | 286 |
| 287 virtual SyncCycleSnapshot GetLastCycleSnapshot() const = 0; | 287 virtual SyncCycleSnapshot GetLastCycleSnapshot() const = 0; |
| 288 | 288 |
| 289 // Returns a ListValue indicating the status of all registered types. | 289 // Returns a ListValue indicating the status of all registered types. |
| 290 // | 290 // |
| 291 // The format is: | 291 // The format is: |
| 292 // [ {"name": <name>, "value": <value>, "status": <status> }, ... ] | 292 // [ {"name": <name>, "value": <value>, "status": <status> }, ... ] |
| 293 // where <name> is a type's name, <value> is a string providing details for | 293 // where <name> is a type's name, <value> is a string providing details for |
| 294 // the type's status, and <status> is one of "error", "warning" or "ok" | 294 // the type's status, and <status> is one of "error", "warning" or "ok" |
| 295 // depending on the type's current status. | 295 // depending on the type's current status. |
| (...skipping 30 matching lines...) Expand all Loading... |
| 326 protected: | 326 protected: |
| 327 SyncService() {} | 327 SyncService() {} |
| 328 | 328 |
| 329 private: | 329 private: |
| 330 DISALLOW_COPY_AND_ASSIGN(SyncService); | 330 DISALLOW_COPY_AND_ASSIGN(SyncService); |
| 331 }; | 331 }; |
| 332 | 332 |
| 333 } // namespace syncer | 333 } // namespace syncer |
| 334 | 334 |
| 335 #endif // COMPONENTS_SYNC_DRIVER_SYNC_SERVICE_H_ | 335 #endif // COMPONENTS_SYNC_DRIVER_SYNC_SERVICE_H_ |
| OLD | NEW |