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

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: 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
« no previous file with comments | « components/sync_driver/fake_sync_service.cc ('k') | components/sync_driver/sync_service.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
22 class GoogleServiceAuthError; 22 class GoogleServiceAuthError;
23 class ProfileSyncService;
23 24
24 namespace browser_sync { 25 namespace browser_sync {
25 class ProtocolEventObserver; 26 class ProtocolEventObserver;
26 } 27 }
27 28
28 namespace syncer { 29 namespace syncer {
29 30
30 class BaseTransaction; 31 class BaseTransaction;
31 class JsController; 32 class JsController;
32 class TypeDebugInfoObserver; 33 class TypeDebugInfoObserver;
33 struct SyncStatus; 34 struct SyncStatus;
34 struct UserShare; 35 struct UserShare;
35 36
36 namespace sessions { 37 namespace sessions {
37 class SyncSessionSnapshot; 38 class SyncSessionSnapshot;
38 } // namespace sessions 39 } // namespace sessions
39 40
40 } // namespace syncer 41 } // namespace syncer
41 42
42 namespace sync_driver { 43 namespace sync_driver {
43 44
44 class DataTypeController; 45 class DataTypeController;
45 class LocalDeviceInfoProvider; 46 class LocalDeviceInfoProvider;
46 class OpenTabsUIDelegate; 47 class OpenTabsUIDelegate;
47 class SyncClient; 48 class SyncClient;
48 49
50 // UIs that need to prevent Sync startup should hold an instance of this class
51 // until the user has finished modifying sync settings.
52 class SyncSetupInProgressHandle {
53 public:
54 ~SyncSetupInProgressHandle();
55
56 private:
57 friend class ::ProfileSyncService;
tommycli 2016/06/10 00:04:16 I added a friend here, since I wanted to ensure th
maxbogue 2016/06/10 17:28:46 I think I would rather just have the constructor b
tommycli 2016/06/10 18:58:20 Done.
58 explicit SyncSetupInProgressHandle(base::Closure on_destroy);
59
60 base::Closure on_destroy_;
61 };
62
49 class SyncService : public DataTypeEncryptionHandler { 63 class SyncService : public DataTypeEncryptionHandler {
50 public: 64 public:
51 // Used to specify the kind of passphrase with which sync data is encrypted. 65 // Used to specify the kind of passphrase with which sync data is encrypted.
52 enum PassphraseType { 66 enum PassphraseType {
53 IMPLICIT, // The user did not provide a custom passphrase for encryption. 67 IMPLICIT, // The user did not provide a custom passphrase for encryption.
54 // We implicitly use the GAIA password in such cases. 68 // We implicitly use the GAIA password in such cases.
55 EXPLICIT, // The user selected the "use custom passphrase" radio button 69 EXPLICIT, // The user selected the "use custom passphrase" radio button
56 // during sync setup and provided a passphrase. 70 // during sync setup and provided a passphrase.
57 }; 71 };
58 72
59 // Passed as an argument to RequestStop to control whether or not the sync 73 // 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 74 // backend should clear its data directory when it shuts down. See
61 // RequestStop for more information. 75 // RequestStop for more information.
62 enum SyncStopDataFate { 76 enum SyncStopDataFate {
63 KEEP_DATA, 77 KEEP_DATA,
64 CLEAR_DATA, 78 CLEAR_DATA,
65 }; 79 };
66 80
67 // Status of sync server connection, sync token and token request. 81 // Status of sync server connection, sync token and token request.
68 struct SyncTokenStatus { 82 struct SyncTokenStatus {
69 SyncTokenStatus(); 83 SyncTokenStatus();
70 ~SyncTokenStatus();
71 84
72 // Sync server connection status reported by sync backend. 85 // Sync server connection status reported by sync backend.
73 base::Time connection_status_update_time; 86 base::Time connection_status_update_time;
74 syncer::ConnectionStatus connection_status; 87 syncer::ConnectionStatus connection_status;
75 88
76 // Times when OAuth2 access token is requested and received. 89 // Times when OAuth2 access token is requested and received.
77 base::Time token_request_time; 90 base::Time token_request_time;
78 base::Time token_receive_time; 91 base::Time token_receive_time;
79 92
80 // Error returned by OAuth2TokenService for token request and time when 93 // Error returned by OAuth2TokenService for token request and time when
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 182
170 // Returns true if initial sync setup is in progress (does not return true 183 // 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). 184 // 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 185 // 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. 186 // user is still setting up the initial sync configuration.
174 virtual bool IsFirstSetupInProgress() const = 0; 187 virtual bool IsFirstSetupInProgress() const = 0;
175 188
176 // Called by the UI to notify the SyncService that UI is visible so it will 189 // 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 190 // 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). 191 // 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 192 // The UI calls this and holds onto the instance for as long as any part of
180 // (even just the login UI). 193 // 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 194 // When the last outstanding handle is deleted, this kicks off the sync engine
182 // that data download starts. In this case, |ReconfigureDatatypeManager| will 195 // to ensure that data download starts. In this case,
183 // get triggered. 196 // |ReconfigureDatatypeManager| will get triggered.
184 virtual void SetSetupInProgress(bool setup_in_progress) = 0; 197 virtual std::unique_ptr<SyncSetupInProgressHandle>
198 GetSetupInProgressHandle() = 0;
185 199
186 // Used by tests. 200 // Used by tests.
187 virtual bool IsSetupInProgress() const = 0; 201 virtual bool IsSetupInProgress() const = 0;
188 202
189 // Whether the data types active for the current mode have finished 203 // Whether the data types active for the current mode have finished
190 // configuration. 204 // configuration.
191 virtual bool ConfigurationDone() const = 0; 205 virtual bool ConfigurationDone() const = 0;
192 206
193 virtual const GoogleServiceAuthError& GetAuthError() const = 0; 207 virtual const GoogleServiceAuthError& GetAuthError() const = 0;
194 virtual bool HasUnrecoverableError() const = 0; 208 virtual bool HasUnrecoverableError() const = 0;
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 protected: 341 protected:
328 SyncService() {} 342 SyncService() {}
329 343
330 private: 344 private:
331 DISALLOW_COPY_AND_ASSIGN(SyncService); 345 DISALLOW_COPY_AND_ASSIGN(SyncService);
332 }; 346 };
333 347
334 } // namespace sync_driver 348 } // namespace sync_driver
335 349
336 #endif // COMPONENTS_SYNC_DRIVER_SYNC_SERVICE_H_ 350 #endif // COMPONENTS_SYNC_DRIVER_SYNC_SERVICE_H_
OLDNEW
« no previous file with comments | « components/sync_driver/fake_sync_service.cc ('k') | components/sync_driver/sync_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698