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_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 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 class SyncSetupInProgressHandle { | |
maxbogue
2016/06/09 20:04:14
Comment explaining the purpose of this class?
tommycli
2016/06/10 00:04:16
Done.
| |
50 public: | |
51 explicit SyncSetupInProgressHandle(base::Closure on_destroy); | |
52 ~SyncSetupInProgressHandle(); | |
53 | |
54 private: | |
55 base::Closure on_destroy_; | |
56 }; | |
57 | |
49 class SyncService : public DataTypeEncryptionHandler { | 58 class SyncService : public DataTypeEncryptionHandler { |
50 public: | 59 public: |
51 // Used to specify the kind of passphrase with which sync data is encrypted. | 60 // Used to specify the kind of passphrase with which sync data is encrypted. |
52 enum PassphraseType { | 61 enum PassphraseType { |
53 IMPLICIT, // The user did not provide a custom passphrase for encryption. | 62 IMPLICIT, // The user did not provide a custom passphrase for encryption. |
54 // We implicitly use the GAIA password in such cases. | 63 // We implicitly use the GAIA password in such cases. |
55 EXPLICIT, // The user selected the "use custom passphrase" radio button | 64 EXPLICIT, // The user selected the "use custom passphrase" radio button |
56 // during sync setup and provided a passphrase. | 65 // during sync setup and provided a passphrase. |
57 }; | 66 }; |
58 | 67 |
59 // Passed as an argument to RequestStop to control whether or not the sync | 68 // 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 | 69 // backend should clear its data directory when it shuts down. See |
61 // RequestStop for more information. | 70 // RequestStop for more information. |
62 enum SyncStopDataFate { | 71 enum SyncStopDataFate { |
63 KEEP_DATA, | 72 KEEP_DATA, |
64 CLEAR_DATA, | 73 CLEAR_DATA, |
65 }; | 74 }; |
66 | 75 |
67 // Status of sync server connection, sync token and token request. | 76 // Status of sync server connection, sync token and token request. |
68 struct SyncTokenStatus { | 77 struct SyncTokenStatus { |
69 SyncTokenStatus(); | 78 SyncTokenStatus(); |
70 ~SyncTokenStatus(); | |
71 | 79 |
72 // Sync server connection status reported by sync backend. | 80 // Sync server connection status reported by sync backend. |
73 base::Time connection_status_update_time; | 81 base::Time connection_status_update_time; |
74 syncer::ConnectionStatus connection_status; | 82 syncer::ConnectionStatus connection_status; |
75 | 83 |
76 // Times when OAuth2 access token is requested and received. | 84 // Times when OAuth2 access token is requested and received. |
77 base::Time token_request_time; | 85 base::Time token_request_time; |
78 base::Time token_receive_time; | 86 base::Time token_receive_time; |
79 | 87 |
80 // Error returned by OAuth2TokenService for token request and time when | 88 // Error returned by OAuth2TokenService for token request and time when |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
169 | 177 |
170 // Returns true if initial sync setup is in progress (does not return true | 178 // 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). | 179 // 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 | 180 // 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. | 181 // user is still setting up the initial sync configuration. |
174 virtual bool IsFirstSetupInProgress() const = 0; | 182 virtual bool IsFirstSetupInProgress() const = 0; |
175 | 183 |
176 // Called by the UI to notify the SyncService that UI is visible so it will | 184 // 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 | 185 // 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). | 186 // 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 | 187 // The UI calls this and holds onto the instance for as long as any part of |
180 // (even just the login UI). | 188 // 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 | 189 // When the last outstanding handle is deleted, this kicks off the sync engine |
182 // that data download starts. In this case, |ReconfigureDatatypeManager| will | 190 // to ensure that data download starts. In this case, |
183 // get triggered. | 191 // |ReconfigureDatatypeManager| will get triggered. |
184 virtual void SetSetupInProgress(bool setup_in_progress) = 0; | 192 std::unique_ptr<SyncSetupInProgressHandle> GetSetupInProgressHandle(); |
maxbogue
2016/06/09 20:04:14
Why is the implementation of this on this class an
tommycli
2016/06/10 00:04:16
Done.
| |
185 | 193 |
186 // Used by tests. | 194 // Used by tests. |
187 virtual bool IsSetupInProgress() const = 0; | 195 virtual bool IsSetupInProgress() const = 0; |
188 | 196 |
189 // Whether the data types active for the current mode have finished | 197 // Whether the data types active for the current mode have finished |
190 // configuration. | 198 // configuration. |
191 virtual bool ConfigurationDone() const = 0; | 199 virtual bool ConfigurationDone() const = 0; |
192 | 200 |
193 virtual const GoogleServiceAuthError& GetAuthError() const = 0; | 201 virtual const GoogleServiceAuthError& GetAuthError() const = 0; |
194 virtual bool HasUnrecoverableError() const = 0; | 202 virtual bool HasUnrecoverableError() const = 0; |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
318 // returns them to the specified callback on this thread. | 326 // returns them to the specified callback on this thread. |
319 // | 327 // |
320 // These requests can live a long time and return when you least expect it. | 328 // These requests can live a long time and return when you least expect it. |
321 // For safety, the callback should be bound to some sort of WeakPtr<> or | 329 // For safety, the callback should be bound to some sort of WeakPtr<> or |
322 // scoped_refptr<>. | 330 // scoped_refptr<>. |
323 virtual void GetAllNodes( | 331 virtual void GetAllNodes( |
324 const base::Callback<void(std::unique_ptr<base::ListValue>)>& | 332 const base::Callback<void(std::unique_ptr<base::ListValue>)>& |
325 callback) = 0; | 333 callback) = 0; |
326 | 334 |
327 protected: | 335 protected: |
328 SyncService() {} | 336 friend class SyncSetupInProgressHandle; |
maxbogue
2016/06/09 20:04:13
This shouldn't be necessary should it? That class
tommycli
2016/06/10 00:04:16
Done.
| |
337 | |
338 SyncService() : outstanding_setup_in_progress_handles_(0) {} | |
maxbogue
2016/06/09 20:04:13
You can just use = 0 on the declaration below now.
tommycli
2016/06/10 00:04:16
Done.
| |
339 | |
340 // Called internally by the GetSetupInProgressHandle mechanism. | |
341 // This should not be called directly (except by the Android wrapper). | |
maxbogue
2016/06/09 20:04:14
What Android wrapper?
tommycli
2016/06/10 00:04:15
Done. Method removed.
| |
342 virtual void SetSetupInProgress(bool setup_in_progress) = 0; | |
343 | |
344 int outstanding_setup_in_progress_handles_; | |
maxbogue
2016/06/09 20:04:13
Comment please.
tommycli
2016/06/10 00:04:15
Done.
| |
329 | 345 |
330 private: | 346 private: |
347 void OnSetupInProgressHandleDestroyed(); | |
348 | |
331 DISALLOW_COPY_AND_ASSIGN(SyncService); | 349 DISALLOW_COPY_AND_ASSIGN(SyncService); |
332 }; | 350 }; |
333 | 351 |
334 } // namespace sync_driver | 352 } // namespace sync_driver |
335 | 353 |
336 #endif // COMPONENTS_SYNC_DRIVER_SYNC_SERVICE_H_ | 354 #endif // COMPONENTS_SYNC_DRIVER_SYNC_SERVICE_H_ |
OLD | NEW |