diff options
author | rlarocque@chromium.org <rlarocque@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-03-21 22:14:35 +0000 |
---|---|---|
committer | rlarocque@chromium.org <rlarocque@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-03-21 22:14:35 +0000 |
commit | eb370fc0fba62ea44db5c35514fb3223523928cc (patch) | |
tree | 314febd8e19760c68cd7a20c1fd95bc5a26c1f97 /sync | |
parent | 560b54e7a49100618417e59a0f1589c864816b6a (diff) | |
download | chromium_src-eb370fc0fba62ea44db5c35514fb3223523928cc.zip chromium_src-eb370fc0fba62ea44db5c35514fb3223523928cc.tar.gz chromium_src-eb370fc0fba62ea44db5c35514fb3223523928cc.tar.bz2 |
sync: Expose ProtocolEvents on ProfileSyncService
Adds code to the sync engine to have it generate protocol events when it
contacts the server. These events are then sent through the
SyncSession, SyncManager, SyncBackendHostCore, SyncBackendHost, and
finally to the ProfileSyncService.
Objects on the UI thread can register with the ProfileSyncService as
observers of these events, though this CL does not introduce any of
these listeners.
BUG=349301
Review URL: https://codereview.chromium.org/203463005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@258685 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'sync')
34 files changed, 128 insertions, 25 deletions
diff --git a/sync/engine/DEPS b/sync/engine/DEPS index b43d31c..0978697 100644 --- a/sync/engine/DEPS +++ b/sync/engine/DEPS @@ -2,6 +2,7 @@ include_rules = [ "+sync/base", "+sync/internal_api/public/base", "+sync/internal_api/public/engine", + "+sync/internal_api/public/events", "+sync/internal_api/public/sessions", "+sync/internal_api/public/test", "+sync/internal_api/public/util", diff --git a/sync/engine/all_status.cc b/sync/engine/all_status.cc index 6fa98d3..d73f206 100644 --- a/sync/engine/all_status.cc +++ b/sync/engine/all_status.cc @@ -124,6 +124,8 @@ void AllStatus::OnThrottledTypesChanged(ModelTypeSet throttled_types) { void AllStatus::OnMigrationRequested(ModelTypeSet) {} +void AllStatus::OnProtocolEvent(const ProtocolEvent&) {} + SyncStatus AllStatus::status() const { base::AutoLock lock(mutex_); return status_; diff --git a/sync/engine/all_status.h b/sync/engine/all_status.h index add42e5..999f2f3 100644 --- a/sync/engine/all_status.h +++ b/sync/engine/all_status.h @@ -46,6 +46,7 @@ class AllStatus : public SyncEngineEventListener { virtual void OnRetryTimeChanged(base::Time retry_time) OVERRIDE; virtual void OnThrottledTypesChanged(ModelTypeSet throttled_types) OVERRIDE; virtual void OnMigrationRequested(ModelTypeSet types) OVERRIDE; + virtual void OnProtocolEvent(const ProtocolEvent& event) OVERRIDE; SyncStatus status() const; diff --git a/sync/engine/commit.cc b/sync/engine/commit.cc index 90b9742..92cf4d2 100644 --- a/sync/engine/commit.cc +++ b/sync/engine/commit.cc @@ -10,6 +10,8 @@ #include "sync/engine/commit_util.h" #include "sync/engine/syncer.h" #include "sync/engine/syncer_proto_util.h" +#include "sync/internal_api/public/events/commit_request_event.h" +#include "sync/internal_api/public/events/commit_response_event.h" #include "sync/sessions/sync_session.h" namespace syncer { @@ -97,11 +99,26 @@ SyncerError Commit::PostAndProcessResponse( } DVLOG(1) << "Sending commit message."; + + CommitRequestEvent request_event( + base::Time::Now(), + message_.commit().entries_size(), + request_types, + message_); + session->SendProtocolEvent(request_event); + TRACE_EVENT_BEGIN0("sync", "PostCommit"); const SyncerError post_result = SyncerProtoUtil::PostClientToServerMessage( &message_, &response_, session); TRACE_EVENT_END0("sync", "PostCommit"); + // TODO(rlarocque): Use result that includes errors captured later? + CommitResponseEvent response_event( + base::Time::Now(), + post_result, + response_); + session->SendProtocolEvent(response_event); + if (post_result != SYNCER_OK) { LOG(WARNING) << "Post commit failed"; return post_result; diff --git a/sync/engine/get_updates_delegate.cc b/sync/engine/get_updates_delegate.cc index 4697485..fe53841 100644 --- a/sync/engine/get_updates_delegate.cc +++ b/sync/engine/get_updates_delegate.cc @@ -6,6 +6,9 @@ #include "sync/engine/directory_update_handler.h" #include "sync/engine/get_updates_processor.h" +#include "sync/internal_api/public/events/configure_get_updates_request_event.h" +#include "sync/internal_api/public/events/normal_get_updates_request_event.h" +#include "sync/internal_api/public/events/poll_get_updates_request_event.h" namespace syncer { @@ -80,6 +83,13 @@ void NormalGetUpdatesDelegate::ApplyUpdates( NonPassiveApplyUpdates(status_controller, update_handler_map); } +scoped_ptr<ProtocolEvent> NormalGetUpdatesDelegate::GetNetworkRequestEvent( + base::Time timestamp, + const sync_pb::ClientToServerMessage& request) const { + return scoped_ptr<ProtocolEvent>( + new NormalGetUpdatesRequestEvent(timestamp, nudge_tracker_, request)); +} + ConfigureGetUpdatesDelegate::ConfigureGetUpdatesDelegate( sync_pb::GetUpdatesCallerInfo::GetUpdatesSource source) : source_(source) {} @@ -97,6 +107,16 @@ void ConfigureGetUpdatesDelegate::ApplyUpdates( PassiveApplyUpdates(status_controller, update_handler_map); } +scoped_ptr<ProtocolEvent> ConfigureGetUpdatesDelegate::GetNetworkRequestEvent( + base::Time timestamp, + const sync_pb::ClientToServerMessage& request) const { + return scoped_ptr<ProtocolEvent>( + new ConfigureGetUpdatesRequestEvent( + timestamp, + ConvertConfigureSourceToOrigin(source_), + request)); +} + sync_pb::SyncEnums::GetUpdatesOrigin ConfigureGetUpdatesDelegate::ConvertConfigureSourceToOrigin( sync_pb::GetUpdatesCallerInfo::GetUpdatesSource source) { @@ -136,4 +156,11 @@ void PollGetUpdatesDelegate::ApplyUpdates( NonPassiveApplyUpdates(status_controller, update_handler_map); } +scoped_ptr<ProtocolEvent> PollGetUpdatesDelegate::GetNetworkRequestEvent( + base::Time timestamp, + const sync_pb::ClientToServerMessage& request) const { + return scoped_ptr<ProtocolEvent>( + new PollGetUpdatesRequestEvent(timestamp, request)); +} + } // namespace syncer diff --git a/sync/engine/get_updates_delegate.h b/sync/engine/get_updates_delegate.h index 9ebc6d8..d897edf 100644 --- a/sync/engine/get_updates_delegate.h +++ b/sync/engine/get_updates_delegate.h @@ -5,6 +5,7 @@ #ifndef SYNC_ENGINE_GET_UPDATES_DELEGATE_H_ #define SYNC_ENGINE_GET_UPDATES_DELEGATE_H_ +#include "sync/internal_api/public/events/protocol_event.h" #include "sync/protocol/sync.pb.h" #include "sync/sessions/model_type_registry.h" #include "sync/sessions/nudge_tracker.h" @@ -31,6 +32,10 @@ class SYNC_EXPORT_PRIVATE GetUpdatesDelegate { virtual void ApplyUpdates( sessions::StatusController* session, UpdateHandlerMap* update_handler_map) const = 0; + + virtual scoped_ptr<ProtocolEvent> GetNetworkRequestEvent( + base::Time timestamp, + const sync_pb::ClientToServerMessage& request) const = 0; }; // Functionality specific to the normal GetUpdate request. @@ -48,6 +53,9 @@ class SYNC_EXPORT_PRIVATE NormalGetUpdatesDelegate : public GetUpdatesDelegate { sessions::StatusController* status, UpdateHandlerMap* update_handler_map) const OVERRIDE; + virtual scoped_ptr<ProtocolEvent> GetNetworkRequestEvent( + base::Time timestamp, + const sync_pb::ClientToServerMessage& request) const OVERRIDE; private: DISALLOW_COPY_AND_ASSIGN(NormalGetUpdatesDelegate); @@ -74,6 +82,9 @@ class SYNC_EXPORT_PRIVATE ConfigureGetUpdatesDelegate sessions::StatusController* status, UpdateHandlerMap* update_handler_map) const OVERRIDE; + virtual scoped_ptr<ProtocolEvent> GetNetworkRequestEvent( + base::Time timestamp, + const sync_pb::ClientToServerMessage& request) const OVERRIDE; private: DISALLOW_COPY_AND_ASSIGN(ConfigureGetUpdatesDelegate); @@ -98,6 +109,9 @@ class SYNC_EXPORT_PRIVATE PollGetUpdatesDelegate : public GetUpdatesDelegate { sessions::StatusController* status, UpdateHandlerMap* update_handler_map) const OVERRIDE; + virtual scoped_ptr<ProtocolEvent> GetNetworkRequestEvent( + base::Time timestamp, + const sync_pb::ClientToServerMessage& request) const OVERRIDE; private: DISALLOW_COPY_AND_ASSIGN(PollGetUpdatesDelegate); }; diff --git a/sync/engine/get_updates_processor.cc b/sync/engine/get_updates_processor.cc index 399c78c..a5ab59b 100644 --- a/sync/engine/get_updates_processor.cc +++ b/sync/engine/get_updates_processor.cc @@ -10,6 +10,7 @@ #include "sync/engine/get_updates_delegate.h" #include "sync/engine/syncer_proto_util.h" #include "sync/engine/update_handler.h" +#include "sync/internal_api/public/events/get_updates_response_event.h" #include "sync/protocol/sync.pb.h" #include "sync/sessions/status_controller.h" #include "sync/sessions/sync_session.h" @@ -193,6 +194,9 @@ SyncerError GetUpdatesProcessor::ExecuteDownloadUpdates( CopyClientDebugInfo(session->context()->debug_info_getter(), debug_info); } + session->SendProtocolEvent( + *(delegate_.GetNetworkRequestEvent(base::Time::Now(), *msg))); + SyncerError result = SyncerProtoUtil::PostClientToServerMessage( msg, &update_response, @@ -202,6 +206,10 @@ SyncerError GetUpdatesProcessor::ExecuteDownloadUpdates( update_response); if (result != SYNCER_OK) { + GetUpdatesResponseEvent response_event( + base::Time::Now(), update_response, result); + session->SendProtocolEvent(response_event); + LOG(ERROR) << "PostClientToServerMessage() failed during GetUpdates"; return result; } @@ -225,9 +233,15 @@ SyncerError GetUpdatesProcessor::ExecuteDownloadUpdates( HandleGetEncryptionKeyResponse(update_response, dir)); } - return ProcessResponse(update_response.get_updates(), - request_types, - status); + SyncerError process_result = ProcessResponse(update_response.get_updates(), + request_types, + status); + + GetUpdatesResponseEvent response_event( + base::Time::Now(), update_response, process_result); + session->SendProtocolEvent(response_event); + + return process_result; } SyncerError GetUpdatesProcessor::ProcessResponse( diff --git a/sync/engine/sync_engine_event_listener.h b/sync/engine/sync_engine_event_listener.h index 35fc05e..d5678a9 100644 --- a/sync/engine/sync_engine_event_listener.h +++ b/sync/engine/sync_engine_event_listener.h @@ -13,6 +13,7 @@ namespace syncer { struct SyncProtocolError; struct SyncCycleEvent; +class ProtocolEvent; class SYNC_EXPORT_PRIVATE SyncEngineEventListener { public: @@ -36,6 +37,9 @@ class SYNC_EXPORT_PRIVATE SyncEngineEventListener { // This event is sent when the server requests a migration. virtual void OnMigrationRequested(ModelTypeSet migration_types) = 0; + // Emits events when sync communicates with the server. + virtual void OnProtocolEvent(const ProtocolEvent& event) = 0; + protected: virtual ~SyncEngineEventListener(); }; diff --git a/sync/engine/sync_scheduler_impl.cc b/sync/engine/sync_scheduler_impl.cc index a9c6359..2240cd6 100644 --- a/sync/engine/sync_scheduler_impl.cc +++ b/sync/engine/sync_scheduler_impl.cc @@ -744,6 +744,7 @@ void SyncSchedulerImpl::Unthrottle() { // We're no longer throttled, so clear the wait interval. wait_interval_.reset(); NotifyRetryTime(base::Time()); + NotifyThrottledTypesChanged(nudge_tracker_.GetThrottledTypes()); // We treat this as a 'canary' in the sense that it was originally scheduled // to run some time ago, failed, and we now want to retry, versus a job that @@ -815,6 +816,7 @@ void SyncSchedulerImpl::OnThrottled(const base::TimeDelta& throttle_duration) { wait_interval_.reset(new WaitInterval(WaitInterval::THROTTLED, throttle_duration)); NotifyRetryTime(base::Time::Now() + wait_interval_->length); + NotifyThrottledTypesChanged(ModelTypeSet::All()); } void SyncSchedulerImpl::OnTypesThrottled( diff --git a/sync/engine/syncer_proto_util_unittest.cc b/sync/engine/syncer_proto_util_unittest.cc index d43b350..93f9088 100644 --- a/sync/engine/syncer_proto_util_unittest.cc +++ b/sync/engine/syncer_proto_util_unittest.cc @@ -39,13 +39,11 @@ class MockDelegate : public sessions::SyncSession::Delegate { MockDelegate() {} ~MockDelegate() {} - MOCK_METHOD0(IsSyncingCurrentlySilenced, bool()); MOCK_METHOD1(OnReceivedShortPollIntervalUpdate, void(const base::TimeDelta&)); MOCK_METHOD1(OnReceivedLongPollIntervalUpdate ,void(const base::TimeDelta&)); MOCK_METHOD1(OnReceivedSessionsCommitDelay, void(const base::TimeDelta&)); MOCK_METHOD1(OnReceivedClientInvalidationHintBufferSize, void(int)); MOCK_METHOD1(OnSyncProtocolError, void(const SyncProtocolError&)); - MOCK_METHOD1(OnSilencedUntil, void(const base::TimeTicks&)); }; // Builds a ClientToServerResponse with some data type ids, including diff --git a/sync/engine/syncer_unittest.cc b/sync/engine/syncer_unittest.cc index d0a2ab4..7a3afe3 100644 --- a/sync/engine/syncer_unittest.cc +++ b/sync/engine/syncer_unittest.cc @@ -152,6 +152,7 @@ class SyncerTest : public testing::Test, } virtual void OnReceivedGuRetryDelay(const base::TimeDelta& delay) OVERRIDE {} virtual void OnReceivedMigrationRequest(ModelTypeSet types) OVERRIDE {} + virtual void OnProtocolEvent(const ProtocolEvent& event) OVERRIDE {} virtual void OnSyncProtocolError(const SyncProtocolError& error) OVERRIDE {} void GetModelSafeRoutingInfo(ModelSafeRoutingInfo* out) { diff --git a/sync/internal_api/debug_info_event_listener.cc b/sync/internal_api/debug_info_event_listener.cc index 6319a03..b3d5505 100644 --- a/sync/internal_api/debug_info_event_listener.cc +++ b/sync/internal_api/debug_info_event_listener.cc @@ -118,6 +118,8 @@ void DebugInfoEventListener::OnActionableError( void DebugInfoEventListener::OnMigrationRequested(ModelTypeSet types) {} +void DebugInfoEventListener::OnProtocolEvent(const ProtocolEvent& event) {} + void DebugInfoEventListener::OnNudgeFromDatatype(ModelType datatype) { DCHECK(thread_checker_.CalledOnValidThread()); sync_pb::DebugEventInfo event_info; diff --git a/sync/internal_api/debug_info_event_listener.h b/sync/internal_api/debug_info_event_listener.h index d9a77c7..1f71682 100644 --- a/sync/internal_api/debug_info_event_listener.h +++ b/sync/internal_api/debug_info_event_listener.h @@ -51,6 +51,7 @@ class SYNC_EXPORT_PRIVATE DebugInfoEventListener virtual void OnActionableError( const SyncProtocolError& sync_error) OVERRIDE; virtual void OnMigrationRequested(ModelTypeSet types) OVERRIDE; + virtual void OnProtocolEvent(const ProtocolEvent& event) OVERRIDE; // SyncEncryptionHandler::Observer implementation. virtual void OnPassphraseRequired( diff --git a/sync/internal_api/events/commit_request_event.cc b/sync/internal_api/events/commit_request_event.cc index bed23d3..0a1de1f 100644 --- a/sync/internal_api/events/commit_request_event.cc +++ b/sync/internal_api/events/commit_request_event.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/internal_api/events/commit_request_event.h" +#include "sync/internal_api/public/events/commit_request_event.h" #include "base/format_macros.h" #include "base/strings/stringprintf.h" diff --git a/sync/internal_api/events/commit_response_event.cc b/sync/internal_api/events/commit_response_event.cc index ec51f5e..c263e94 100644 --- a/sync/internal_api/events/commit_response_event.cc +++ b/sync/internal_api/events/commit_response_event.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/internal_api/events/commit_response_event.h" +#include "sync/internal_api/public/events/commit_response_event.h" #include "base/strings/stringprintf.h" #include "sync/protocol/proto_value_conversions.h" diff --git a/sync/internal_api/events/configure_get_updates_request_event.cc b/sync/internal_api/events/configure_get_updates_request_event.cc index 252ae0a..8b487b6 100644 --- a/sync/internal_api/events/configure_get_updates_request_event.cc +++ b/sync/internal_api/events/configure_get_updates_request_event.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/internal_api/events/configure_get_updates_request_event.h" +#include "sync/internal_api/public/events/configure_get_updates_request_event.h" #include "base/strings/stringprintf.h" #include "sync/protocol/proto_enum_conversions.h" diff --git a/sync/internal_api/events/get_updates_response_event.cc b/sync/internal_api/events/get_updates_response_event.cc index 17c0e8e..50bc551 100644 --- a/sync/internal_api/events/get_updates_response_event.cc +++ b/sync/internal_api/events/get_updates_response_event.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/internal_api/events/get_updates_response_event.h" +#include "sync/internal_api/public/events/get_updates_response_event.h" #include "base/strings/stringprintf.h" #include "sync/protocol/proto_value_conversions.h" diff --git a/sync/internal_api/events/normal_get_updates_request_event.cc b/sync/internal_api/events/normal_get_updates_request_event.cc index d6a2f884..f5d6cd4 100644 --- a/sync/internal_api/events/normal_get_updates_request_event.cc +++ b/sync/internal_api/events/normal_get_updates_request_event.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/internal_api/events/normal_get_updates_request_event.h" +#include "sync/internal_api/public/events/normal_get_updates_request_event.h" #include "base/strings/stringprintf.h" #include "sync/protocol/proto_value_conversions.h" diff --git a/sync/internal_api/events/poll_get_updates_request_event.cc b/sync/internal_api/events/poll_get_updates_request_event.cc index 802d4cb..c6eecb9 100644 --- a/sync/internal_api/events/poll_get_updates_request_event.cc +++ b/sync/internal_api/events/poll_get_updates_request_event.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/internal_api/events/poll_get_updates_request_event.h" +#include "sync/internal_api/public/events/poll_get_updates_request_event.h" #include "sync/protocol/proto_value_conversions.h" diff --git a/sync/internal_api/js_sync_manager_observer.cc b/sync/internal_api/js_sync_manager_observer.cc index 57df9d3..b5f8452 100644 --- a/sync/internal_api/js_sync_manager_observer.cc +++ b/sync/internal_api/js_sync_manager_observer.cc @@ -60,6 +60,9 @@ void JsSyncManagerObserver::OnActionableError( JsEventDetails(&details)); } +void JsSyncManagerObserver::OnProtocolEvent( + const ProtocolEvent& event) { } + void JsSyncManagerObserver::OnMigrationRequested(ModelTypeSet types) { } void JsSyncManagerObserver::OnInitializationComplete( diff --git a/sync/internal_api/js_sync_manager_observer.h b/sync/internal_api/js_sync_manager_observer.h index a30a40b..6f22005 100644 --- a/sync/internal_api/js_sync_manager_observer.h +++ b/sync/internal_api/js_sync_manager_observer.h @@ -42,6 +42,7 @@ class SYNC_EXPORT_PRIVATE JsSyncManagerObserver : public SyncManager::Observer { syncer::ModelTypeSet restored_types) OVERRIDE; virtual void OnActionableError( const SyncProtocolError& sync_protocol_error) OVERRIDE; + virtual void OnProtocolEvent(const ProtocolEvent& event) OVERRIDE; virtual void OnMigrationRequested( syncer::ModelTypeSet types) OVERRIDE; diff --git a/sync/internal_api/events/commit_request_event.h b/sync/internal_api/public/events/commit_request_event.h index cf379a9..cf379a9 100644 --- a/sync/internal_api/events/commit_request_event.h +++ b/sync/internal_api/public/events/commit_request_event.h diff --git a/sync/internal_api/events/commit_response_event.h b/sync/internal_api/public/events/commit_response_event.h index e1f1797..e1f1797 100644 --- a/sync/internal_api/events/commit_response_event.h +++ b/sync/internal_api/public/events/commit_response_event.h diff --git a/sync/internal_api/events/configure_get_updates_request_event.h b/sync/internal_api/public/events/configure_get_updates_request_event.h index eb783ab..eb783ab 100644 --- a/sync/internal_api/events/configure_get_updates_request_event.h +++ b/sync/internal_api/public/events/configure_get_updates_request_event.h diff --git a/sync/internal_api/events/get_updates_response_event.h b/sync/internal_api/public/events/get_updates_response_event.h index 1d31ccc..1d31ccc 100644 --- a/sync/internal_api/events/get_updates_response_event.h +++ b/sync/internal_api/public/events/get_updates_response_event.h diff --git a/sync/internal_api/events/normal_get_updates_request_event.h b/sync/internal_api/public/events/normal_get_updates_request_event.h index 7d0b874..7d0b874 100644 --- a/sync/internal_api/events/normal_get_updates_request_event.h +++ b/sync/internal_api/public/events/normal_get_updates_request_event.h diff --git a/sync/internal_api/events/poll_get_updates_request_event.h b/sync/internal_api/public/events/poll_get_updates_request_event.h index d4a679c..d4a679c 100644 --- a/sync/internal_api/events/poll_get_updates_request_event.h +++ b/sync/internal_api/public/events/poll_get_updates_request_event.h diff --git a/sync/internal_api/public/sync_manager.h b/sync/internal_api/public/sync_manager.h index fa2e585..6f6d9fc 100644 --- a/sync/internal_api/public/sync_manager.h +++ b/sync/internal_api/public/sync_manager.h @@ -20,6 +20,7 @@ #include "sync/internal_api/public/configure_reason.h" #include "sync/internal_api/public/engine/model_safe_worker.h" #include "sync/internal_api/public/engine/sync_status.h" +#include "sync/internal_api/public/events/protocol_event.h" #include "sync/internal_api/public/sync_encryption_handler.h" #include "sync/internal_api/public/util/report_unrecoverable_error_function.h" #include "sync/internal_api/public/util/unrecoverable_error_handler.h" @@ -43,6 +44,7 @@ class InternalComponentsFactory; class JsBackend; class JsEventHandler; class SyncEncryptionHandler; +class ProtocolEvent; class SyncScheduler; struct UserShare; class CancelationSignal; @@ -196,6 +198,8 @@ class SYNC_EXPORT SyncManager : public syncer::InvalidationHandler { virtual void OnMigrationRequested(ModelTypeSet types) = 0; + virtual void OnProtocolEvent(const ProtocolEvent& event) = 0; + protected: virtual ~Observer(); }; diff --git a/sync/internal_api/sync_manager_impl.cc b/sync/internal_api/sync_manager_impl.cc index 501f887..8ecb29f 100644 --- a/sync/internal_api/sync_manager_impl.cc +++ b/sync/internal_api/sync_manager_impl.cc @@ -899,7 +899,6 @@ void SyncManagerImpl::RequestNudgeForDataTypes( base::TimeDelta nudge_delay = NudgeStrategy::GetNudgeDelayTimeDelta( types.First().Get(), this); - allstatus_.IncrementNudgeCounter(NUDGE_SOURCE_LOCAL); scheduler_->ScheduleLocalNudge(nudge_delay, types, nudge_location); @@ -943,6 +942,11 @@ void SyncManagerImpl::OnMigrationRequested(ModelTypeSet types) { OnMigrationRequested(types)); } +void SyncManagerImpl::OnProtocolEvent(const ProtocolEvent& event) { + FOR_EACH_OBSERVER(SyncManager::Observer, observers_, + OnProtocolEvent(event)); +} + void SyncManagerImpl::SetJsEventHandler( const WeakHandle<JsEventHandler>& event_handler) { js_sync_manager_observer_.SetJsEventHandler(event_handler); @@ -1029,11 +1033,9 @@ void SyncManagerImpl::OnIncomingInvalidation( if (invalidation_map.Empty()) { LOG(WARNING) << "Sync received invalidation without any type information."; } else { - allstatus_.IncrementNudgeCounter(NUDGE_SOURCE_NOTIFICATION); scheduler_->ScheduleInvalidationNudge( TimeDelta::FromMilliseconds(kSyncSchedulerDelayMsec), invalidation_map, FROM_HERE); - allstatus_.IncrementNotificationsReceived(); debug_info_event_listener_.OnIncomingNotification(invalidation_map); } } @@ -1045,7 +1047,6 @@ void SyncManagerImpl::RefreshTypes(ModelTypeSet types) { if (types.Empty()) { LOG(WARNING) << "Sync received refresh request with no types specified."; } else { - allstatus_.IncrementNudgeCounter(NUDGE_SOURCE_LOCAL_REFRESH); scheduler_->ScheduleLocalRefreshRequest( TimeDelta::FromMilliseconds(kSyncRefreshDelayMsec), types, FROM_HERE); diff --git a/sync/internal_api/sync_manager_impl.h b/sync/internal_api/sync_manager_impl.h index e2b3fb4..7189026 100644 --- a/sync/internal_api/sync_manager_impl.h +++ b/sync/internal_api/sync_manager_impl.h @@ -142,6 +142,7 @@ class SYNC_EXPORT_PRIVATE SyncManagerImpl : virtual void OnRetryTimeChanged(base::Time retry_time) OVERRIDE; virtual void OnThrottledTypesChanged(ModelTypeSet throttled_types) OVERRIDE; virtual void OnMigrationRequested(ModelTypeSet types) OVERRIDE; + virtual void OnProtocolEvent(const ProtocolEvent& event) OVERRIDE; // ServerConnectionEventListener implementation. virtual void OnServerConnectionEvent( diff --git a/sync/internal_api/sync_manager_impl_unittest.cc b/sync/internal_api/sync_manager_impl_unittest.cc index 064db9e..7da7070 100644 --- a/sync/internal_api/sync_manager_impl_unittest.cc +++ b/sync/internal_api/sync_manager_impl_unittest.cc @@ -29,6 +29,7 @@ #include "sync/internal_api/public/change_record.h" #include "sync/internal_api/public/engine/model_safe_worker.h" #include "sync/internal_api/public/engine/polling_constants.h" +#include "sync/internal_api/public/events/protocol_event.h" #include "sync/internal_api/public/http_post_provider_factory.h" #include "sync/internal_api/public/http_post_provider_interface.h" #include "sync/internal_api/public/read_node.h" @@ -646,10 +647,9 @@ class SyncManagerObserverMock : public SyncManager::Observer { syncer::ModelTypeSet)); // NOLINT MOCK_METHOD1(OnConnectionStatusChange, void(ConnectionStatus)); // NOLINT MOCK_METHOD1(OnUpdatedToken, void(const std::string&)); // NOLINT - MOCK_METHOD1(OnActionableError, - void(const SyncProtocolError&)); // NOLINT - MOCK_METHOD1(OnMigrationRequested, - void(syncer::ModelTypeSet)); // NOLINT + MOCK_METHOD1(OnActionableError, void(const SyncProtocolError&)); // NOLINT + MOCK_METHOD1(OnMigrationRequested, void(syncer::ModelTypeSet)); // NOLINT + MOCK_METHOD1(OnProtocolEvent, void(const ProtocolEvent&)); // NOLINT }; class SyncEncryptionHandlerObserverMock diff --git a/sync/sessions/sync_session.cc b/sync/sessions/sync_session.cc index 957cfbf..e352e70 100644 --- a/sync/sessions/sync_session.cc +++ b/sync/sessions/sync_session.cc @@ -89,5 +89,11 @@ void SyncSession::SendEventNotification(SyncCycleEvent::EventCause cause) { OnSyncCycleEvent(event)); } +void SyncSession::SendProtocolEvent(const ProtocolEvent& event) { + FOR_EACH_OBSERVER(SyncEngineEventListener, + *(context_->listeners()), + OnProtocolEvent(event)); +} + } // namespace sessions } // namespace syncer diff --git a/sync/sessions/sync_session.h b/sync/sessions/sync_session.h index 2a96fbc..d61a792 100644 --- a/sync/sessions/sync_session.h +++ b/sync/sessions/sync_session.h @@ -30,6 +30,7 @@ namespace syncer { class ModelSafeWorker; +class ProtocolEvent; namespace sessions { @@ -110,6 +111,8 @@ class SYNC_EXPORT_PRIVATE SyncSession { sync_pb::GetUpdatesCallerInfo::GetUpdatesSource source); void SendEventNotification(SyncCycleEvent::EventCause cause); + void SendProtocolEvent(const ProtocolEvent& event); + // TODO(akalin): Split this into context() and mutable_context(). SyncSessionContext* context() const { return context_; } Delegate* delegate() const { return delegate_; } diff --git a/sync/sync_internal_api.gypi b/sync/sync_internal_api.gypi index 77416eb..8f46442 100644 --- a/sync/sync_internal_api.gypi +++ b/sync/sync_internal_api.gypi @@ -25,17 +25,11 @@ 'internal_api/debug_info_event_listener.h', 'internal_api/delete_journal.cc', 'internal_api/events/commit_request_event.cc', - 'internal_api/events/commit_request_event.h', 'internal_api/events/commit_response_event.cc', - 'internal_api/events/commit_response_event.h', 'internal_api/events/configure_get_updates_request_event.cc', - 'internal_api/events/configure_get_updates_request_event.h', 'internal_api/events/get_updates_response_event.cc', - 'internal_api/events/get_updates_response_event.h', 'internal_api/events/normal_get_updates_request_event.cc', - 'internal_api/events/normal_get_updates_request_event.h', 'internal_api/events/poll_get_updates_request_event.cc', - 'internal_api/events/poll_get_updates_request_event.h', 'internal_api/events/protocol_event.cc', 'internal_api/http_bridge.cc', 'internal_api/http_bridge_network_resources.cc', @@ -81,6 +75,12 @@ 'internal_api/public/engine/polling_constants.h', 'internal_api/public/engine/sync_status.cc', 'internal_api/public/engine/sync_status.h', + 'internal_api/public/events/commit_request_event.h', + 'internal_api/public/events/commit_response_event.h', + 'internal_api/public/events/configure_get_updates_request_event.h', + 'internal_api/public/events/get_updates_response_event.h', + 'internal_api/public/events/normal_get_updates_request_event.h', + 'internal_api/public/events/poll_get_updates_request_event.h', 'internal_api/public/events/protocol_event.h', 'internal_api/public/http_bridge.h', 'internal_api/public/http_bridge_network_resources.h', |