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 c290374fbeaba4f9169f393b7d1d554cefbb53af..9825fa6456b0df3818d4541d3a04ed132da85ea9 100644 |
--- a/chrome/browser/sync/profile_sync_service_harness.cc |
+++ b/chrome/browser/sync/profile_sync_service_harness.cc |
@@ -20,6 +20,7 @@ |
#include "base/logging.h" |
#include "base/memory/ref_counted.h" |
#include "base/message_loop.h" |
+#include "chrome/browser/p2p_invalidation_service.h" |
#include "chrome/browser/profiles/profile.h" |
#include "chrome/browser/signin/signin_manager.h" |
#include "chrome/browser/sync/about_sync_util.h" |
@@ -101,17 +102,20 @@ bool StateChangeTimeoutEvent::Abort() { |
ProfileSyncServiceHarness::ProfileSyncServiceHarness( |
Profile* profile, |
+ P2PInvalidationService* p2p_invalidation_service, |
const std::string& username, |
const std::string& password) |
: 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), |
profile_debug_name_(profile->GetDebugName()), |
waiting_for_status_change_(false) { |
+ DCHECK(p2p_invalidation_service); |
if (IsSyncAlreadySetup()) { |
service_ = ProfileSyncServiceFactory::GetInstance()->GetForProfile( |
profile_); |
@@ -128,13 +132,16 @@ ProfileSyncServiceHarness::~ProfileSyncServiceHarness() { |
// static |
ProfileSyncServiceHarness* ProfileSyncServiceHarness::CreateAndAttach( |
- Profile* profile) { |
+ Profile* profile, P2PInvalidationService *p2p_invalidation_service) { |
ProfileSyncServiceFactory* f = ProfileSyncServiceFactory::GetInstance(); |
if (!f->HasProfileSyncService(profile)) { |
NOTREACHED() << "Profile has never signed into sync."; |
return NULL; |
} |
- return new ProfileSyncServiceHarness(profile, "", ""); |
+ return new ProfileSyncServiceHarness(profile, |
+ p2p_invalidation_service, |
+ "", |
+ ""); |
} |
void ProfileSyncServiceHarness::SetCredentials(const std::string& username, |
@@ -464,6 +471,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) { |
+ const syncer::ObjectIdInvalidationMap& invalidation_map = |
+ ModelTypeInvalidationMapToObjectIdInvalidationMap( |
+ snap.source().types); |
+ p2p_invalidation_service_->SendInvalidation(invalidation_map); |
+ } |
+ |
+ OnStateChanged(); |
+} |
+ |
void ProfileSyncServiceHarness::OnMigrationStateChange() { |
// Update migration state. |
if (HasPendingBackendMigration()) { |