diff options
Diffstat (limited to 'sync/notifier')
22 files changed, 95 insertions, 102 deletions
diff --git a/sync/notifier/fake_invalidation_state_tracker.cc b/sync/notifier/fake_invalidation_state_tracker.cc index a228922..6e147fe 100644 --- a/sync/notifier/fake_invalidation_state_tracker.cc +++ b/sync/notifier/fake_invalidation_state_tracker.cc @@ -49,6 +49,7 @@ void FakeInvalidationStateTracker::Forget(const ObjectIdSet& ids) { void FakeInvalidationStateTracker::SetInvalidatorClientId( const std::string& client_id) { + Clear(); invalidator_client_id_ = client_id; } @@ -65,6 +66,12 @@ std::string FakeInvalidationStateTracker::GetBootstrapData() const { return bootstrap_data_; } +void FakeInvalidationStateTracker::Clear() { + invalidator_client_id_ = ""; + state_map_ = InvalidationStateMap(); + bootstrap_data_ = ""; +} + void FakeInvalidationStateTracker::GenerateAckHandles( const ObjectIdSet& ids, const scoped_refptr<base::TaskRunner>& task_runner, diff --git a/sync/notifier/fake_invalidation_state_tracker.h b/sync/notifier/fake_invalidation_state_tracker.h index 79606ee..b43699b 100644 --- a/sync/notifier/fake_invalidation_state_tracker.h +++ b/sync/notifier/fake_invalidation_state_tracker.h @@ -31,6 +31,7 @@ class FakeInvalidationStateTracker virtual std::string GetInvalidatorClientId() const OVERRIDE; virtual void SetBootstrapData(const std::string& data) OVERRIDE; virtual std::string GetBootstrapData() const OVERRIDE; + virtual void Clear() OVERRIDE; virtual void GenerateAckHandles( const ObjectIdSet& ids, const scoped_refptr<base::TaskRunner>& task_runner, diff --git a/sync/notifier/fake_invalidator.cc b/sync/notifier/fake_invalidator.cc index c8216af..088d239 100644 --- a/sync/notifier/fake_invalidator.cc +++ b/sync/notifier/fake_invalidator.cc @@ -19,10 +19,6 @@ ObjectIdSet FakeInvalidator::GetRegisteredIds( return registrar_.GetRegisteredIds(handler); } -const std::string& FakeInvalidator::GetUniqueId() const { - return unique_id_; -} - const std::string& FakeInvalidator::GetCredentialsEmail() const { return email_; } @@ -67,10 +63,6 @@ InvalidatorState FakeInvalidator::GetInvalidatorState() const { return registrar_.GetInvalidatorState(); } -void FakeInvalidator::SetUniqueId(const std::string& unique_id) { - unique_id_ = unique_id; -} - void FakeInvalidator::UpdateCredentials( const std::string& email, const std::string& token) { email_ = email; diff --git a/sync/notifier/fake_invalidator.h b/sync/notifier/fake_invalidator.h index e20fcc0..87380d0 100644 --- a/sync/notifier/fake_invalidator.h +++ b/sync/notifier/fake_invalidator.h @@ -37,7 +37,6 @@ class FakeInvalidator : public Invalidator { virtual void Acknowledge(const invalidation::ObjectId& id, const AckHandle& ack_handle) OVERRIDE; virtual InvalidatorState GetInvalidatorState() const OVERRIDE; - virtual void SetUniqueId(const std::string& unique_id) OVERRIDE; virtual void UpdateCredentials( const std::string& email, const std::string& token) OVERRIDE; virtual void SendInvalidation( @@ -45,7 +44,6 @@ class FakeInvalidator : public Invalidator { private: InvalidatorRegistrar registrar_; - std::string unique_id_; std::string state_; std::string email_; std::string token_; diff --git a/sync/notifier/fake_invalidator_unittest.cc b/sync/notifier/fake_invalidator_unittest.cc index de1bb71..d8cae84 100644 --- a/sync/notifier/fake_invalidator_unittest.cc +++ b/sync/notifier/fake_invalidator_unittest.cc @@ -21,6 +21,7 @@ class FakeInvalidatorTestDelegate { } void CreateInvalidator( + const std::string& invalidator_client_id, const std::string& initial_state, const base::WeakPtr<InvalidationStateTracker>& invalidation_state_tracker) { diff --git a/sync/notifier/invalidation_notifier.cc b/sync/notifier/invalidation_notifier.cc index 30e5df3..695705c 100644 --- a/sync/notifier/invalidation_notifier.cc +++ b/sync/notifier/invalidation_notifier.cc @@ -19,6 +19,7 @@ namespace syncer { InvalidationNotifier::InvalidationNotifier( scoped_ptr<notifier::PushClient> push_client, + const std::string& invalidator_client_id, const InvalidationStateMap& initial_invalidation_state_map, const std::string& invalidation_bootstrap_data, const WeakHandle<InvalidationStateTracker>& invalidation_state_tracker, @@ -27,6 +28,7 @@ InvalidationNotifier::InvalidationNotifier( initial_invalidation_state_map_(initial_invalidation_state_map), invalidation_state_tracker_(invalidation_state_tracker), client_info_(client_info), + invalidator_client_id_(invalidator_client_id), invalidation_bootstrap_data_(invalidation_bootstrap_data), invalidation_listener_(&tick_clock_, push_client.Pass()) { } @@ -63,19 +65,12 @@ InvalidatorState InvalidationNotifier::GetInvalidatorState() const { return registrar_.GetInvalidatorState(); } -void InvalidationNotifier::SetUniqueId(const std::string& unique_id) { - DCHECK(CalledOnValidThread()); - client_id_ = unique_id; - DVLOG(1) << "Setting unique ID to " << unique_id; - CHECK(!client_id_.empty()); -} - void InvalidationNotifier::UpdateCredentials( const std::string& email, const std::string& token) { if (state_ == STOPPED) { invalidation_listener_.Start( base::Bind(&invalidation::CreateInvalidationClient), - client_id_, client_info_, invalidation_bootstrap_data_, + invalidator_client_id_, client_info_, invalidation_bootstrap_data_, initial_invalidation_state_map_, invalidation_state_tracker_, this); diff --git a/sync/notifier/invalidation_notifier.h b/sync/notifier/invalidation_notifier.h index 602ba73..269511f 100644 --- a/sync/notifier/invalidation_notifier.h +++ b/sync/notifier/invalidation_notifier.h @@ -43,6 +43,7 @@ class SYNC_EXPORT_PRIVATE InvalidationNotifier // |invalidation_state_tracker| must be initialized. InvalidationNotifier( scoped_ptr<notifier::PushClient> push_client, + const std::string& invalidator_client_id, const InvalidationStateMap& initial_invalidation_state_map, const std::string& invalidation_bootstrap_data, const WeakHandle<InvalidationStateTracker>& @@ -59,7 +60,6 @@ class SYNC_EXPORT_PRIVATE InvalidationNotifier virtual void Acknowledge(const invalidation::ObjectId& id, const AckHandle& ack_handle) OVERRIDE; virtual InvalidatorState GetInvalidatorState() const OVERRIDE; - virtual void SetUniqueId(const std::string& unique_id) OVERRIDE; virtual void UpdateCredentials( const std::string& email, const std::string& token) OVERRIDE; virtual void SendInvalidation( @@ -95,7 +95,7 @@ class SYNC_EXPORT_PRIVATE InvalidationNotifier const std::string client_info_; // The client ID to pass to |invalidation_listener_|. - std::string client_id_; + const std::string invalidator_client_id_; // The initial bootstrap data to pass to |invalidation_listener_|. const std::string invalidation_bootstrap_data_; diff --git a/sync/notifier/invalidation_notifier_unittest.cc b/sync/notifier/invalidation_notifier_unittest.cc index b1856ba..6bb9276 100644 --- a/sync/notifier/invalidation_notifier_unittest.cc +++ b/sync/notifier/invalidation_notifier_unittest.cc @@ -33,6 +33,7 @@ class InvalidationNotifierTestDelegate { } void CreateInvalidator( + const std::string& invalidator_client_id, const std::string& initial_state, const base::WeakPtr<InvalidationStateTracker>& invalidation_state_tracker) { @@ -40,6 +41,7 @@ class InvalidationNotifierTestDelegate { invalidator_.reset( new InvalidationNotifier( scoped_ptr<notifier::PushClient>(new notifier::FakePushClient()), + invalidator_client_id, InvalidationStateMap(), initial_state, MakeWeakHandle(invalidation_state_tracker), diff --git a/sync/notifier/invalidation_state_tracker.h b/sync/notifier/invalidation_state_tracker.h index 58a5bc8..e3e5bd2 100644 --- a/sync/notifier/invalidation_state_tracker.h +++ b/sync/notifier/invalidation_state_tracker.h @@ -75,6 +75,9 @@ class InvalidationStateTracker { virtual void SetBootstrapData(const std::string& data) = 0; virtual std::string GetBootstrapData() const = 0; + // Erases invalidation versions, client ID, and state stored on disk. + virtual void Clear() = 0; + // Used for generating our own local ack handles. Generates a new ack handle // for each object id in |ids|. The result is returned via |callback| posted // to |task_runner|. diff --git a/sync/notifier/invalidator.h b/sync/notifier/invalidator.h index 7854b28..a0f881e 100644 --- a/sync/notifier/invalidator.h +++ b/sync/notifier/invalidator.h @@ -78,11 +78,6 @@ class SYNC_EXPORT Invalidator { // the updated state. virtual InvalidatorState GetInvalidatorState() const = 0; - // SetUniqueId must be called once, before any call to - // UpdateCredentials. |unique_id| should be a non-empty globally - // unique string. - virtual void SetUniqueId(const std::string& unique_id) = 0; - // The observers won't be notified of any notifications until // UpdateCredentials is called at least once. It can be called more than // once. diff --git a/sync/notifier/invalidator_factory.cc b/sync/notifier/invalidator_factory.cc index 3f09f5f..f359ce8 100644 --- a/sync/notifier/invalidator_factory.cc +++ b/sync/notifier/invalidator_factory.cc @@ -6,7 +6,9 @@ #include <string> +#include "base/base64.h" #include "base/logging.h" +#include "base/rand_util.h" #include "jingle/notifier/listener/push_client.h" #include "sync/notifier/invalidator.h" #include "sync/notifier/non_blocking_invalidator.h" @@ -17,6 +19,7 @@ namespace { Invalidator* CreateDefaultInvalidator( const notifier::NotifierOptions& notifier_options, + const std::string& invalidator_client_id, const InvalidationStateMap& initial_invalidation_state_map, const std::string& invalidation_bootstrap_data, const WeakHandle<InvalidationStateTracker>& invalidation_state_tracker, @@ -28,14 +31,24 @@ Invalidator* CreateDefaultInvalidator( // on this behaviour. See crbug.com/97780. return new P2PInvalidator( notifier::PushClient::CreateDefault(notifier_options), + invalidator_client_id, NOTIFY_ALL); } return new NonBlockingInvalidator( - notifier_options, initial_invalidation_state_map, + notifier_options, invalidator_client_id, initial_invalidation_state_map, invalidation_bootstrap_data, invalidation_state_tracker, client_info); } +std::string GenerateInvalidatorClientId() { + // Generate a GUID with 128 bits worth of base64-encoded randomness. + // This format is similar to that of sync's cache_guid. + const int kGuidBytes = 128 / 8; + std::string guid; + base::Base64Encode(base::RandBytesAsString(kGuidBytes), &guid); + return guid; +} + } // namespace // TODO(akalin): Remove the dependency on jingle if OS_ANDROID is defined. @@ -45,16 +58,28 @@ InvalidatorFactory::InvalidatorFactory( const base::WeakPtr<InvalidationStateTracker>& invalidation_state_tracker) : notifier_options_(notifier_options), - client_info_(client_info), - initial_invalidation_state_map_( - invalidation_state_tracker.get() ? - invalidation_state_tracker->GetAllInvalidationStates() : - InvalidationStateMap()), - invalidation_bootstrap_data_( - invalidation_state_tracker.get() ? - invalidation_state_tracker->GetBootstrapData() : - std::string()), - invalidation_state_tracker_(invalidation_state_tracker) { + client_info_(client_info) { + if (!invalidation_state_tracker.get()) { + return; + } + + // TODO(rlarocque): This is not the most obvious place for client ID + // generation code. We should try to find a better place for it when we + // refactor the invalidator into its own service. + if (invalidation_state_tracker->GetInvalidatorClientId().empty()) { + // This also clears any existing state. We can't reuse old invalidator + // state with the new ID anyway. + invalidation_state_tracker->SetInvalidatorClientId( + GenerateInvalidatorClientId()); + } + + initial_invalidation_state_map_ = + invalidation_state_tracker->GetAllInvalidationStates(); + invalidator_client_id_ = + invalidation_state_tracker->GetInvalidatorClientId(); + invalidation_bootstrap_data_ = invalidation_state_tracker->GetBootstrapData(); + invalidation_state_tracker_ = WeakHandle<InvalidationStateTracker>( + invalidation_state_tracker); } InvalidatorFactory::~InvalidatorFactory() { @@ -67,10 +92,16 @@ Invalidator* InvalidatorFactory::CreateInvalidator() { return NULL; #else return CreateDefaultInvalidator(notifier_options_, + invalidator_client_id_, initial_invalidation_state_map_, invalidation_bootstrap_data_, invalidation_state_tracker_, client_info_); #endif } + +std::string InvalidatorFactory::GetInvalidatorClientId() const { + return invalidator_client_id_; +} + } // namespace syncer diff --git a/sync/notifier/invalidator_factory.h b/sync/notifier/invalidator_factory.h index f7bd3e0..782850e 100644 --- a/sync/notifier/invalidator_factory.h +++ b/sync/notifier/invalidator_factory.h @@ -36,13 +36,18 @@ class SYNC_EXPORT InvalidatorFactory { // factory from which it was created. Can be called on any thread. Invalidator* CreateInvalidator(); + // Returns the unique ID that was (or will be) passed to the invalidator. + std::string GetInvalidatorClientId() const; + private: const notifier::NotifierOptions notifier_options_; + + // Some of these should be const, but can't be set up in member initializers. + InvalidationStateMap initial_invalidation_state_map_; const std::string client_info_; - const InvalidationStateMap initial_invalidation_state_map_; - const std::string invalidation_bootstrap_data_; - const WeakHandle<InvalidationStateTracker> - invalidation_state_tracker_; + std::string invalidator_client_id_; + std::string invalidation_bootstrap_data_; + WeakHandle<InvalidationStateTracker> invalidation_state_tracker_; }; } // namespace syncer diff --git a/sync/notifier/invalidator_registrar_unittest.cc b/sync/notifier/invalidator_registrar_unittest.cc index fe4b409..070c134 100644 --- a/sync/notifier/invalidator_registrar_unittest.cc +++ b/sync/notifier/invalidator_registrar_unittest.cc @@ -52,10 +52,6 @@ class RegistrarInvalidator : public Invalidator { return registrar_.GetInvalidatorState(); } - virtual void SetUniqueId(const std::string& unique_id) OVERRIDE { - // Do nothing. - } - virtual void UpdateCredentials( const std::string& email, const std::string& token) OVERRIDE { // Do nothing. @@ -81,6 +77,7 @@ class RegistrarInvalidatorTestDelegate { } void CreateInvalidator( + const std::string& invalidator_client_id, const std::string& initial_state, const base::WeakPtr<InvalidationStateTracker>& invalidation_state_tracker) { diff --git a/sync/notifier/invalidator_test_template.h b/sync/notifier/invalidator_test_template.h index 72d8c63..0353000 100644 --- a/sync/notifier/invalidator_test_template.h +++ b/sync/notifier/invalidator_test_template.h @@ -101,11 +101,11 @@ class InvalidatorTest : public testing::Test { } Invalidator* CreateAndInitializeInvalidator() { - this->delegate_.CreateInvalidator("fake_initial_state", + this->delegate_.CreateInvalidator("fake_invalidator_client_id", + "fake_initial_state", this->fake_tracker_.AsWeakPtr()); Invalidator* const invalidator = this->delegate_.GetInvalidator(); - invalidator->SetUniqueId("fake_id"); this->delegate_.WaitForInvalidator(); invalidator->UpdateCredentials("foo@bar.com", "fake_token"); this->delegate_.WaitForInvalidator(); diff --git a/sync/notifier/non_blocking_invalidator.cc b/sync/notifier/non_blocking_invalidator.cc index 32ffd9e..d366e31 100644 --- a/sync/notifier/non_blocking_invalidator.cc +++ b/sync/notifier/non_blocking_invalidator.cc @@ -30,6 +30,7 @@ class NonBlockingInvalidator::Core // Helpers called on I/O thread. void Initialize( const notifier::NotifierOptions& notifier_options, + const std::string& invalidator_client_id, const InvalidationStateMap& initial_invalidation_state_map, const std::string& invalidation_bootstrap_data, const WeakHandle<InvalidationStateTracker>& invalidation_state_tracker, @@ -38,7 +39,6 @@ class NonBlockingInvalidator::Core void UpdateRegisteredIds(const ObjectIdSet& ids); void Acknowledge(const invalidation::ObjectId& id, const AckHandle& ack_handle); - void SetUniqueId(const std::string& unique_id); void UpdateCredentials(const std::string& email, const std::string& token); // InvalidationHandler implementation (all called on I/O thread by @@ -72,6 +72,7 @@ NonBlockingInvalidator::Core::~Core() { void NonBlockingInvalidator::Core::Initialize( const notifier::NotifierOptions& notifier_options, + const std::string& invalidator_client_id, const InvalidationStateMap& initial_invalidation_state_map, const std::string& invalidation_bootstrap_data, const WeakHandle<InvalidationStateTracker>& invalidation_state_tracker, @@ -85,6 +86,7 @@ void NonBlockingInvalidator::Core::Initialize( invalidation_notifier_.reset( new InvalidationNotifier( notifier::PushClient::CreateDefaultOnIOThread(notifier_options), + invalidator_client_id, initial_invalidation_state_map, invalidation_bootstrap_data, invalidation_state_tracker, @@ -110,11 +112,6 @@ void NonBlockingInvalidator::Core::Acknowledge(const invalidation::ObjectId& id, invalidation_notifier_->Acknowledge(id, ack_handle); } -void NonBlockingInvalidator::Core::SetUniqueId(const std::string& unique_id) { - DCHECK(network_task_runner_->BelongsToCurrentThread()); - invalidation_notifier_->SetUniqueId(unique_id); -} - void NonBlockingInvalidator::Core::UpdateCredentials(const std::string& email, const std::string& token) { DCHECK(network_task_runner_->BelongsToCurrentThread()); @@ -138,6 +135,7 @@ void NonBlockingInvalidator::Core::OnIncomingInvalidation( NonBlockingInvalidator::NonBlockingInvalidator( const notifier::NotifierOptions& notifier_options, + const std::string& invalidator_client_id, const InvalidationStateMap& initial_invalidation_state_map, const std::string& invalidation_bootstrap_data, const WeakHandle<InvalidationStateTracker>& @@ -156,6 +154,7 @@ NonBlockingInvalidator::NonBlockingInvalidator( &NonBlockingInvalidator::Core::Initialize, core_.get(), notifier_options, + invalidator_client_id, initial_invalidation_state_map, invalidation_bootstrap_data, invalidation_state_tracker, @@ -217,16 +216,6 @@ InvalidatorState NonBlockingInvalidator::GetInvalidatorState() const { return registrar_.GetInvalidatorState(); } -void NonBlockingInvalidator::SetUniqueId(const std::string& unique_id) { - DCHECK(parent_task_runner_->BelongsToCurrentThread()); - if (!network_task_runner_->PostTask( - FROM_HERE, - base::Bind(&NonBlockingInvalidator::Core::SetUniqueId, - core_.get(), unique_id))) { - NOTREACHED(); - } -} - void NonBlockingInvalidator::UpdateCredentials(const std::string& email, const std::string& token) { DCHECK(parent_task_runner_->BelongsToCurrentThread()); diff --git a/sync/notifier/non_blocking_invalidator.h b/sync/notifier/non_blocking_invalidator.h index 0da2e4c1..9c366fe 100644 --- a/sync/notifier/non_blocking_invalidator.h +++ b/sync/notifier/non_blocking_invalidator.h @@ -38,6 +38,7 @@ class SYNC_EXPORT_PRIVATE NonBlockingInvalidator // |invalidation_state_tracker| must be initialized. NonBlockingInvalidator( const notifier::NotifierOptions& notifier_options, + const std::string& invalidator_client_id, const InvalidationStateMap& initial_invalidation_state_map, const std::string& invalidation_bootstrap_data, const WeakHandle<InvalidationStateTracker>& @@ -54,7 +55,6 @@ class SYNC_EXPORT_PRIVATE NonBlockingInvalidator virtual void Acknowledge(const invalidation::ObjectId& id, const AckHandle& ack_handle) OVERRIDE; virtual InvalidatorState GetInvalidatorState() const OVERRIDE; - virtual void SetUniqueId(const std::string& unique_id) OVERRIDE; virtual void UpdateCredentials( const std::string& email, const std::string& token) OVERRIDE; virtual void SendInvalidation( diff --git a/sync/notifier/non_blocking_invalidator_unittest.cc b/sync/notifier/non_blocking_invalidator_unittest.cc index 0a38fb3..a143aca 100644 --- a/sync/notifier/non_blocking_invalidator_unittest.cc +++ b/sync/notifier/non_blocking_invalidator_unittest.cc @@ -33,6 +33,7 @@ class NonBlockingInvalidatorTestDelegate { } void CreateInvalidator( + const std::string& invalidator_client_id, const std::string& initial_state, const base::WeakPtr<InvalidationStateTracker>& invalidation_state_tracker) { @@ -47,6 +48,7 @@ class NonBlockingInvalidatorTestDelegate { invalidator_.reset( new NonBlockingInvalidator( invalidator_options, + invalidator_client_id, InvalidationStateMap(), initial_state, MakeWeakHandle(invalidation_state_tracker), diff --git a/sync/notifier/p2p_invalidator.cc b/sync/notifier/p2p_invalidator.cc index e71d1e3c..dd9a34d 100644 --- a/sync/notifier/p2p_invalidator.cc +++ b/sync/notifier/p2p_invalidator.cc @@ -137,8 +137,10 @@ bool P2PNotificationData::ResetFromString(const std::string& str) { } P2PInvalidator::P2PInvalidator(scoped_ptr<notifier::PushClient> push_client, + const std::string& invalidator_client_id, P2PNotificationTarget send_notification_target) : push_client_(push_client.Pass()), + invalidator_client_id_(invalidator_client_id), logged_in_(false), notifications_enabled_(false), send_notification_target_(send_notification_target) { @@ -169,7 +171,8 @@ void P2PInvalidator::UpdateRegisteredIds(InvalidationHandler* handler, ObjectIdLessThan()); registrar_.UpdateRegisteredIds(handler, ids); const P2PNotificationData notification_data( - unique_id_, NOTIFY_SELF, ObjectIdSetToInvalidationMap(new_ids, "")); + invalidator_client_id_, NOTIFY_SELF, + ObjectIdSetToInvalidationMap(new_ids, "")); SendNotificationData(notification_data); } @@ -189,11 +192,6 @@ InvalidatorState P2PInvalidator::GetInvalidatorState() const { return registrar_.GetInvalidatorState(); } -void P2PInvalidator::SetUniqueId(const std::string& unique_id) { - DCHECK(thread_checker_.CalledOnValidThread()); - unique_id_ = unique_id; -} - void P2PInvalidator::UpdateCredentials( const std::string& email, const std::string& token) { DCHECK(thread_checker_.CalledOnValidThread()); @@ -215,7 +213,7 @@ void P2PInvalidator::SendInvalidation( const ObjectIdInvalidationMap& invalidation_map) { DCHECK(thread_checker_.CalledOnValidThread()); const P2PNotificationData notification_data( - unique_id_, send_notification_target_, invalidation_map); + invalidator_client_id_, send_notification_target_, invalidation_map); SendNotificationData(notification_data); } @@ -226,7 +224,7 @@ void P2PInvalidator::OnNotificationsEnabled() { registrar_.UpdateInvalidatorState(INVALIDATIONS_ENABLED); if (just_turned_on) { const P2PNotificationData notification_data( - unique_id_, NOTIFY_SELF, + invalidator_client_id_, NOTIFY_SELF, ObjectIdSetToInvalidationMap(registrar_.GetAllRegisteredIds(), "")); SendNotificationData(notification_data); } @@ -260,10 +258,10 @@ void P2PInvalidator::OnIncomingNotification( << notification.data; notification_data = P2PNotificationData( - unique_id_, NOTIFY_ALL, + invalidator_client_id_, NOTIFY_ALL, ObjectIdSetToInvalidationMap(registrar_.GetAllRegisteredIds(), "")); } - if (!notification_data.IsTargeted(unique_id_)) { + if (!notification_data.IsTargeted(invalidator_client_id_)) { DVLOG(1) << "Not a target of the notification -- " << "not emitting notification"; return; diff --git a/sync/notifier/p2p_invalidator.h b/sync/notifier/p2p_invalidator.h index 952299f..a56521e 100644 --- a/sync/notifier/p2p_invalidator.h +++ b/sync/notifier/p2p_invalidator.h @@ -93,6 +93,7 @@ class SYNC_EXPORT_PRIVATE P2PInvalidator // to send notifications to all clients except for the one that triggered the // notification. See crbug.com/97780. P2PInvalidator(scoped_ptr<notifier::PushClient> push_client, + const std::string& invalidator_client_id, P2PNotificationTarget send_notification_target); virtual ~P2PInvalidator(); @@ -105,7 +106,6 @@ class SYNC_EXPORT_PRIVATE P2PInvalidator virtual void Acknowledge(const invalidation::ObjectId& id, const AckHandle& ack_handle) OVERRIDE; virtual InvalidatorState GetInvalidatorState() const OVERRIDE; - virtual void SetUniqueId(const std::string& unique_id) OVERRIDE; virtual void UpdateCredentials( const std::string& email, const std::string& token) OVERRIDE; virtual void SendInvalidation( @@ -131,7 +131,7 @@ class SYNC_EXPORT_PRIVATE P2PInvalidator // The push client. scoped_ptr<notifier::PushClient> push_client_; // Our unique ID. - std::string unique_id_; + std::string invalidator_client_id_; // Whether we have called UpdateCredentials() yet. bool logged_in_; bool notifications_enabled_; diff --git a/sync/notifier/p2p_invalidator_unittest.cc b/sync/notifier/p2p_invalidator_unittest.cc index 31a180e0..1b7aad4 100644 --- a/sync/notifier/p2p_invalidator_unittest.cc +++ b/sync/notifier/p2p_invalidator_unittest.cc @@ -27,6 +27,7 @@ class P2PInvalidatorTestDelegate { } void CreateInvalidator( + const std::string& invalidator_client_id, const std::string& initial_state, const base::WeakPtr<InvalidationStateTracker>& invalidation_state_tracker) { @@ -36,6 +37,7 @@ class P2PInvalidatorTestDelegate { invalidator_.reset( new P2PInvalidator( scoped_ptr<notifier::PushClient>(fake_push_client_), + invalidator_client_id, NOTIFY_OTHERS)); } @@ -84,7 +86,8 @@ class P2PInvalidatorTest : public testing::Test { protected: P2PInvalidatorTest() : next_sent_notification_to_reflect_(0) { - delegate_.CreateInvalidator("fake_state", + delegate_.CreateInvalidator("sender", + "fake_state", base::WeakPtr<InvalidationStateTracker>()); delegate_.GetInvalidator()->RegisterHandler(&fake_handler_); } @@ -214,8 +217,6 @@ TEST_F(P2PInvalidatorTest, NotificationsBasic) { invalidator->UpdateRegisteredIds(&fake_handler_, ModelTypeSetToObjectIdSet(enabled_types)); - invalidator->SetUniqueId("sender"); - const char kEmail[] = "foo@bar.com"; const char kToken[] = "token"; invalidator->UpdateCredentials(kEmail, kToken); @@ -272,7 +273,6 @@ TEST_F(P2PInvalidatorTest, SendNotificationData) { invalidator->UpdateRegisteredIds(&fake_handler_, ModelTypeSetToObjectIdSet(enabled_types)); - invalidator->SetUniqueId("sender"); invalidator->UpdateCredentials("foo@bar.com", "fake_token"); ReflectSentNotifications(); diff --git a/sync/notifier/sync_invalidation_listener.cc b/sync/notifier/sync_invalidation_listener.cc index d4af589..44faac5 100644 --- a/sync/notifier/sync_invalidation_listener.cc +++ b/sync/notifier/sync_invalidation_listener.cc @@ -103,16 +103,6 @@ void SyncInvalidationListener::Start( registration_manager_.reset( new RegistrationManager(invalidation_client_.get())); - // TODO(rlarocque): This call exists as part of an effort to move the - // invalidator's ID out of sync. It writes the provided (sync-managed) ID to - // storage that lives on the UI thread. Once this has been in place for a - // milestone or two, we can remove it and start looking for invalidator client - // IDs exclusively in the InvalidationStateTracker. See crbug.com/124142. - invalidation_state_tracker_.Call( - FROM_HERE, - &InvalidationStateTracker::SetInvalidatorClientId, - client_id); - // Set up reminders for any invalidations that have not been locally // acknowledged. ObjectIdSet unacknowledged_ids; diff --git a/sync/notifier/sync_invalidation_listener_unittest.cc b/sync/notifier/sync_invalidation_listener_unittest.cc index 44c1725..8177327 100644 --- a/sync/notifier/sync_invalidation_listener_unittest.cc +++ b/sync/notifier/sync_invalidation_listener_unittest.cc @@ -277,11 +277,6 @@ class SyncInvalidationListenerTest : public testing::Test { MakeWeakHandle(fake_tracker_.AsWeakPtr()), &fake_delegate_); DCHECK(fake_invalidation_client_); - - // TODO(rlarocque): This is necessary for the deferred write of the client - // ID to take place. We can remove this statement when we remove the - // WriteInvalidatorClientId test. See crbug.com/124142. - message_loop_.RunUntilIdle(); } void StopClient() { @@ -424,14 +419,6 @@ class SyncInvalidationListenerTest : public testing::Test { FakeDelegate fake_delegate_; }; -// Verify the client ID is written to the state tracker on client start. -// TODO(rlarocque): Remove this test when migration code is removed. -// See crbug.com/124142. -TEST_F(SyncInvalidationListenerTest, WriteInvalidatorClientId) { - // The client is started by the harness, so we don't have to do anything here. - EXPECT_EQ(kClientId, GetInvalidatorClientId()); -} - // Write a new state to the client. It should propagate to the // tracker. TEST_F(SyncInvalidationListenerTest, WriteState) { |