OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 CHROME_BROWSER_SYNC_PROFILE_SYNC_SERVICE_HARNESS_H_ | 5 #ifndef CHROME_BROWSER_SYNC_PROFILE_SYNC_SERVICE_HARNESS_H_ |
6 #define CHROME_BROWSER_SYNC_PROFILE_SYNC_SERVICE_HARNESS_H_ | 6 #define CHROME_BROWSER_SYNC_PROFILE_SYNC_SERVICE_HARNESS_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
13 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
14 #include "chrome/browser/sync/backend_migrator.h" | 14 #include "chrome/browser/sync/backend_migrator.h" |
15 #include "chrome/browser/sync/profile_sync_service.h" | 15 #include "chrome/browser/sync/profile_sync_service.h" |
16 #include "chrome/browser/sync/profile_sync_service_observer.h" | 16 #include "chrome/browser/sync/profile_sync_service_observer.h" |
17 #include "chrome/browser/sync/retry_verifier.h" | 17 #include "chrome/browser/sync/retry_verifier.h" |
18 #include "sync/syncable/model_type.h" | 18 #include "sync/syncable/model_type.h" |
19 | 19 |
20 class Profile; | 20 class Profile; |
21 | 21 |
22 namespace browser_sync { | 22 namespace browser_sync { |
23 namespace sessions { | 23 namespace sessions { |
24 struct SyncSessionSnapshot; | 24 class SyncSessionSnapshot; |
25 } | 25 } |
26 } | 26 } |
27 | 27 |
28 // An instance of this class is basically our notion of a "sync client" for | 28 // An instance of this class is basically our notion of a "sync client" for |
29 // automation purposes. It harnesses the ProfileSyncService member of the | 29 // automation purposes. It harnesses the ProfileSyncService member of the |
30 // profile passed to it on construction and automates certain things like setup | 30 // profile passed to it on construction and automates certain things like setup |
31 // and authentication. It provides ways to "wait" adequate periods of time for | 31 // and authentication. It provides ways to "wait" adequate periods of time for |
32 // several clients to get to the same state. | 32 // several clients to get to the same state. |
33 class ProfileSyncServiceHarness | 33 class ProfileSyncServiceHarness |
34 : public ProfileSyncServiceObserver, | 34 : public ProfileSyncServiceObserver, |
35 public browser_sync::MigrationObserver { | 35 public browser_sync::MigrationObserver { |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 // Disables sync for a particular sync datatype. Returns true on success. | 154 // Disables sync for a particular sync datatype. Returns true on success. |
155 bool DisableSyncForDatatype(syncable::ModelType datatype); | 155 bool DisableSyncForDatatype(syncable::ModelType datatype); |
156 | 156 |
157 // Enables sync for all sync datatypes. Returns true on success. | 157 // Enables sync for all sync datatypes. Returns true on success. |
158 bool EnableSyncForAllDatatypes(); | 158 bool EnableSyncForAllDatatypes(); |
159 | 159 |
160 // Disables sync for all sync datatypes. Returns true on success. | 160 // Disables sync for all sync datatypes. Returns true on success. |
161 bool DisableSyncForAllDatatypes(); | 161 bool DisableSyncForAllDatatypes(); |
162 | 162 |
163 // Returns a snapshot of the current sync session. | 163 // Returns a snapshot of the current sync session. |
164 const browser_sync::sessions::SyncSessionSnapshot* | 164 browser_sync::sessions::SyncSessionSnapshot GetLastSessionSnapshot() const; |
165 GetLastSessionSnapshot() const; | |
166 | 165 |
167 // Encrypt the datatype |type|. This method will block while the sync backend | 166 // Encrypt the datatype |type|. This method will block while the sync backend |
168 // host performs the encryption or a timeout is reached. | 167 // host performs the encryption or a timeout is reached. |
169 // PostCondition: | 168 // PostCondition: |
170 // returns: True if |type| was encrypted and we are fully synced. | 169 // returns: True if |type| was encrypted and we are fully synced. |
171 // False if we timed out. | 170 // False if we timed out. |
172 bool EnableEncryptionForType(syncable::ModelType type); | 171 bool EnableEncryptionForType(syncable::ModelType type); |
173 | 172 |
174 // Wait until |type| is encrypted or we time out. | 173 // Wait until |type| is encrypted or we time out. |
175 // PostCondition: | 174 // PostCondition: |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
283 | 282 |
284 // Finite state machine for controlling state. Returns true only if a state | 283 // Finite state machine for controlling state. Returns true only if a state |
285 // change has taken place. | 284 // change has taken place. |
286 bool RunStateChangeMachine(); | 285 bool RunStateChangeMachine(); |
287 | 286 |
288 // Returns true if a status change took place, false on timeout. | 287 // Returns true if a status change took place, false on timeout. |
289 bool AwaitStatusChangeWithTimeout(int timeout_milliseconds, | 288 bool AwaitStatusChangeWithTimeout(int timeout_milliseconds, |
290 const std::string& reason); | 289 const std::string& reason); |
291 | 290 |
292 // A helper for implementing IsDataSynced() and IsFullySynced(). | 291 // A helper for implementing IsDataSynced() and IsFullySynced(). |
293 bool IsDataSyncedImpl(const browser_sync::sessions::SyncSessionSnapshot*); | 292 bool IsDataSyncedImpl( |
| 293 const browser_sync::sessions::SyncSessionSnapshot& snapshot); |
294 | 294 |
295 // Returns true if the sync client has no unsynced items. | 295 // Returns true if the sync client has no unsynced items. |
296 bool IsDataSynced(); | 296 bool IsDataSynced(); |
297 | 297 |
298 // Returns true if the sync client has no unsynced items and its progress | 298 // Returns true if the sync client has no unsynced items and its progress |
299 // markers are believed to be up to date. | 299 // markers are believed to be up to date. |
300 // | 300 // |
301 // Although we can't detect when commits from other clients invalidate our | 301 // Although we can't detect when commits from other clients invalidate our |
302 // local progress markers, we do know when our own commits have invalidated | 302 // local progress markers, we do know when our own commits have invalidated |
303 // our timestmaps. This check returns true when this client has, to the best | 303 // our timestmaps. This check returns true when this client has, to the best |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
356 const std::string profile_debug_name_; | 356 const std::string profile_debug_name_; |
357 | 357 |
358 // Keeps track of the number of attempts at exponential backoff and its | 358 // Keeps track of the number of attempts at exponential backoff and its |
359 // related bookkeeping information for verification. | 359 // related bookkeeping information for verification. |
360 browser_sync::RetryVerifier retry_verifier_; | 360 browser_sync::RetryVerifier retry_verifier_; |
361 | 361 |
362 DISALLOW_COPY_AND_ASSIGN(ProfileSyncServiceHarness); | 362 DISALLOW_COPY_AND_ASSIGN(ProfileSyncServiceHarness); |
363 }; | 363 }; |
364 | 364 |
365 #endif // CHROME_BROWSER_SYNC_PROFILE_SYNC_SERVICE_HARNESS_H_ | 365 #endif // CHROME_BROWSER_SYNC_PROFILE_SYNC_SERVICE_HARNESS_H_ |
OLD | NEW |