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

Side by Side Diff: trunk/src/chrome/browser/sync/profile_sync_service_harness.h

Issue 17610004: Revert 208315 "Make use of InvalidationService" (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 7 years, 5 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 | Annotate | Revision Log
OLDNEW
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 7
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "base/compiler_specific.h" 12 #include "base/compiler_specific.h"
13 #include "chrome/browser/sync/backend_migrator.h" 13 #include "chrome/browser/sync/backend_migrator.h"
14 #include "chrome/browser/sync/profile_sync_service.h" 14 #include "chrome/browser/sync/profile_sync_service.h"
15 #include "chrome/browser/sync/profile_sync_service_observer.h" 15 #include "chrome/browser/sync/profile_sync_service_observer.h"
16 #include "chrome/browser/sync/retry_verifier.h" 16 #include "chrome/browser/sync/retry_verifier.h"
17 #include "sync/internal_api/public/base/model_type.h" 17 #include "sync/internal_api/public/base/model_type.h"
18 18
19 class Profile; 19 class Profile;
20 20
21 namespace invalidation {
22 class P2PInvalidationService;
23 }
24
25 namespace browser_sync { 21 namespace browser_sync {
26 namespace sessions { 22 namespace sessions {
27 class SyncSessionSnapshot; 23 class SyncSessionSnapshot;
28 } 24 }
29 } 25 }
30 26
31 // An instance of this class is basically our notion of a "sync client" for 27 // An instance of this class is basically our notion of a "sync client" for
32 // automation purposes. It harnesses the ProfileSyncService member of the 28 // automation purposes. It harnesses the ProfileSyncService member of the
33 // profile passed to it on construction and automates certain things like setup 29 // profile passed to it on construction and automates certain things like setup
34 // and authentication. It provides ways to "wait" adequate periods of time for 30 // and authentication. It provides ways to "wait" adequate periods of time for
35 // several clients to get to the same state. 31 // several clients to get to the same state.
36 class ProfileSyncServiceHarness 32 class ProfileSyncServiceHarness
37 : public ProfileSyncServiceObserver, 33 : public ProfileSyncServiceObserver,
38 public browser_sync::MigrationObserver { 34 public browser_sync::MigrationObserver {
39 public: 35 public:
40 static ProfileSyncServiceHarness* Create( 36 ProfileSyncServiceHarness(Profile* profile,
41 Profile* profile, 37 const std::string& username,
42 const std::string& username, 38 const std::string& password);
43 const std::string& password);
44
45 static ProfileSyncServiceHarness* CreateForIntegrationTest(
46 Profile* profile,
47 const std::string& username,
48 const std::string& password,
49 invalidation::P2PInvalidationService* invalidation_service);
50 39
51 virtual ~ProfileSyncServiceHarness(); 40 virtual ~ProfileSyncServiceHarness();
52 41
42 // Creates a ProfileSyncServiceHarness object and attaches it to |profile|, a
43 // profile that is assumed to have been signed into sync in the past. Caller
44 // takes ownership.
45 static ProfileSyncServiceHarness* CreateAndAttach(Profile* profile);
46
53 // Sets the GAIA credentials with which to sign in to sync. 47 // Sets the GAIA credentials with which to sign in to sync.
54 void SetCredentials(const std::string& username, const std::string& password); 48 void SetCredentials(const std::string& username, const std::string& password);
55 49
56 // Returns true if sync has been enabled on |profile_|. 50 // Returns true if sync has been enabled on |profile_|.
57 bool IsSyncAlreadySetup(); 51 bool IsSyncAlreadySetup();
58 52
59 // Creates a ProfileSyncService for the profile passed at construction and 53 // Creates a ProfileSyncService for the profile passed at construction and
60 // enables sync for all available datatypes. Returns true only after sync has 54 // enables sync for all available datatypes. Returns true only after sync has
61 // been fully initialized and authenticated, and we are ready to process 55 // been fully initialized and authenticated, and we are ready to process
62 // changes. 56 // changes.
63 bool SetupSync(); 57 bool SetupSync();
64 58
65 // Same as the above method, but enables sync only for the datatypes contained 59 // Same as the above method, but enables sync only for the datatypes contained
66 // in |synced_datatypes|. 60 // in |synced_datatypes|.
67 bool SetupSync(syncer::ModelTypeSet synced_datatypes); 61 bool SetupSync(syncer::ModelTypeSet synced_datatypes);
68 62
69 // ProfileSyncServiceObserver implementation. 63 // ProfileSyncServiceObserver implementation.
70 virtual void OnStateChanged() OVERRIDE; 64 virtual void OnStateChanged() OVERRIDE;
71 virtual void OnSyncCycleCompleted() OVERRIDE;
72 65
73 // MigrationObserver implementation. 66 // MigrationObserver implementation.
74 virtual void OnMigrationStateChange() OVERRIDE; 67 virtual void OnMigrationStateChange() OVERRIDE;
75 68
76 // Blocks the caller until the sync backend host associated with this harness 69 // Blocks the caller until the sync backend host associated with this harness
77 // has been initialized. Returns true if the wait was successful. 70 // has been initialized. Returns true if the wait was successful.
78 bool AwaitBackendInitialized(); 71 bool AwaitBackendInitialized();
79 72
80 // Blocks the caller until this harness has completed a single sync cycle 73 // Blocks the caller until this harness has completed a single sync cycle
81 // since the previous one. Returns true if a sync cycle has completed. 74 // since the previous one. Returns true if a sync cycle has completed.
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 263
271 // The sync client is fully synced and there are no pending updates. 264 // The sync client is fully synced and there are no pending updates.
272 FULLY_SYNCED, 265 FULLY_SYNCED,
273 266
274 // Syncing is disabled for the client. 267 // Syncing is disabled for the client.
275 SYNC_DISABLED, 268 SYNC_DISABLED,
276 269
277 NUMBER_OF_STATES, 270 NUMBER_OF_STATES,
278 }; 271 };
279 272
280 ProfileSyncServiceHarness(
281 Profile* profile,
282 const std::string& username,
283 const std::string& password,
284 invalidation::P2PInvalidationService* invalidation_service);
285
286 // Listen to migration events if the migrator has been initialized 273 // Listen to migration events if the migrator has been initialized
287 // and we're not already listening. Returns true if we started 274 // and we're not already listening. Returns true if we started
288 // listening. 275 // listening.
289 bool TryListeningToMigrationEvents(); 276 bool TryListeningToMigrationEvents();
290 277
291 // Called from the observer when the current wait state has been completed. 278 // Called from the observer when the current wait state has been completed.
292 void SignalStateCompleteWithNextState(WaitState next_state); 279 void SignalStateCompleteWithNextState(WaitState next_state);
293 280
294 // Indicates that the operation being waited on is complete. 281 // Indicates that the operation being waited on is complete.
295 void SignalStateComplete(); 282 void SignalStateComplete();
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 // The WaitState in which the sync client currently is. Helps determine what 327 // The WaitState in which the sync client currently is. Helps determine what
341 // action to take when RunStateChangeMachine() is called. 328 // action to take when RunStateChangeMachine() is called.
342 WaitState wait_state_; 329 WaitState wait_state_;
343 330
344 // Sync profile associated with this sync client. 331 // Sync profile associated with this sync client.
345 Profile* profile_; 332 Profile* profile_;
346 333
347 // ProfileSyncService object associated with |profile_|. 334 // ProfileSyncService object associated with |profile_|.
348 ProfileSyncService* service_; 335 ProfileSyncService* service_;
349 336
350 // P2PInvalidationService associated with |profile_|.
351 invalidation::P2PInvalidationService* p2p_invalidation_service_;
352
353 // The harness of the client whose update progress marker we're expecting 337 // The harness of the client whose update progress marker we're expecting
354 // eventually match. 338 // eventually match.
355 ProfileSyncServiceHarness* progress_marker_partner_; 339 ProfileSyncServiceHarness* progress_marker_partner_;
356 340
357 // Credentials used for GAIA authentication. 341 // Credentials used for GAIA authentication.
358 std::string username_; 342 std::string username_;
359 std::string password_; 343 std::string password_;
360 344
361 // The current set of data types pending migration. Used by 345 // The current set of data types pending migration. Used by
362 // AwaitMigration(). 346 // AwaitMigration().
(...skipping 12 matching lines...) Expand all
375 359
376 // Flag set to true when we're waiting for a status change to happen. Used to 360 // Flag set to true when we're waiting for a status change to happen. Used to
377 // avoid triggering internal state machine logic on unexpected sync observer 361 // avoid triggering internal state machine logic on unexpected sync observer
378 // callbacks. 362 // callbacks.
379 bool waiting_for_status_change_; 363 bool waiting_for_status_change_;
380 364
381 DISALLOW_COPY_AND_ASSIGN(ProfileSyncServiceHarness); 365 DISALLOW_COPY_AND_ASSIGN(ProfileSyncServiceHarness);
382 }; 366 };
383 367
384 #endif // CHROME_BROWSER_SYNC_PROFILE_SYNC_SERVICE_HARNESS_H_ 368 #endif // CHROME_BROWSER_SYNC_PROFILE_SYNC_SERVICE_HARNESS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698