diff options
author | zea@chromium.org <zea@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-01-27 22:00:54 +0000 |
---|---|---|
committer | zea@chromium.org <zea@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-01-27 22:00:54 +0000 |
commit | b0bcdbfe4b1e64fc2d07ccf3963ffb9097d6afb9 (patch) | |
tree | ca0b75f7847692fd00183bafb5f9e3a1b81e3856 /chrome/browser/sync/notifier | |
parent | c757aaea2a0eef2c4cad4925884281e2f7639cd3 (diff) | |
download | chromium_src-b0bcdbfe4b1e64fc2d07ccf3963ffb9097d6afb9.zip chromium_src-b0bcdbfe4b1e64fc2d07ccf3963ffb9097d6afb9.tar.gz chromium_src-b0bcdbfe4b1e64fc2d07ccf3963ffb9097d6afb9.tar.bz2 |
Recommit attempt for rev 72685.
[SYNC] Refactor SyncSourceInfo and add support in chrome invalidation client and syncer thread for passing a datatype-specific payload originating in the invalidation server and directed at the sync frontend server. Also fixes bug with last_sync_time and PostTimeToTypeHistogram, which would get hit when the unit tests were being run.
BUG=68572, 69558
TEST=unit
Review URL: http://codereview.chromium.org/6313018
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@72891 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/sync/notifier')
5 files changed, 23 insertions, 6 deletions
diff --git a/chrome/browser/sync/notifier/chrome_invalidation_client.cc b/chrome/browser/sync/notifier/chrome_invalidation_client.cc index 7b17f9a..5d0cfd2a 100644 --- a/chrome/browser/sync/notifier/chrome_invalidation_client.cc +++ b/chrome/browser/sync/notifier/chrome_invalidation_client.cc @@ -126,13 +126,18 @@ void ChromeInvalidationClient::Invalidate( VLOG(1) << "Invalidate: " << InvalidationToString(invalidation); syncable::ModelType model_type; if (ObjectIdToRealModelType(invalidation.object_id(), &model_type)) { + std::string payload; + // payload() CHECK()'s has_payload(), so we must check it ourselves first. + if (invalidation.has_payload()) + payload = invalidation.payload(); + // TODO(akalin): This is a hack to make new sync data types work // with server-issued notifications. Remove this when it's not // needed anymore. if (model_type == syncable::UNSPECIFIED) { listener_->OnInvalidateAll(); } else { - listener_->OnInvalidate(model_type); + listener_->OnInvalidate(model_type, payload); } } else { LOG(WARNING) << "Could not get invalidation model type; " diff --git a/chrome/browser/sync/notifier/chrome_invalidation_client.h b/chrome/browser/sync/notifier/chrome_invalidation_client.h index 3d4e1d7..873b877 100644 --- a/chrome/browser/sync/notifier/chrome_invalidation_client.h +++ b/chrome/browser/sync/notifier/chrome_invalidation_client.h @@ -41,7 +41,8 @@ class ChromeInvalidationClient public: virtual ~Listener(); - virtual void OnInvalidate(syncable::ModelType model_type) = 0; + virtual void OnInvalidate(syncable::ModelType model_type, + const std::string& payload) = 0; virtual void OnInvalidateAll() = 0; }; diff --git a/chrome/browser/sync/notifier/chrome_invalidation_client_unittest.cc b/chrome/browser/sync/notifier/chrome_invalidation_client_unittest.cc index 809e32a..13438b9 100644 --- a/chrome/browser/sync/notifier/chrome_invalidation_client_unittest.cc +++ b/chrome/browser/sync/notifier/chrome_invalidation_client_unittest.cc @@ -18,7 +18,8 @@ using ::testing::Return; class MockListener : public ChromeInvalidationClient::Listener { public: - MOCK_METHOD1(OnInvalidate, void(syncable::ModelType)); + MOCK_METHOD2(OnInvalidate, void(syncable::ModelType, + const std::string& payload)); MOCK_METHOD0(OnInvalidateAll, void()); }; diff --git a/chrome/browser/sync/notifier/server_notifier_thread.cc b/chrome/browser/sync/notifier/server_notifier_thread.cc index ae15943..1c45beb 100644 --- a/chrome/browser/sync/notifier/server_notifier_thread.cc +++ b/chrome/browser/sync/notifier/server_notifier_thread.cc @@ -66,7 +66,9 @@ void ServerNotifierThread::SendNotification( "used"; } -void ServerNotifierThread::OnInvalidate(syncable::ModelType model_type) { +void ServerNotifierThread::OnInvalidate( + syncable::ModelType model_type, + const std::string& payload) { DCHECK_EQ(MessageLoop::current(), worker_message_loop()); DCHECK_GE(model_type, syncable::FIRST_REAL_MODEL_TYPE); DCHECK_LT(model_type, syncable::MODEL_TYPE_COUNT); @@ -75,7 +77,8 @@ void ServerNotifierThread::OnInvalidate(syncable::ModelType model_type) { syncable::ModelTypeBitSet model_types; model_types[model_type] = true; IncomingNotificationData notification_data; - notification_data.service_specific_data = model_types.to_string(); + notification_data.service_url = model_types.to_string(); + notification_data.service_specific_data = payload; observers_->Notify(&Observer::OnIncomingNotification, notification_data); } diff --git a/chrome/browser/sync/notifier/server_notifier_thread.h b/chrome/browser/sync/notifier/server_notifier_thread.h index 55b60fe..b0b9819 100644 --- a/chrome/browser/sync/notifier/server_notifier_thread.h +++ b/chrome/browser/sync/notifier/server_notifier_thread.h @@ -59,7 +59,14 @@ class ServerNotifierThread virtual void SendNotification(const OutgoingNotificationData& data); // ChromeInvalidationClient::Listener implementation. - virtual void OnInvalidate(syncable::ModelType model_type); + // We pass on two pieces of information to observers through the + // IncomingNotificationData. + // - the model type being invalidated, through IncomingNotificationData's + // service_url. + // - the invalidation payload for that model type, through + // IncomingNotificationData's service_specific_data. + virtual void OnInvalidate(syncable::ModelType model_type, + const std::string& payload); virtual void OnInvalidateAll(); // StateWriter implementation. |