diff options
author | akalin@chromium.org <akalin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-09-06 03:06:13 +0000 |
---|---|---|
committer | akalin@chromium.org <akalin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-09-06 03:06:13 +0000 |
commit | 1f7893fa86a8e84abbc460dca12c87346bb2d758 (patch) | |
tree | c1eaf9751541304bcaf0bc16e7124ff72e5ee07b /sync | |
parent | eef1ea503196e51ccf67d69b271c3d715363497d (diff) | |
download | chromium_src-1f7893fa86a8e84abbc460dca12c87346bb2d758.zip chromium_src-1f7893fa86a8e84abbc460dca12c87346bb2d758.tar.gz chromium_src-1f7893fa86a8e84abbc460dca12c87346bb2d758.tar.bz2 |
[Sync] Rename classes in sync/ that start with Chrome
There should be as few references as possible to Chrome from sync/.
BUG=
Review URL: https://chromiumcodereview.appspot.com/10907070
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@155110 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'sync')
-rw-r--r-- | sync/notifier/invalidation_notifier.cc | 14 | ||||
-rw-r--r-- | sync/notifier/invalidation_notifier.h | 22 | ||||
-rw-r--r-- | sync/notifier/sync_invalidation_listener.cc (renamed from sync/notifier/chrome_invalidation_client.cc) | 86 | ||||
-rw-r--r-- | sync/notifier/sync_invalidation_listener.h (renamed from sync/notifier/chrome_invalidation_client.h) | 32 | ||||
-rw-r--r-- | sync/notifier/sync_invalidation_listener_unittest.cc (renamed from sync/notifier/chrome_invalidation_client_unittest.cc) | 80 | ||||
-rw-r--r-- | sync/notifier/sync_system_resources.cc (renamed from sync/notifier/chrome_system_resources.cc) | 95 | ||||
-rw-r--r-- | sync/notifier/sync_system_resources.h (renamed from sync/notifier/chrome_system_resources.h) | 50 | ||||
-rw-r--r-- | sync/notifier/sync_system_resources_unittest.cc (renamed from sync/notifier/chrome_system_resources_unittest.cc) | 76 | ||||
-rw-r--r-- | sync/sync.gyp | 12 |
9 files changed, 233 insertions, 234 deletions
diff --git a/sync/notifier/invalidation_notifier.cc b/sync/notifier/invalidation_notifier.cc index 167b0ba..81a268b 100644 --- a/sync/notifier/invalidation_notifier.cc +++ b/sync/notifier/invalidation_notifier.cc @@ -28,7 +28,7 @@ InvalidationNotifier::InvalidationNotifier( invalidation_state_tracker_(invalidation_state_tracker), client_info_(client_info), invalidation_state_(initial_invalidation_state), - invalidation_client_(push_client.Pass()) { + invalidation_listener_(push_client.Pass()) { } InvalidationNotifier::~InvalidationNotifier() { @@ -44,7 +44,7 @@ void InvalidationNotifier::UpdateRegisteredIds(InvalidationHandler* handler, const ObjectIdSet& ids) { DCHECK(CalledOnValidThread()); registrar_.UpdateRegisteredIds(handler, ids); - invalidation_client_.UpdateRegisteredIds(registrar_.GetAllRegisteredIds()); + invalidation_listener_.UpdateRegisteredIds(registrar_.GetAllRegisteredIds()); } void InvalidationNotifier::UnregisterHandler(InvalidationHandler* handler) { @@ -54,9 +54,9 @@ void InvalidationNotifier::UnregisterHandler(InvalidationHandler* handler) { void InvalidationNotifier::SetUniqueId(const std::string& unique_id) { DCHECK(CalledOnValidThread()); - invalidation_client_id_ = unique_id; + client_id_ = unique_id; DVLOG(1) << "Setting unique ID to " << unique_id; - CHECK(!invalidation_client_id_.empty()); + CHECK(!client_id_.empty()); } void InvalidationNotifier::SetStateDeprecated(const std::string& state) { @@ -82,16 +82,16 @@ void InvalidationNotifier::SetStateDeprecated(const std::string& state) { void InvalidationNotifier::UpdateCredentials( const std::string& email, const std::string& token) { if (state_ == STOPPED) { - invalidation_client_.Start( + invalidation_listener_.Start( base::Bind(&invalidation::CreateInvalidationClient), - invalidation_client_id_, client_info_, invalidation_state_, + client_id_, client_info_, invalidation_state_, initial_max_invalidation_versions_, invalidation_state_tracker_, this); invalidation_state_.clear(); state_ = STARTED; } - invalidation_client_.UpdateCredentials(email, token); + invalidation_listener_.UpdateCredentials(email, token); } void InvalidationNotifier::SendNotification( diff --git a/sync/notifier/invalidation_notifier.h b/sync/notifier/invalidation_notifier.h index 08b1095..789c30d 100644 --- a/sync/notifier/invalidation_notifier.h +++ b/sync/notifier/invalidation_notifier.h @@ -20,10 +20,10 @@ #include "base/threading/non_thread_safe.h" #include "sync/internal_api/public/base/model_type.h" #include "sync/internal_api/public/util/weak_handle.h" -#include "sync/notifier/chrome_invalidation_client.h" #include "sync/notifier/invalidation_state_tracker.h" #include "sync/notifier/invalidator.h" #include "sync/notifier/invalidator_registrar.h" +#include "sync/notifier/sync_invalidation_listener.h" namespace notifier { class PushClient; @@ -35,7 +35,7 @@ namespace syncer { // TODO(dcheng): Think of a name better than InvalidationInvalidator. class InvalidationNotifier : public Invalidator, - public ChromeInvalidationClient::Listener, + public SyncInvalidationListener::Delegate, public base::NonThreadSafe { public: // |invalidation_state_tracker| must be initialized. @@ -60,7 +60,7 @@ class InvalidationNotifier const std::string& email, const std::string& token) OVERRIDE; virtual void SendNotification(const ObjectIdStateMap& id_state_map) OVERRIDE; - // ChromeInvalidationClient::Listener implementation. + // SyncInvalidationListener::Delegate implementation. virtual void OnInvalidate(const ObjectIdStateMap& id_state_map) OVERRIDE; virtual void OnNotificationsEnabled() OVERRIDE; virtual void OnNotificationsDisabled( @@ -80,26 +80,26 @@ class InvalidationNotifier InvalidatorRegistrar registrar_; - // Passed to |invalidation_client_|. + // Passed to |invalidation_listener_|. const InvalidationVersionMap initial_max_invalidation_versions_; - // Passed to |invalidation_client_|. + // Passed to |invalidation_listener_|. const WeakHandle<InvalidationStateTracker> invalidation_state_tracker_; - // Passed to |invalidation_client_|. + // Passed to |invalidation_listener_|. const std::string client_info_; - // The client ID to pass to |chrome_invalidation_client_|. - std::string invalidation_client_id_; + // The client ID to pass to |invalidation_listener_|. + std::string client_id_; - // The state to pass to |chrome_invalidation_client_|. + // The state to pass to |invalidation_listener_|. // TODO(tim): This should be made const once migration is completed for bug // 124140. std::string invalidation_state_; - // The invalidation client. - ChromeInvalidationClient invalidation_client_; + // The invalidation listener. + SyncInvalidationListener invalidation_listener_; DISALLOW_COPY_AND_ASSIGN(InvalidationNotifier); }; diff --git a/sync/notifier/chrome_invalidation_client.cc b/sync/notifier/sync_invalidation_listener.cc index 938f7e6..b75b15c 100644 --- a/sync/notifier/chrome_invalidation_client.cc +++ b/sync/notifier/sync_invalidation_listener.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "sync/notifier/chrome_invalidation_client.h" +#include "sync/notifier/sync_invalidation_listener.h" #include <string> #include <vector> @@ -26,45 +26,45 @@ const char kApplicationName[] = "chrome-sync"; namespace syncer { -ChromeInvalidationClient::Listener::~Listener() {} +SyncInvalidationListener::Delegate::~Delegate() {} -ChromeInvalidationClient::ChromeInvalidationClient( +SyncInvalidationListener::SyncInvalidationListener( scoped_ptr<notifier::PushClient> push_client) : push_client_(push_client.get()), - chrome_system_resources_(push_client.Pass(), - ALLOW_THIS_IN_INITIALIZER_LIST(this)), - listener_(NULL), + sync_system_resources_(push_client.Pass(), + ALLOW_THIS_IN_INITIALIZER_LIST(this)), + delegate_(NULL), ticl_state_(DEFAULT_NOTIFICATION_ERROR), push_client_state_(DEFAULT_NOTIFICATION_ERROR) { DCHECK(CalledOnValidThread()); push_client_->AddObserver(this); } -ChromeInvalidationClient::~ChromeInvalidationClient() { +SyncInvalidationListener::~SyncInvalidationListener() { DCHECK(CalledOnValidThread()); push_client_->RemoveObserver(this); Stop(); - DCHECK(!listener_); + DCHECK(!delegate_); } -void ChromeInvalidationClient::Start( +void SyncInvalidationListener::Start( const CreateInvalidationClientCallback& create_invalidation_client_callback, const std::string& client_id, const std::string& client_info, const std::string& state, const InvalidationVersionMap& initial_max_invalidation_versions, const WeakHandle<InvalidationStateTracker>& invalidation_state_tracker, - Listener* listener) { + Delegate* delegate) { DCHECK(CalledOnValidThread()); Stop(); - chrome_system_resources_.set_platform(client_info); - chrome_system_resources_.Start(); + sync_system_resources_.set_platform(client_info); + sync_system_resources_.Start(); // The Storage resource is implemented as a write-through cache. We populate // it with the initial state on startup, so subsequent writes go to disk and // update the in-memory cache, while reads just return the cached state. - chrome_system_resources_.storage()->SetInitialState(state); + sync_system_resources_.storage()->SetInitialState(state); max_invalidation_versions_ = initial_max_invalidation_versions; if (max_invalidation_versions_.empty()) { @@ -81,14 +81,14 @@ void ChromeInvalidationClient::Start( invalidation_state_tracker_ = invalidation_state_tracker; DCHECK(invalidation_state_tracker_.IsInitialized()); - DCHECK(!listener_); - DCHECK(listener); - listener_ = listener; + DCHECK(!delegate_); + DCHECK(delegate); + delegate_ = delegate; int client_type = ipc::invalidation::ClientType::CHROME_SYNC; invalidation_client_.reset( create_invalidation_client_callback.Run( - &chrome_system_resources_, client_type, client_id, + &sync_system_resources_, client_type, client_id, kApplicationName, this)); invalidation_client_->Start(); @@ -96,13 +96,13 @@ void ChromeInvalidationClient::Start( new RegistrationManager(invalidation_client_.get())); } -void ChromeInvalidationClient::UpdateCredentials( +void SyncInvalidationListener::UpdateCredentials( const std::string& email, const std::string& token) { DCHECK(CalledOnValidThread()); - chrome_system_resources_.network()->UpdateCredentials(email, token); + sync_system_resources_.network()->UpdateCredentials(email, token); } -void ChromeInvalidationClient::UpdateRegisteredIds(const ObjectIdSet& ids) { +void SyncInvalidationListener::UpdateRegisteredIds(const ObjectIdSet& ids) { DCHECK(CalledOnValidThread()); registered_ids_ = ids; // |ticl_state_| can go to NO_NOTIFICATION_ERROR even without a @@ -113,7 +113,7 @@ void ChromeInvalidationClient::UpdateRegisteredIds(const ObjectIdSet& ids) { } } -void ChromeInvalidationClient::Ready( +void SyncInvalidationListener::Ready( invalidation::InvalidationClient* client) { DCHECK(CalledOnValidThread()); DCHECK_EQ(client, invalidation_client_.get()); @@ -122,7 +122,7 @@ void ChromeInvalidationClient::Ready( DoRegistrationUpdate(); } -void ChromeInvalidationClient::Invalidate( +void SyncInvalidationListener::Invalidate( invalidation::InvalidationClient* client, const invalidation::Invalidation& invalidation, const invalidation::AckHandle& ack_handle) { @@ -169,7 +169,7 @@ void ChromeInvalidationClient::Invalidate( client->Acknowledge(ack_handle); } -void ChromeInvalidationClient::InvalidateUnknownVersion( +void SyncInvalidationListener::InvalidateUnknownVersion( invalidation::InvalidationClient* client, const invalidation::ObjectId& object_id, const invalidation::AckHandle& ack_handle) { @@ -187,7 +187,7 @@ void ChromeInvalidationClient::InvalidateUnknownVersion( // This should behave as if we got an invalidation with version // UNKNOWN_OBJECT_VERSION for all known data types. -void ChromeInvalidationClient::InvalidateAll( +void SyncInvalidationListener::InvalidateAll( invalidation::InvalidationClient* client, const invalidation::AckHandle& ack_handle) { DCHECK(CalledOnValidThread()); @@ -205,13 +205,13 @@ void ChromeInvalidationClient::InvalidateAll( client->Acknowledge(ack_handle); } -void ChromeInvalidationClient::EmitInvalidation( +void SyncInvalidationListener::EmitInvalidation( const ObjectIdStateMap& id_state_map) { DCHECK(CalledOnValidThread()); - listener_->OnInvalidate(id_state_map); + delegate_->OnInvalidate(id_state_map); } -void ChromeInvalidationClient::InformRegistrationStatus( +void SyncInvalidationListener::InformRegistrationStatus( invalidation::InvalidationClient* client, const invalidation::ObjectId& object_id, InvalidationListener::RegistrationState new_state) { @@ -226,7 +226,7 @@ void ChromeInvalidationClient::InformRegistrationStatus( } } -void ChromeInvalidationClient::InformRegistrationFailure( +void SyncInvalidationListener::InformRegistrationFailure( invalidation::InvalidationClient* client, const invalidation::ObjectId& object_id, bool is_transient, @@ -255,7 +255,7 @@ void ChromeInvalidationClient::InformRegistrationFailure( } } -void ChromeInvalidationClient::ReissueRegistrations( +void SyncInvalidationListener::ReissueRegistrations( invalidation::InvalidationClient* client, const std::string& prefix, int prefix_length) { @@ -265,7 +265,7 @@ void ChromeInvalidationClient::ReissueRegistrations( registration_manager_->MarkAllRegistrationsLost(); } -void ChromeInvalidationClient::InformError( +void SyncInvalidationListener::InformError( invalidation::InvalidationClient* client, const invalidation::ErrorInfo& error_info) { DCHECK(CalledOnValidThread()); @@ -281,14 +281,14 @@ void ChromeInvalidationClient::InformError( EmitStateChange(); } -void ChromeInvalidationClient::WriteState(const std::string& state) { +void SyncInvalidationListener::WriteState(const std::string& state) { DCHECK(CalledOnValidThread()); DVLOG(1) << "WriteState"; invalidation_state_tracker_.Call( FROM_HERE, &InvalidationStateTracker::SetInvalidationState, state); } -void ChromeInvalidationClient::DoRegistrationUpdate() { +void SyncInvalidationListener::DoRegistrationUpdate() { DCHECK(CalledOnValidThread()); const ObjectIdSet& unregistered_ids = registration_manager_->UpdateRegisteredIds(registered_ids_); @@ -296,23 +296,23 @@ void ChromeInvalidationClient::DoRegistrationUpdate() { FROM_HERE, &InvalidationStateTracker::Forget, unregistered_ids); } -void ChromeInvalidationClient::StopForTest() { +void SyncInvalidationListener::StopForTest() { DCHECK(CalledOnValidThread()); Stop(); } -void ChromeInvalidationClient::Stop() { +void SyncInvalidationListener::Stop() { DCHECK(CalledOnValidThread()); if (!invalidation_client_.get()) { return; } registration_manager_.reset(); - chrome_system_resources_.Stop(); + sync_system_resources_.Stop(); invalidation_client_->Stop(); invalidation_client_.reset(); - listener_ = NULL; + delegate_ = NULL; invalidation_state_tracker_.Reset(); max_invalidation_versions_.clear(); @@ -320,7 +320,7 @@ void ChromeInvalidationClient::Stop() { push_client_state_ = DEFAULT_NOTIFICATION_ERROR; } -NotificationsDisabledReason ChromeInvalidationClient::GetState() const { +NotificationsDisabledReason SyncInvalidationListener::GetState() const { DCHECK(CalledOnValidThread()); if (ticl_state_ == NOTIFICATION_CREDENTIALS_REJECTED || push_client_state_ == NOTIFICATION_CREDENTIALS_REJECTED) { @@ -338,29 +338,29 @@ NotificationsDisabledReason ChromeInvalidationClient::GetState() const { return TRANSIENT_NOTIFICATION_ERROR; } -void ChromeInvalidationClient::EmitStateChange() { +void SyncInvalidationListener::EmitStateChange() { DCHECK(CalledOnValidThread()); if (GetState() == NO_NOTIFICATION_ERROR) { - listener_->OnNotificationsEnabled(); + delegate_->OnNotificationsEnabled(); } else { - listener_->OnNotificationsDisabled(GetState()); + delegate_->OnNotificationsDisabled(GetState()); } } -void ChromeInvalidationClient::OnNotificationsEnabled() { +void SyncInvalidationListener::OnNotificationsEnabled() { DCHECK(CalledOnValidThread()); push_client_state_ = NO_NOTIFICATION_ERROR; EmitStateChange(); } -void ChromeInvalidationClient::OnNotificationsDisabled( +void SyncInvalidationListener::OnNotificationsDisabled( notifier::NotificationsDisabledReason reason) { DCHECK(CalledOnValidThread()); push_client_state_ = FromNotifierReason(reason); EmitStateChange(); } -void ChromeInvalidationClient::OnIncomingNotification( +void SyncInvalidationListener::OnIncomingNotification( const notifier::Notification& notification) { DCHECK(CalledOnValidThread()); // Do nothing, since this is already handled by |invalidation_client_|. diff --git a/sync/notifier/chrome_invalidation_client.h b/sync/notifier/sync_invalidation_listener.h index 1d2d33d..860f6e7 100644 --- a/sync/notifier/chrome_invalidation_client.h +++ b/sync/notifier/sync_invalidation_listener.h @@ -5,8 +5,8 @@ // A simple wrapper around invalidation::InvalidationClient that // handles all the startup/shutdown details and hookups. -#ifndef SYNC_NOTIFIER_CHROME_INVALIDATION_CLIENT_H_ -#define SYNC_NOTIFIER_CHROME_INVALIDATION_CLIENT_H_ +#ifndef SYNC_NOTIFIER_SYNC_INVALIDATION_LISTENER_H_ +#define SYNC_NOTIFIER_SYNC_INVALIDATION_LISTENER_H_ #include <string> @@ -19,11 +19,11 @@ #include "google/cacheinvalidation/include/invalidation-listener.h" #include "jingle/notifier/listener/push_client_observer.h" #include "sync/internal_api/public/util/weak_handle.h" -#include "sync/notifier/chrome_system_resources.h" #include "sync/notifier/invalidation_state_tracker.h" #include "sync/notifier/notifications_disabled_reason.h" #include "sync/notifier/object_id_state_map.h" #include "sync/notifier/state_writer.h" +#include "sync/notifier/sync_system_resources.h" namespace buzz { class XmppTaskParentInterface; @@ -37,9 +37,9 @@ namespace syncer { class RegistrationManager; -// ChromeInvalidationClient is not thread-safe and lives on the sync +// SyncInvalidationListener is not thread-safe and lives on the sync // thread. -class ChromeInvalidationClient +class SyncInvalidationListener : public invalidation::InvalidationListener, public StateWriter, public notifier::PushClientObserver, @@ -52,9 +52,9 @@ class ChromeInvalidationClient const invalidation::string&, invalidation::InvalidationListener*)> CreateInvalidationClientCallback; - class Listener { + class Delegate { public: - virtual ~Listener(); + virtual ~Delegate(); virtual void OnInvalidate(const ObjectIdStateMap& id_state_map) = 0; @@ -64,13 +64,13 @@ class ChromeInvalidationClient NotificationsDisabledReason reason) = 0; }; - explicit ChromeInvalidationClient( + explicit SyncInvalidationListener( scoped_ptr<notifier::PushClient> push_client); // Calls Stop(). - virtual ~ChromeInvalidationClient(); + virtual ~SyncInvalidationListener(); - // Does not take ownership of |listener| or |state_writer|. + // Does not take ownership of |delegate| or |state_writer|. // |invalidation_state_tracker| must be initialized. void Start( const CreateInvalidationClientCallback& @@ -79,7 +79,7 @@ class ChromeInvalidationClient const std::string& state, const InvalidationVersionMap& initial_max_invalidation_versions, const WeakHandle<InvalidationStateTracker>& invalidation_state_tracker, - Listener* listener); + Delegate* delegate); void UpdateCredentials(const std::string& email, const std::string& token); @@ -141,12 +141,12 @@ class ChromeInvalidationClient void EmitInvalidation(const ObjectIdStateMap& id_state_map); - // Owned by |chrome_system_resources_|. + // Owned by |sync_system_resources_|. notifier::PushClient* const push_client_; - ChromeSystemResources chrome_system_resources_; + SyncSystemResources sync_system_resources_; InvalidationVersionMap max_invalidation_versions_; WeakHandle<InvalidationStateTracker> invalidation_state_tracker_; - Listener* listener_; + Delegate* delegate_; scoped_ptr<invalidation::InvalidationClient> invalidation_client_; scoped_ptr<RegistrationManager> registration_manager_; // Stored to pass to |registration_manager_| on start. @@ -157,9 +157,9 @@ class ChromeInvalidationClient NotificationsDisabledReason ticl_state_; NotificationsDisabledReason push_client_state_; - DISALLOW_COPY_AND_ASSIGN(ChromeInvalidationClient); + DISALLOW_COPY_AND_ASSIGN(SyncInvalidationListener); }; } // namespace syncer -#endif // SYNC_NOTIFIER_CHROME_INVALIDATION_CLIENT_H_ +#endif // SYNC_NOTIFIER_SYNC_INVALIDATION_LISTENER_H_ diff --git a/sync/notifier/chrome_invalidation_client_unittest.cc b/sync/notifier/sync_invalidation_listener_unittest.cc index a7c8f8af..2f0deac 100644 --- a/sync/notifier/chrome_invalidation_client_unittest.cc +++ b/sync/notifier/sync_invalidation_listener_unittest.cc @@ -12,9 +12,9 @@ #include "google/cacheinvalidation/include/types.h" #include "jingle/notifier/listener/fake_push_client.h" #include "sync/internal_api/public/util/weak_handle.h" -#include "sync/notifier/chrome_invalidation_client.h" #include "sync/notifier/fake_invalidation_state_tracker.h" #include "sync/notifier/invalidation_util.h" +#include "sync/notifier/sync_invalidation_listener.h" #include "testing/gtest/include/gtest/gtest.h" namespace syncer { @@ -127,12 +127,12 @@ class FakeInvalidationClient : public invalidation::InvalidationClient { AckHandleSet acked_handles_; }; -// Fake listener tkat keeps track of invalidation counts, payloads, +// Fake delegate tkat keeps track of invalidation counts, payloads, // and state. -class FakeListener : public ChromeInvalidationClient::Listener { +class FakeDelegate : public SyncInvalidationListener::Delegate { public: - FakeListener() : reason_(TRANSIENT_NOTIFICATION_ERROR) {} - virtual ~FakeListener() {} + FakeDelegate() : reason_(TRANSIENT_NOTIFICATION_ERROR) {} + virtual ~FakeDelegate() {} int GetInvalidationCount(const ObjectId& id) const { ObjectIdCountMap::const_iterator it = invalidation_counts_.find(id); @@ -149,7 +149,7 @@ class FakeListener : public ChromeInvalidationClient::Listener { return reason_; } - // ChromeInvalidationClient::Listener implementation. + // SyncInvalidationListener::Delegate implementation. virtual void OnInvalidate(const ObjectIdStateMap& id_state_map) OVERRIDE { for (ObjectIdStateMap::const_iterator it = id_state_map.begin(); @@ -185,9 +185,9 @@ invalidation::InvalidationClient* CreateFakeInvalidationClient( return *fake_invalidation_client; } -class ChromeInvalidationClientTest : public testing::Test { +class SyncInvalidationListenerTest : public testing::Test { protected: - ChromeInvalidationClientTest() + SyncInvalidationListenerTest() : kBookmarksId_(kChromeSyncSourceId, "BOOKMARK"), kPreferencesId_(kChromeSyncSourceId, "PREFERENCE"), kExtensionsId_(kChromeSyncSourceId, "EXTENSION"), @@ -215,15 +215,15 @@ class ChromeInvalidationClientTest : public testing::Test { } int GetInvalidationCount(const ObjectId& id) const { - return fake_listener_.GetInvalidationCount(id); + return fake_delegate_.GetInvalidationCount(id); } std::string GetPayload(const ObjectId& id) const { - return fake_listener_.GetPayload(id); + return fake_delegate_.GetPayload(id); } NotificationsDisabledReason GetNotificationsDisabledReason() const { - return fake_listener_.GetNotificationsDisabledReason(); + return fake_delegate_.GetNotificationsDisabledReason(); } int64 GetMaxVersion(const ObjectId& id) const { @@ -302,7 +302,7 @@ class ChromeInvalidationClientTest : public testing::Test { kClientId, kClientInfo, kState, InvalidationVersionMap(), MakeWeakHandle(fake_tracker_.AsWeakPtr()), - &fake_listener_); + &fake_delegate_); DCHECK(fake_invalidation_client_); } @@ -320,19 +320,19 @@ class ChromeInvalidationClientTest : public testing::Test { MessageLoop message_loop_; - FakeListener fake_listener_; + FakeDelegate fake_delegate_; FakeInvalidationStateTracker fake_tracker_; notifier::FakePushClient* const fake_push_client_; protected: // Tests need to access these directly. FakeInvalidationClient* fake_invalidation_client_; - ChromeInvalidationClient client_; + SyncInvalidationListener client_; }; // Write a new state to the client. It should propagate to the // tracker. -TEST_F(ChromeInvalidationClientTest, WriteState) { +TEST_F(SyncInvalidationListenerTest, WriteState) { WriteState(kNewState); EXPECT_EQ(kNewState, GetInvalidationState()); @@ -342,7 +342,7 @@ TEST_F(ChromeInvalidationClientTest, WriteState) { // Fire an invalidation without a payload. It should be processed, // the payload should remain empty, and the version should be updated. -TEST_F(ChromeInvalidationClientTest, InvalidateNoPayload) { +TEST_F(SyncInvalidationListenerTest, InvalidateNoPayload) { const ObjectId& id = kBookmarksId_; FireInvalidate(id, kVersion1, NULL); @@ -355,7 +355,7 @@ TEST_F(ChromeInvalidationClientTest, InvalidateNoPayload) { // Fire an invalidation with an empty payload. It should be // processed, the payload should remain empty, and the version should // be updated. -TEST_F(ChromeInvalidationClientTest, InvalidateEmptyPayload) { +TEST_F(SyncInvalidationListenerTest, InvalidateEmptyPayload) { const ObjectId& id = kBookmarksId_; FireInvalidate(id, kVersion1, ""); @@ -367,7 +367,7 @@ TEST_F(ChromeInvalidationClientTest, InvalidateEmptyPayload) { // Fire an invalidation with a payload. It should be processed, and // both the payload and the version should be updated. -TEST_F(ChromeInvalidationClientTest, InvalidateWithPayload) { +TEST_F(SyncInvalidationListenerTest, InvalidateWithPayload) { const ObjectId& id = kPreferencesId_; FireInvalidate(id, kVersion1, kPayload1); @@ -379,7 +379,7 @@ TEST_F(ChromeInvalidationClientTest, InvalidateWithPayload) { // Fire an invalidation with a payload. It should still be processed, // and both the payload and the version should be updated. -TEST_F(ChromeInvalidationClientTest, InvalidateUnregistered) { +TEST_F(SyncInvalidationListenerTest, InvalidateUnregistered) { const ObjectId kUnregisteredId( kChromeSyncSourceId, "unregistered"); const ObjectId& id = kUnregisteredId; @@ -398,7 +398,7 @@ TEST_F(ChromeInvalidationClientTest, InvalidateUnregistered) { // Fire an invalidation, then fire another one with a lower version. // The first one should be processed and should update the payload and // version, but the second one shouldn't. -TEST_F(ChromeInvalidationClientTest, InvalidateVersion) { +TEST_F(SyncInvalidationListenerTest, InvalidateVersion) { const ObjectId& id = kPreferencesId_; FireInvalidate(id, kVersion2, kPayload2); @@ -417,7 +417,7 @@ TEST_F(ChromeInvalidationClientTest, InvalidateVersion) { // Fire an invalidation with an unknown version twice. It shouldn't // update the payload or version either time, but it should still be // processed. -TEST_F(ChromeInvalidationClientTest, InvalidateUnknownVersion) { +TEST_F(SyncInvalidationListenerTest, InvalidateUnknownVersion) { const ObjectId& id = kBookmarksId_; FireInvalidateUnknownVersion(id); @@ -435,7 +435,7 @@ TEST_F(ChromeInvalidationClientTest, InvalidateUnknownVersion) { // Fire an invalidation for all enabled IDs. It shouldn't update the // payload or version, but it should still invalidate the IDs. -TEST_F(ChromeInvalidationClientTest, InvalidateAll) { +TEST_F(SyncInvalidationListenerTest, InvalidateAll) { FireInvalidateAll(); for (ObjectIdSet::const_iterator it = registered_ids_.begin(); @@ -447,7 +447,7 @@ TEST_F(ChromeInvalidationClientTest, InvalidateAll) { } // Comprehensive test of various scenarios for multiple IDs. -TEST_F(ChromeInvalidationClientTest, InvalidateMultipleIds) { +TEST_F(SyncInvalidationListenerTest, InvalidateMultipleIds) { FireInvalidate(kBookmarksId_, 3, NULL); EXPECT_EQ(1, GetInvalidationCount(kBookmarksId_)); @@ -513,7 +513,7 @@ TEST_F(ChromeInvalidationClientTest, InvalidateMultipleIds) { // With IDs already registered, enable notifications then ready the // client. The IDs should be registered only after the client is // readied. -TEST_F(ChromeInvalidationClientTest, RegisterEnableReady) { +TEST_F(SyncInvalidationListenerTest, RegisterEnableReady) { EXPECT_TRUE(GetRegisteredIds().empty()); EnableNotifications(); @@ -528,7 +528,7 @@ TEST_F(ChromeInvalidationClientTest, RegisterEnableReady) { // With IDs already registered, ready the client then enable // notifications. The IDs should be registered after the client is // readied. -TEST_F(ChromeInvalidationClientTest, RegisterReadyEnable) { +TEST_F(SyncInvalidationListenerTest, RegisterReadyEnable) { EXPECT_TRUE(GetRegisteredIds().empty()); client_.Ready(fake_invalidation_client_); @@ -543,7 +543,7 @@ TEST_F(ChromeInvalidationClientTest, RegisterReadyEnable) { // Unregister the IDs, enable notifications, re-register the IDs, then // ready the client. The IDs should be registered only after the // client is readied. -TEST_F(ChromeInvalidationClientTest, EnableRegisterReady) { +TEST_F(SyncInvalidationListenerTest, EnableRegisterReady) { client_.UpdateRegisteredIds(ObjectIdSet()); EXPECT_TRUE(GetRegisteredIds().empty()); @@ -564,7 +564,7 @@ TEST_F(ChromeInvalidationClientTest, EnableRegisterReady) { // Unregister the IDs, enable notifications, ready the client, then // re-register the IDs. The IDs should be registered only after the // client is readied. -TEST_F(ChromeInvalidationClientTest, EnableReadyRegister) { +TEST_F(SyncInvalidationListenerTest, EnableReadyRegister) { client_.UpdateRegisteredIds(ObjectIdSet()); EXPECT_TRUE(GetRegisteredIds().empty()); @@ -585,7 +585,7 @@ TEST_F(ChromeInvalidationClientTest, EnableReadyRegister) { // Unregister the IDs, ready the client, enable notifications, then // re-register the IDs. The IDs should be registered only after the // client is readied. -TEST_F(ChromeInvalidationClientTest, ReadyEnableRegister) { +TEST_F(SyncInvalidationListenerTest, ReadyEnableRegister) { client_.UpdateRegisteredIds(ObjectIdSet()); EXPECT_TRUE(GetRegisteredIds().empty()); @@ -608,7 +608,7 @@ TEST_F(ChromeInvalidationClientTest, ReadyEnableRegister) { // client is readied. // // This test is important: see http://crbug.com/139424. -TEST_F(ChromeInvalidationClientTest, ReadyRegisterEnable) { +TEST_F(SyncInvalidationListenerTest, ReadyRegisterEnable) { client_.UpdateRegisteredIds(ObjectIdSet()); EXPECT_TRUE(GetRegisteredIds().empty()); @@ -628,7 +628,7 @@ TEST_F(ChromeInvalidationClientTest, ReadyRegisterEnable) { // With IDs already registered, ready the client, restart the client, // then re-ready it. The IDs should still be registered. -TEST_F(ChromeInvalidationClientTest, RegisterTypesPreserved) { +TEST_F(SyncInvalidationListenerTest, RegisterTypesPreserved) { EXPECT_TRUE(GetRegisteredIds().empty()); client_.Ready(fake_invalidation_client_); @@ -645,8 +645,8 @@ TEST_F(ChromeInvalidationClientTest, RegisterTypesPreserved) { } // Without readying the client, disable notifications, then enable -// them. The listener should still think notifications are disabled. -TEST_F(ChromeInvalidationClientTest, EnableNotificationsNotReady) { +// them. The delegate should still think notifications are disabled. +TEST_F(SyncInvalidationListenerTest, EnableNotificationsNotReady) { EXPECT_EQ(TRANSIENT_NOTIFICATION_ERROR, GetNotificationsDisabledReason()); @@ -669,8 +669,8 @@ TEST_F(ChromeInvalidationClientTest, EnableNotificationsNotReady) { } // Enable notifications then Ready the invalidation client. The -// listener should then be ready. -TEST_F(ChromeInvalidationClientTest, EnableNotificationsThenReady) { +// delegate should then be ready. +TEST_F(SyncInvalidationListenerTest, EnableNotificationsThenReady) { EXPECT_EQ(TRANSIENT_NOTIFICATION_ERROR, GetNotificationsDisabledReason()); EnableNotifications(); @@ -683,8 +683,8 @@ TEST_F(ChromeInvalidationClientTest, EnableNotificationsThenReady) { } // Ready the invalidation client then enable notifications. The -// listener should then be ready. -TEST_F(ChromeInvalidationClientTest, ReadyThenEnableNotifications) { +// delegate should then be ready. +TEST_F(SyncInvalidationListenerTest, ReadyThenEnableNotifications) { EXPECT_EQ(TRANSIENT_NOTIFICATION_ERROR, GetNotificationsDisabledReason()); client_.Ready(fake_invalidation_client_); @@ -698,8 +698,8 @@ TEST_F(ChromeInvalidationClientTest, ReadyThenEnableNotifications) { // Enable notifications and ready the client. Then disable // notifications with an auth error and re-enable notifications. The -// listener should go into an auth error mode and then back out. -TEST_F(ChromeInvalidationClientTest, PushClientAuthError) { +// delegate should go into an auth error mode and then back out. +TEST_F(SyncInvalidationListenerTest, PushClientAuthError) { EnableNotifications(); client_.Ready(fake_invalidation_client_); @@ -718,9 +718,9 @@ TEST_F(ChromeInvalidationClientTest, PushClientAuthError) { // Enable notifications and ready the client. Then simulate an auth // error from the invalidation client. Simulate some notification -// events, then re-ready the client. The listener should go into an +// events, then re-ready the client. The delegate should go into an // auth error mode and come out of it only after the client is ready. -TEST_F(ChromeInvalidationClientTest, InvalidationClientAuthError) { +TEST_F(SyncInvalidationListenerTest, InvalidationClientAuthError) { EnableNotifications(); client_.Ready(fake_invalidation_client_); diff --git a/sync/notifier/chrome_system_resources.cc b/sync/notifier/sync_system_resources.cc index af4cf9a..5328657 100644 --- a/sync/notifier/chrome_system_resources.cc +++ b/sync/notifier/sync_system_resources.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "sync/notifier/chrome_system_resources.h" +#include "sync/notifier/sync_system_resources.h" #include <cstdlib> #include <cstring> @@ -21,11 +21,11 @@ namespace syncer { -ChromeLogger::ChromeLogger() {} -ChromeLogger::~ChromeLogger() {} +SyncLogger::SyncLogger() {} +SyncLogger::~SyncLogger() {} -void ChromeLogger::Log(LogLevel level, const char* file, int line, - const char* format, ...) { +void SyncLogger::Log(LogLevel level, const char* file, int line, + const char* format, ...) { logging::LogSeverity log_severity = -2; // VLOG(2) bool emit_log = false; switch (level) { @@ -56,12 +56,11 @@ void ChromeLogger::Log(LogLevel level, const char* file, int line, } } -void ChromeLogger::SetSystemResources( - invalidation::SystemResources* resources) { +void SyncLogger::SetSystemResources(invalidation::SystemResources* resources) { // Do nothing. } -ChromeScheduler::ChromeScheduler() +SyncInvalidationScheduler::SyncInvalidationScheduler() : ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)), created_on_loop_(MessageLoop::current()), is_started_(false), @@ -69,12 +68,12 @@ ChromeScheduler::ChromeScheduler() CHECK(created_on_loop_); } -ChromeScheduler::~ChromeScheduler() { +SyncInvalidationScheduler::~SyncInvalidationScheduler() { CHECK_EQ(created_on_loop_, MessageLoop::current()); CHECK(is_stopped_); } -void ChromeScheduler::Start() { +void SyncInvalidationScheduler::Start() { CHECK_EQ(created_on_loop_, MessageLoop::current()); CHECK(!is_started_); is_started_ = true; @@ -82,7 +81,7 @@ void ChromeScheduler::Start() { weak_factory_.InvalidateWeakPtrs(); } -void ChromeScheduler::Stop() { +void SyncInvalidationScheduler::Stop() { CHECK_EQ(created_on_loop_, MessageLoop::current()); is_stopped_ = true; is_started_ = false; @@ -91,8 +90,8 @@ void ChromeScheduler::Stop() { posted_tasks_.clear(); } -void ChromeScheduler::Schedule(invalidation::TimeDelta delay, - invalidation::Closure* task) { +void SyncInvalidationScheduler::Schedule(invalidation::TimeDelta delay, + invalidation::Closure* task) { DCHECK(invalidation::IsCallbackRepeatable(task)); CHECK_EQ(created_on_loop_, MessageLoop::current()); @@ -103,44 +102,44 @@ void ChromeScheduler::Schedule(invalidation::TimeDelta delay, posted_tasks_.insert(task); MessageLoop::current()->PostDelayedTask( - FROM_HERE, base::Bind(&ChromeScheduler::RunPostedTask, + FROM_HERE, base::Bind(&SyncInvalidationScheduler::RunPostedTask, weak_factory_.GetWeakPtr(), task), delay); } -bool ChromeScheduler::IsRunningOnThread() const { +bool SyncInvalidationScheduler::IsRunningOnThread() const { return created_on_loop_ == MessageLoop::current(); } -invalidation::Time ChromeScheduler::GetCurrentTime() const { +invalidation::Time SyncInvalidationScheduler::GetCurrentTime() const { CHECK_EQ(created_on_loop_, MessageLoop::current()); return base::Time::Now(); } -void ChromeScheduler::SetSystemResources( +void SyncInvalidationScheduler::SetSystemResources( invalidation::SystemResources* resources) { // Do nothing. } -void ChromeScheduler::RunPostedTask(invalidation::Closure* task) { +void SyncInvalidationScheduler::RunPostedTask(invalidation::Closure* task) { CHECK_EQ(created_on_loop_, MessageLoop::current()); task->Run(); posted_tasks_.erase(task); delete task; } -ChromeStorage::ChromeStorage(StateWriter* state_writer, - invalidation::Scheduler* scheduler) +SyncStorage::SyncStorage(StateWriter* state_writer, + invalidation::Scheduler* scheduler) : state_writer_(state_writer), scheduler_(scheduler) { DCHECK(state_writer_); DCHECK(scheduler_); } -ChromeStorage::~ChromeStorage() {} +SyncStorage::~SyncStorage() {} -void ChromeStorage::WriteKey(const std::string& key, const std::string& value, - invalidation::WriteKeyCallback* done) { +void SyncStorage::WriteKey(const std::string& key, const std::string& value, + invalidation::WriteKeyCallback* done) { CHECK(state_writer_); // TODO(ghc): actually write key,value associations, and don't invoke the // callback until the operation completes. @@ -154,39 +153,39 @@ void ChromeStorage::WriteKey(const std::string& key, const std::string& value, scheduler_->Schedule( invalidation::Scheduler::NoDelay(), invalidation::NewPermanentCallback( - this, &ChromeStorage::RunAndDeleteWriteKeyCallback, + this, &SyncStorage::RunAndDeleteWriteKeyCallback, done)); } -void ChromeStorage::ReadKey(const std::string& key, - invalidation::ReadKeyCallback* done) { +void SyncStorage::ReadKey(const std::string& key, + invalidation::ReadKeyCallback* done) { DCHECK(scheduler_->IsRunningOnThread()) << "not running on scheduler thread"; RunAndDeleteReadKeyCallback(done, cached_state_); } -void ChromeStorage::DeleteKey(const std::string& key, - invalidation::DeleteKeyCallback* done) { +void SyncStorage::DeleteKey(const std::string& key, + invalidation::DeleteKeyCallback* done) { // TODO(ghc): Implement. LOG(WARNING) << "ignoring call to DeleteKey(" << key << ", callback)"; } -void ChromeStorage::ReadAllKeys(invalidation::ReadAllKeysCallback* done) { +void SyncStorage::ReadAllKeys(invalidation::ReadAllKeysCallback* done) { // TODO(ghc): Implement. LOG(WARNING) << "ignoring call to ReadAllKeys(callback)"; } -void ChromeStorage::SetSystemResources( +void SyncStorage::SetSystemResources( invalidation::SystemResources* resources) { // Do nothing. } -void ChromeStorage::RunAndDeleteWriteKeyCallback( +void SyncStorage::RunAndDeleteWriteKeyCallback( invalidation::WriteKeyCallback* callback) { callback->Run(invalidation::Status(invalidation::Status::SUCCESS, "")); delete callback; } -void ChromeStorage::RunAndDeleteReadKeyCallback( +void SyncStorage::RunAndDeleteReadKeyCallback( invalidation::ReadKeyCallback* callback, const std::string& value) { callback->Run(std::make_pair( invalidation::Status(invalidation::Status::SUCCESS, ""), @@ -194,61 +193,61 @@ void ChromeStorage::RunAndDeleteReadKeyCallback( delete callback; } -ChromeSystemResources::ChromeSystemResources( +SyncSystemResources::SyncSystemResources( scoped_ptr<notifier::PushClient> push_client, StateWriter* state_writer) : is_started_(false), - logger_(new ChromeLogger()), - internal_scheduler_(new ChromeScheduler()), - listener_scheduler_(new ChromeScheduler()), - storage_(new ChromeStorage(state_writer, internal_scheduler_.get())), + logger_(new SyncLogger()), + internal_scheduler_(new SyncInvalidationScheduler()), + listener_scheduler_(new SyncInvalidationScheduler()), + storage_(new SyncStorage(state_writer, internal_scheduler_.get())), push_client_channel_(push_client.Pass()) { } -ChromeSystemResources::~ChromeSystemResources() { +SyncSystemResources::~SyncSystemResources() { Stop(); } -void ChromeSystemResources::Start() { +void SyncSystemResources::Start() { internal_scheduler_->Start(); listener_scheduler_->Start(); is_started_ = true; } -void ChromeSystemResources::Stop() { +void SyncSystemResources::Stop() { internal_scheduler_->Stop(); listener_scheduler_->Stop(); } -bool ChromeSystemResources::IsStarted() const { +bool SyncSystemResources::IsStarted() const { return is_started_; } -void ChromeSystemResources::set_platform(const std::string& platform) { +void SyncSystemResources::set_platform(const std::string& platform) { platform_ = platform; } -std::string ChromeSystemResources::platform() const { +std::string SyncSystemResources::platform() const { return platform_; } -ChromeLogger* ChromeSystemResources::logger() { +SyncLogger* SyncSystemResources::logger() { return logger_.get(); } -ChromeStorage* ChromeSystemResources::storage() { +SyncStorage* SyncSystemResources::storage() { return storage_.get(); } -PushClientChannel* ChromeSystemResources::network() { +PushClientChannel* SyncSystemResources::network() { return &push_client_channel_; } -ChromeScheduler* ChromeSystemResources::internal_scheduler() { +SyncInvalidationScheduler* SyncSystemResources::internal_scheduler() { return internal_scheduler_.get(); } -ChromeScheduler* ChromeSystemResources::listener_scheduler() { +SyncInvalidationScheduler* SyncSystemResources::listener_scheduler() { return listener_scheduler_.get(); } diff --git a/sync/notifier/chrome_system_resources.h b/sync/notifier/sync_system_resources.h index a2ba11d..bd6fc48 100644 --- a/sync/notifier/chrome_system_resources.h +++ b/sync/notifier/sync_system_resources.h @@ -6,8 +6,8 @@ // for scheduling. Assumes the current message loop is already // running. -#ifndef SYNC_NOTIFIER_CHROME_SYSTEM_RESOURCES_H_ -#define SYNC_NOTIFIER_CHROME_SYSTEM_RESOURCES_H_ +#ifndef SYNC_NOTIFIER_SYNC_SYSTEM_RESOURCES_H_ +#define SYNC_NOTIFIER_SYNC_SYSTEM_RESOURCES_H_ #include <set> #include <string> @@ -28,11 +28,11 @@ class PushClient; namespace syncer { -class ChromeLogger : public invalidation::Logger { +class SyncLogger : public invalidation::Logger { public: - ChromeLogger(); + SyncLogger(); - virtual ~ChromeLogger(); + virtual ~SyncLogger(); // invalidation::Logger implementation. virtual void Log(LogLevel level, const char* file, int line, @@ -42,11 +42,11 @@ class ChromeLogger : public invalidation::Logger { invalidation::SystemResources* resources) OVERRIDE; }; -class ChromeScheduler : public invalidation::Scheduler { +class SyncInvalidationScheduler : public invalidation::Scheduler { public: - ChromeScheduler(); + SyncInvalidationScheduler(); - virtual ~ChromeScheduler(); + virtual ~SyncInvalidationScheduler(); // Start and stop the scheduler. void Start(); @@ -64,7 +64,7 @@ class ChromeScheduler : public invalidation::Scheduler { invalidation::SystemResources* resources) OVERRIDE; private: - base::WeakPtrFactory<ChromeScheduler> weak_factory_; + base::WeakPtrFactory<SyncInvalidationScheduler> weak_factory_; // Holds all posted tasks that have not yet been run. std::set<invalidation::Closure*> posted_tasks_; @@ -76,11 +76,11 @@ class ChromeScheduler : public invalidation::Scheduler { void RunPostedTask(invalidation::Closure* task); }; -class ChromeStorage : public invalidation::Storage { +class SyncStorage : public invalidation::Storage { public: - ChromeStorage(StateWriter* state_writer, invalidation::Scheduler* scheduler); + SyncStorage(StateWriter* state_writer, invalidation::Scheduler* scheduler); - virtual ~ChromeStorage(); + virtual ~SyncStorage(); void SetInitialState(const std::string& value) { cached_state_ = value; @@ -116,12 +116,12 @@ class ChromeStorage : public invalidation::Storage { std::string cached_state_; }; -class ChromeSystemResources : public invalidation::SystemResources { +class SyncSystemResources : public invalidation::SystemResources { public: - ChromeSystemResources(scoped_ptr<notifier::PushClient> push_client, - StateWriter* state_writer); + SyncSystemResources(scoped_ptr<notifier::PushClient> push_client, + StateWriter* state_writer); - virtual ~ChromeSystemResources(); + virtual ~SyncSystemResources(); // invalidation::SystemResources implementation. virtual void Start() OVERRIDE; @@ -129,22 +129,22 @@ class ChromeSystemResources : public invalidation::SystemResources { virtual bool IsStarted() const OVERRIDE; virtual void set_platform(const std::string& platform); virtual std::string platform() const OVERRIDE; - virtual ChromeLogger* logger() OVERRIDE; - virtual ChromeStorage* storage() OVERRIDE; + virtual SyncLogger* logger() OVERRIDE; + virtual SyncStorage* storage() OVERRIDE; virtual PushClientChannel* network() OVERRIDE; - virtual ChromeScheduler* internal_scheduler() OVERRIDE; - virtual ChromeScheduler* listener_scheduler() OVERRIDE; + virtual SyncInvalidationScheduler* internal_scheduler() OVERRIDE; + virtual SyncInvalidationScheduler* listener_scheduler() OVERRIDE; private: bool is_started_; std::string platform_; - scoped_ptr<ChromeLogger> logger_; - scoped_ptr<ChromeScheduler> internal_scheduler_; - scoped_ptr<ChromeScheduler> listener_scheduler_; - scoped_ptr<ChromeStorage> storage_; + scoped_ptr<SyncLogger> logger_; + scoped_ptr<SyncInvalidationScheduler> internal_scheduler_; + scoped_ptr<SyncInvalidationScheduler> listener_scheduler_; + scoped_ptr<SyncStorage> storage_; PushClientChannel push_client_channel_; }; } // namespace syncer -#endif // SYNC_NOTIFIER_CHROME_SYSTEM_RESOURCES_H_ +#endif // SYNC_NOTIFIER_SYNC_SYSTEM_RESOURCES_H_ diff --git a/sync/notifier/chrome_system_resources_unittest.cc b/sync/notifier/sync_system_resources_unittest.cc index 7d05db8..314f728 100644 --- a/sync/notifier/chrome_system_resources_unittest.cc +++ b/sync/notifier/sync_system_resources_unittest.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "sync/notifier/chrome_system_resources.h" +#include "sync/notifier/sync_system_resources.h" #include <string> @@ -46,14 +46,14 @@ class MockStorageCallback { } }; -class ChromeSystemResourcesTest : public testing::Test { +class SyncSystemResourcesTest : public testing::Test { protected: - ChromeSystemResourcesTest() - : chrome_system_resources_( + SyncSystemResourcesTest() + : sync_system_resources_( scoped_ptr<notifier::PushClient>(new notifier::FakePushClient()), &mock_state_writer_) {} - virtual ~ChromeSystemResourcesTest() {} + virtual ~SyncSystemResourcesTest() {} void ScheduleShouldNotRun() { { @@ -61,7 +61,7 @@ class ChromeSystemResourcesTest : public testing::Test { MockClosure mock_closure; base::Closure* should_not_run = mock_closure.CreateClosure(); EXPECT_CALL(mock_closure, Run()).Times(0); - chrome_system_resources_.internal_scheduler()->Schedule( + sync_system_resources_.internal_scheduler()->Schedule( invalidation::Scheduler::NoDelay(), should_not_run); } { @@ -69,7 +69,7 @@ class ChromeSystemResourcesTest : public testing::Test { MockClosure mock_closure; base::Closure* should_not_run = mock_closure.CreateClosure(); EXPECT_CALL(mock_closure, Run()).Times(0); - chrome_system_resources_.listener_scheduler()->Schedule( + sync_system_resources_.listener_scheduler()->Schedule( invalidation::Scheduler::NoDelay(), should_not_run); } { @@ -77,89 +77,89 @@ class ChromeSystemResourcesTest : public testing::Test { MockClosure mock_closure; base::Closure* should_not_run = mock_closure.CreateClosure(); EXPECT_CALL(mock_closure, Run()).Times(0); - chrome_system_resources_.internal_scheduler()->Schedule( + sync_system_resources_.internal_scheduler()->Schedule( invalidation::TimeDelta::FromSeconds(0), should_not_run); } } - // Needed by |chrome_system_resources_|. + // Needed by |sync_system_resources_|. MessageLoop message_loop_; MockStateWriter mock_state_writer_; - ChromeSystemResources chrome_system_resources_; + SyncSystemResources sync_system_resources_; private: - DISALLOW_COPY_AND_ASSIGN(ChromeSystemResourcesTest); + DISALLOW_COPY_AND_ASSIGN(SyncSystemResourcesTest); }; // Make sure current_time() doesn't crash or leak. -TEST_F(ChromeSystemResourcesTest, CurrentTime) { +TEST_F(SyncSystemResourcesTest, CurrentTime) { invalidation::Time current_time = - chrome_system_resources_.internal_scheduler()->GetCurrentTime(); + sync_system_resources_.internal_scheduler()->GetCurrentTime(); DVLOG(1) << "current_time returned: " << current_time.ToInternalValue(); } // Make sure Log() doesn't crash or leak. -TEST_F(ChromeSystemResourcesTest, Log) { - chrome_system_resources_.logger()->Log(ChromeLogger::INFO_LEVEL, +TEST_F(SyncSystemResourcesTest, Log) { + sync_system_resources_.logger()->Log(SyncLogger::INFO_LEVEL, __FILE__, __LINE__, "%s %d", "test string", 5); } -TEST_F(ChromeSystemResourcesTest, ScheduleBeforeStart) { +TEST_F(SyncSystemResourcesTest, ScheduleBeforeStart) { ScheduleShouldNotRun(); - chrome_system_resources_.Start(); + sync_system_resources_.Start(); } -TEST_F(ChromeSystemResourcesTest, ScheduleAfterStop) { - chrome_system_resources_.Start(); - chrome_system_resources_.Stop(); +TEST_F(SyncSystemResourcesTest, ScheduleAfterStop) { + sync_system_resources_.Start(); + sync_system_resources_.Stop(); ScheduleShouldNotRun(); } -TEST_F(ChromeSystemResourcesTest, ScheduleAndStop) { - chrome_system_resources_.Start(); +TEST_F(SyncSystemResourcesTest, ScheduleAndStop) { + sync_system_resources_.Start(); ScheduleShouldNotRun(); - chrome_system_resources_.Stop(); + sync_system_resources_.Stop(); } -TEST_F(ChromeSystemResourcesTest, ScheduleAndDestroy) { - chrome_system_resources_.Start(); +TEST_F(SyncSystemResourcesTest, ScheduleAndDestroy) { + sync_system_resources_.Start(); ScheduleShouldNotRun(); } -TEST_F(ChromeSystemResourcesTest, ScheduleImmediately) { - chrome_system_resources_.Start(); +TEST_F(SyncSystemResourcesTest, ScheduleImmediately) { + sync_system_resources_.Start(); MockClosure mock_closure; EXPECT_CALL(mock_closure, Run()); - chrome_system_resources_.internal_scheduler()->Schedule( + sync_system_resources_.internal_scheduler()->Schedule( invalidation::Scheduler::NoDelay(), mock_closure.CreateClosure()); message_loop_.RunAllPending(); } -TEST_F(ChromeSystemResourcesTest, ScheduleOnListenerThread) { - chrome_system_resources_.Start(); +TEST_F(SyncSystemResourcesTest, ScheduleOnListenerThread) { + sync_system_resources_.Start(); MockClosure mock_closure; EXPECT_CALL(mock_closure, Run()); - chrome_system_resources_.listener_scheduler()->Schedule( + sync_system_resources_.listener_scheduler()->Schedule( invalidation::Scheduler::NoDelay(), mock_closure.CreateClosure()); EXPECT_TRUE( - chrome_system_resources_.internal_scheduler()->IsRunningOnThread()); + sync_system_resources_.internal_scheduler()->IsRunningOnThread()); message_loop_.RunAllPending(); } -TEST_F(ChromeSystemResourcesTest, ScheduleWithZeroDelay) { - chrome_system_resources_.Start(); +TEST_F(SyncSystemResourcesTest, ScheduleWithZeroDelay) { + sync_system_resources_.Start(); MockClosure mock_closure; EXPECT_CALL(mock_closure, Run()); - chrome_system_resources_.internal_scheduler()->Schedule( + sync_system_resources_.internal_scheduler()->Schedule( invalidation::TimeDelta::FromSeconds(0), mock_closure.CreateClosure()); message_loop_.RunAllPending(); } // TODO(akalin): Figure out how to test with a non-zero delay. -TEST_F(ChromeSystemResourcesTest, WriteState) { - chrome_system_resources_.Start(); +TEST_F(SyncSystemResourcesTest, WriteState) { + sync_system_resources_.Start(); EXPECT_CALL(mock_state_writer_, WriteState(_)); // Owned by WriteState. MockStorageCallback mock_storage_callback; @@ -167,7 +167,7 @@ TEST_F(ChromeSystemResourcesTest, WriteState) { "fake-failure"); EXPECT_CALL(mock_storage_callback, Run(_)) .WillOnce(SaveArg<0>(&results)); - chrome_system_resources_.storage()->WriteKey( + sync_system_resources_.storage()->WriteKey( "", "state", mock_storage_callback.CreateCallback()); message_loop_.RunAllPending(); EXPECT_EQ(invalidation::Status(invalidation::Status::SUCCESS, ""), results); diff --git a/sync/sync.gyp b/sync/sync.gyp index 9d68359..3701d34 100644 --- a/sync/sync.gyp +++ b/sync/sync.gyp @@ -274,10 +274,6 @@ 'conditions': [ ['OS != "android"', { 'sources': [ - 'notifier/chrome_invalidation_client.cc', - 'notifier/chrome_invalidation_client.h', - 'notifier/chrome_system_resources.cc', - 'notifier/chrome_system_resources.h', 'notifier/invalidation_notifier.cc', 'notifier/invalidation_notifier.h', 'notifier/invalidation_state_tracker.h', @@ -290,6 +286,10 @@ 'notifier/registration_manager.cc', 'notifier/registration_manager.h', 'notifier/state_writer.h', + 'notifier/sync_invalidation_listener.cc', + 'notifier/sync_invalidation_listener.h', + 'notifier/sync_system_resources.cc', + 'notifier/sync_system_resources.h', ], }], ], @@ -674,8 +674,6 @@ 'conditions': [ ['OS != "android"', { 'sources': [ - 'notifier/chrome_invalidation_client_unittest.cc', - 'notifier/chrome_system_resources_unittest.cc', 'notifier/fake_invalidator_unittest.cc', 'notifier/invalidation_notifier_unittest.cc', 'notifier/invalidator_registrar_unittest.cc', @@ -683,6 +681,8 @@ 'notifier/p2p_invalidator_unittest.cc', 'notifier/push_client_channel_unittest.cc', 'notifier/registration_manager_unittest.cc', + 'notifier/sync_invalidation_listener_unittest.cc', + 'notifier/sync_system_resources_unittest.cc', ], }], ], |