Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(536)

Side by Side Diff: components/sync_driver/sync_service.h

Issue 2044303004: Sync: Support multiple setup UIs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rename variable Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_forward.h" 11 #include "base/callback.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
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
49 class SyncService : public DataTypeEncryptionHandler { 64 class SyncService : public DataTypeEncryptionHandler {
50 public: 65 public:
51 // Used to specify the kind of passphrase with which sync data is encrypted. 66 // Used to specify the kind of passphrase with which sync data is encrypted.
52 enum PassphraseType { 67 enum PassphraseType {
53 IMPLICIT, // The user did not provide a custom passphrase for encryption. 68 IMPLICIT, // The user did not provide a custom passphrase for encryption.
54 // We implicitly use the GAIA password in such cases. 69 // We implicitly use the GAIA password in such cases.
55 EXPLICIT, // The user selected the "use custom passphrase" radio button 70 EXPLICIT, // The user selected the "use custom passphrase" radio button
56 // during sync setup and provided a passphrase. 71 // during sync setup and provided a passphrase.
57 }; 72 };
58 73
59 // Passed as an argument to RequestStop to control whether or not the sync 74 // Passed as an argument to RequestStop to control whether or not the sync
60 // backend should clear its data directory when it shuts down. See 75 // backend should clear its data directory when it shuts down. See
61 // RequestStop for more information. 76 // RequestStop for more information.
62 enum SyncStopDataFate { 77 enum SyncStopDataFate {
63 KEEP_DATA, 78 KEEP_DATA,
64 CLEAR_DATA, 79 CLEAR_DATA,
65 }; 80 };
66 81
67 // Status of sync server connection, sync token and token request. 82 // Status of sync server connection, sync token and token request.
68 struct SyncTokenStatus { 83 struct SyncTokenStatus {
69 SyncTokenStatus(); 84 SyncTokenStatus();
70 ~SyncTokenStatus();
71 85
72 // Sync server connection status reported by sync backend. 86 // Sync server connection status reported by sync backend.
73 base::Time connection_status_update_time; 87 base::Time connection_status_update_time;
74 syncer::ConnectionStatus connection_status; 88 syncer::ConnectionStatus connection_status;
75 89
76 // Times when OAuth2 access token is requested and received. 90 // Times when OAuth2 access token is requested and received.
77 base::Time token_request_time; 91 base::Time token_request_time;
78 base::Time token_receive_time; 92 base::Time token_receive_time;
79 93
80 // Error returned by OAuth2TokenService for token request and time when 94 // Error returned by OAuth2TokenService for token request and time when
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 183
170 // Returns true if initial sync setup is in progress (does not return true 184 // Returns true if initial sync setup is in progress (does not return true
171 // if the user is customizing sync after already completing setup once). 185 // if the user is customizing sync after already completing setup once).
172 // SyncService uses this to determine if it's OK to start syncing, or if the 186 // SyncService uses this to determine if it's OK to start syncing, or if the
173 // user is still setting up the initial sync configuration. 187 // user is still setting up the initial sync configuration.
174 virtual bool IsFirstSetupInProgress() const = 0; 188 virtual bool IsFirstSetupInProgress() const = 0;
175 189
176 // Called by the UI to notify the SyncService that UI is visible so it will 190 // Called by the UI to notify the SyncService that UI is visible so it will
177 // not start syncing. This tells sync whether it's safe to start downloading 191 // not start syncing. This tells sync whether it's safe to start downloading
178 // data types yet (we don't start syncing until after sync setup is complete). 192 // data types yet (we don't start syncing until after sync setup is complete).
179 // The UI calls this as soon as any part of the signin wizard is displayed 193 // The UI calls this and holds onto the instance for as long as any part of
180 // (even just the login UI). 194 // the signin wizard is displayed (even just the login UI).
181 // If |setup_in_progress| is false, this also kicks the sync engine to ensure 195 // When the last outstanding handle is deleted, this kicks off the sync engine
182 // that data download starts. In this case, |ReconfigureDatatypeManager| will 196 // to ensure that data download starts. In this case,
183 // get triggered. 197 // |ReconfigureDatatypeManager| will get triggered.
184 virtual void SetSetupInProgress(bool setup_in_progress) = 0; 198 virtual std::unique_ptr<SyncSetupInProgressHandle>
199 GetSetupInProgressHandle() = 0;
185 200
186 // Used by tests. 201 // Used by tests.
187 virtual bool IsSetupInProgress() const = 0; 202 virtual bool IsSetupInProgress() const = 0;
188 203
189 // Whether the data types active for the current mode have finished 204 // Whether the data types active for the current mode have finished
190 // configuration. 205 // configuration.
191 virtual bool ConfigurationDone() const = 0; 206 virtual bool ConfigurationDone() const = 0;
192 207
193 virtual const GoogleServiceAuthError& GetAuthError() const = 0; 208 virtual const GoogleServiceAuthError& GetAuthError() const = 0;
194 virtual bool HasUnrecoverableError() const = 0; 209 virtual bool HasUnrecoverableError() const = 0;
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 protected: 342 protected:
328 SyncService() {} 343 SyncService() {}
329 344
330 private: 345 private:
331 DISALLOW_COPY_AND_ASSIGN(SyncService); 346 DISALLOW_COPY_AND_ASSIGN(SyncService);
332 }; 347 };
333 348
334 } // namespace sync_driver 349 } // namespace sync_driver
335 350
336 #endif // COMPONENTS_SYNC_DRIVER_SYNC_SERVICE_H_ 351 #endif // COMPONENTS_SYNC_DRIVER_SYNC_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698