Index: chrome/browser/sync/profile_sync_service_harness.cc |
diff --git a/chrome/browser/sync/profile_sync_service_harness.cc b/chrome/browser/sync/profile_sync_service_harness.cc |
index ee77cb7225f824c988c971cb0632416aa3320469..47b7434ba3bf859bfb4be891b76d116a8072583f 100644 |
--- a/chrome/browser/sync/profile_sync_service_harness.cc |
+++ b/chrome/browser/sync/profile_sync_service_harness.cc |
@@ -21,6 +21,7 @@ |
#include "base/memory/ref_counted.h" |
#include "base/message_loop.h" |
#include "base/prefs/pref_service.h" |
+#include "chrome/browser/invalidation/p2p_invalidation_service.h" |
#include "chrome/browser/profiles/profile.h" |
#include "chrome/browser/signin/signin_manager_base.h" |
#include "chrome/browser/signin/token_service.h" |
@@ -38,6 +39,7 @@ |
#include "sync/internal_api/public/util/sync_string_conversions.h" |
using syncer::sessions::SyncSessionSnapshot; |
+using invalidation::P2PInvalidationService; |
// TODO(rsimha): Remove the following lines once crbug.com/91863 is fixed. |
// The amount of time for which we wait for a live sync operation to complete. |
@@ -106,14 +108,36 @@ bool StateChangeTimeoutEvent::Abort() { |
return !did_timeout_; |
} |
+// static |
+ProfileSyncServiceHarness* ProfileSyncServiceHarness::Create( |
+ Profile* profile, |
+ const std::string& username, |
+ const std::string& password) { |
+ return new ProfileSyncServiceHarness(profile, username, password, NULL); |
+} |
+ |
+// static |
+ProfileSyncServiceHarness* ProfileSyncServiceHarness::CreateForIntegrationTest( |
+ Profile* profile, |
+ const std::string& username, |
+ const std::string& password, |
+ P2PInvalidationService* p2p_invalidation_service) { |
+ return new ProfileSyncServiceHarness(profile, |
+ username, |
+ password, |
+ p2p_invalidation_service); |
+} |
+ |
ProfileSyncServiceHarness::ProfileSyncServiceHarness( |
Profile* profile, |
const std::string& username, |
- const std::string& password) |
+ const std::string& password, |
+ P2PInvalidationService* p2p_invalidation_service) |
: waiting_for_encryption_type_(syncer::UNSPECIFIED), |
wait_state_(INITIAL_WAIT_STATE), |
profile_(profile), |
service_(NULL), |
+ p2p_invalidation_service_(p2p_invalidation_service), |
progress_marker_partner_(NULL), |
username_(username), |
password_(password), |
@@ -133,17 +157,6 @@ ProfileSyncServiceHarness::~ProfileSyncServiceHarness() { |
service_->RemoveObserver(this); |
} |
-// static |
-ProfileSyncServiceHarness* ProfileSyncServiceHarness::CreateAndAttach( |
- Profile* profile) { |
- ProfileSyncServiceFactory* f = ProfileSyncServiceFactory::GetInstance(); |
- if (!f->HasProfileSyncService(profile)) { |
- NOTREACHED() << "Profile has never signed into sync."; |
- return NULL; |
- } |
- return new ProfileSyncServiceHarness(profile, std::string(), std::string()); |
-} |
- |
void ProfileSyncServiceHarness::SetCredentials(const std::string& username, |
const std::string& password) { |
username_ = username; |
@@ -482,6 +495,21 @@ void ProfileSyncServiceHarness::OnStateChanged() { |
RunStateChangeMachine(); |
} |
+void ProfileSyncServiceHarness::OnSyncCycleCompleted() { |
+ // Integration tests still use p2p notifications. |
+ const SyncSessionSnapshot& snap = GetLastSessionSnapshot(); |
+ bool is_notifiable_commit = |
+ (snap.model_neutral_state().num_successful_commits > 0); |
+ if (is_notifiable_commit && p2p_invalidation_service_) { |
+ const syncer::ObjectIdInvalidationMap& invalidation_map = |
+ ModelTypeInvalidationMapToObjectIdInvalidationMap( |
+ snap.source().types); |
+ p2p_invalidation_service_->SendInvalidation(invalidation_map); |
+ } |
+ |
+ OnStateChanged(); |
+} |
+ |
void ProfileSyncServiceHarness::OnMigrationStateChange() { |
// Update migration state. |
if (HasPendingBackendMigration()) { |