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

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

Issue 13197004: Draft: InvalidationService (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Passes tests Created 7 years, 8 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 class P2PInvalidationService;
20 21
21 namespace browser_sync { 22 namespace browser_sync {
22 namespace sessions { 23 namespace sessions {
23 class SyncSessionSnapshot; 24 class SyncSessionSnapshot;
24 } 25 }
25 } 26 }
26 27
27 // 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
28 // automation purposes. It harnesses the ProfileSyncService member of the 29 // automation purposes. It harnesses the ProfileSyncService member of the
29 // 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
30 // 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
31 // several clients to get to the same state. 32 // several clients to get to the same state.
32 class ProfileSyncServiceHarness 33 class ProfileSyncServiceHarness
33 : public ProfileSyncServiceObserver, 34 : public ProfileSyncServiceObserver,
34 public browser_sync::MigrationObserver { 35 public browser_sync::MigrationObserver {
35 public: 36 public:
36 ProfileSyncServiceHarness(Profile* profile, 37 ProfileSyncServiceHarness(Profile* profile,
38 P2PInvalidationService* invalidation_service,
37 const std::string& username, 39 const std::string& username,
38 const std::string& password); 40 const std::string& password);
39 41
40 virtual ~ProfileSyncServiceHarness(); 42 virtual ~ProfileSyncServiceHarness();
41 43
42 // Creates a ProfileSyncServiceHarness object and attaches it to |profile|, a 44 // 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 45 // profile that is assumed to have been signed into sync in the past. Caller
44 // takes ownership. 46 // takes ownership.
45 static ProfileSyncServiceHarness* CreateAndAttach(Profile* profile); 47 static ProfileSyncServiceHarness* CreateAndAttach(
48 Profile* profile,
49 P2PInvalidationService* p2p_invalidation_service);
46 50
47 // Sets the GAIA credentials with which to sign in to sync. 51 // Sets the GAIA credentials with which to sign in to sync.
48 void SetCredentials(const std::string& username, const std::string& password); 52 void SetCredentials(const std::string& username, const std::string& password);
49 53
50 // Returns true if sync has been enabled on |profile_|. 54 // Returns true if sync has been enabled on |profile_|.
51 bool IsSyncAlreadySetup(); 55 bool IsSyncAlreadySetup();
52 56
53 // Creates a ProfileSyncService for the profile passed at construction and 57 // Creates a ProfileSyncService for the profile passed at construction and
54 // enables sync for all available datatypes. Returns true only after sync has 58 // enables sync for all available datatypes. Returns true only after sync has
55 // been fully initialized and authenticated, and we are ready to process 59 // been fully initialized and authenticated, and we are ready to process
56 // changes. 60 // changes.
57 bool SetupSync(); 61 bool SetupSync();
58 62
59 // Same as the above method, but enables sync only for the datatypes contained 63 // Same as the above method, but enables sync only for the datatypes contained
60 // in |synced_datatypes|. 64 // in |synced_datatypes|.
61 bool SetupSync(syncer::ModelTypeSet synced_datatypes); 65 bool SetupSync(syncer::ModelTypeSet synced_datatypes);
62 66
63 // ProfileSyncServiceObserver implementation. 67 // ProfileSyncServiceObserver implementation.
64 virtual void OnStateChanged() OVERRIDE; 68 virtual void OnStateChanged() OVERRIDE;
69 virtual void OnSyncCycleCompleted() OVERRIDE;
65 70
66 // MigrationObserver implementation. 71 // MigrationObserver implementation.
67 virtual void OnMigrationStateChange() OVERRIDE; 72 virtual void OnMigrationStateChange() OVERRIDE;
68 73
69 // Blocks the caller until the sync backend host associated with this harness 74 // Blocks the caller until the sync backend host associated with this harness
70 // has been initialized. Returns true if the wait was successful. 75 // has been initialized. Returns true if the wait was successful.
71 bool AwaitBackendInitialized(); 76 bool AwaitBackendInitialized();
72 77
73 // Blocks the caller until the datatype manager is configured and sync has 78 // Blocks the caller until the datatype manager is configured and sync has
74 // been initialized (for example, after a browser restart). Returns true if 79 // been initialized (for example, after a browser restart). Returns true if
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
332 // The WaitState in which the sync client currently is. Helps determine what 337 // The WaitState in which the sync client currently is. Helps determine what
333 // action to take when RunStateChangeMachine() is called. 338 // action to take when RunStateChangeMachine() is called.
334 WaitState wait_state_; 339 WaitState wait_state_;
335 340
336 // Sync profile associated with this sync client. 341 // Sync profile associated with this sync client.
337 Profile* profile_; 342 Profile* profile_;
338 343
339 // ProfileSyncService object associated with |profile_|. 344 // ProfileSyncService object associated with |profile_|.
340 ProfileSyncService* service_; 345 ProfileSyncService* service_;
341 346
347 // P2PInvalidationService associated with |profile_|.
348 P2PInvalidationService* p2p_invalidation_service_;
349
342 // The harness of the client whose update progress marker we're expecting 350 // The harness of the client whose update progress marker we're expecting
343 // eventually match. 351 // eventually match.
344 ProfileSyncServiceHarness* progress_marker_partner_; 352 ProfileSyncServiceHarness* progress_marker_partner_;
345 353
346 // Credentials used for GAIA authentication. 354 // Credentials used for GAIA authentication.
347 std::string username_; 355 std::string username_;
348 std::string password_; 356 std::string password_;
349 357
350 // The current set of data types pending migration. Used by 358 // The current set of data types pending migration. Used by
351 // AwaitMigration(). 359 // AwaitMigration().
(...skipping 12 matching lines...) Expand all
364 372
365 // Flag set to true when we're waiting for a status change to happen. Used to 373 // Flag set to true when we're waiting for a status change to happen. Used to
366 // avoid triggering internal state machine logic on unexpected sync observer 374 // avoid triggering internal state machine logic on unexpected sync observer
367 // callbacks. 375 // callbacks.
368 bool waiting_for_status_change_; 376 bool waiting_for_status_change_;
369 377
370 DISALLOW_COPY_AND_ASSIGN(ProfileSyncServiceHarness); 378 DISALLOW_COPY_AND_ASSIGN(ProfileSyncServiceHarness);
371 }; 379 };
372 380
373 #endif // CHROME_BROWSER_SYNC_PROFILE_SYNC_SERVICE_HARNESS_H_ 381 #endif // CHROME_BROWSER_SYNC_PROFILE_SYNC_SERVICE_HARNESS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698