summaryrefslogtreecommitdiffstats
path: root/sync/internal_api/public
diff options
context:
space:
mode:
authorrlarocque@chromium.org <rlarocque@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-03-21 22:14:35 +0000
committerrlarocque@chromium.org <rlarocque@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-03-21 22:14:35 +0000
commiteb370fc0fba62ea44db5c35514fb3223523928cc (patch)
tree314febd8e19760c68cd7a20c1fd95bc5a26c1f97 /sync/internal_api/public
parent560b54e7a49100618417e59a0f1589c864816b6a (diff)
downloadchromium_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/internal_api/public')
-rw-r--r--sync/internal_api/public/events/commit_request_event.h49
-rw-r--r--sync/internal_api/public/events/commit_response_event.h47
-rw-r--r--sync/internal_api/public/events/configure_get_updates_request_event.h41
-rw-r--r--sync/internal_api/public/events/get_updates_response_event.h46
-rw-r--r--sync/internal_api/public/events/normal_get_updates_request_event.h60
-rw-r--r--sync/internal_api/public/events/poll_get_updates_request_event.h44
-rw-r--r--sync/internal_api/public/sync_manager.h4
7 files changed, 291 insertions, 0 deletions
diff --git a/sync/internal_api/public/events/commit_request_event.h b/sync/internal_api/public/events/commit_request_event.h
new file mode 100644
index 0000000..cf379a9
--- /dev/null
+++ b/sync/internal_api/public/events/commit_request_event.h
@@ -0,0 +1,49 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef SYNC_INTERNAL_API_EVENTS_COMMIT_REQUEST_EVENT_H
+#define SYNC_INTERNAL_API_EVENTS_COMMIT_REQUEST_EVENT_H
+
+#include <cstddef>
+
+#include "base/memory/scoped_ptr.h"
+#include "base/time/time.h"
+#include "base/values.h"
+#include "sync/internal_api/public/base/model_type.h"
+#include "sync/internal_api/public/events/protocol_event.h"
+#include "sync/protocol/sync.pb.h"
+
+namespace syncer {
+
+// An event representing a commit request message sent to the server.
+class CommitRequestEvent : public ProtocolEvent {
+ public:
+ CommitRequestEvent(
+ base::Time timestamp,
+ size_t num_items,
+ ModelTypeSet contributing_types,
+ const sync_pb::ClientToServerMessage& request);
+ virtual ~CommitRequestEvent();
+
+ virtual base::Time GetTimestamp() const OVERRIDE;
+ virtual std::string GetType() const OVERRIDE;
+ virtual std::string GetDetails() const OVERRIDE;
+ virtual scoped_ptr<base::DictionaryValue> GetProtoMessage() const OVERRIDE;
+ virtual scoped_ptr<ProtocolEvent> Clone() const OVERRIDE;
+
+ static scoped_ptr<base::DictionaryValue> ToValue(
+ const ProtocolEvent& event);
+
+ private:
+ const base::Time timestamp_;
+ const size_t num_items_;
+ const ModelTypeSet contributing_types_;
+ const sync_pb::ClientToServerMessage request_;
+
+ DISALLOW_COPY_AND_ASSIGN(CommitRequestEvent);
+};
+
+} // namespace syncer
+
+#endif // SYNC_INTERNAL_API_EVENTS_COMMIT_REQUEST_EVENT_H
diff --git a/sync/internal_api/public/events/commit_response_event.h b/sync/internal_api/public/events/commit_response_event.h
new file mode 100644
index 0000000..e1f1797
--- /dev/null
+++ b/sync/internal_api/public/events/commit_response_event.h
@@ -0,0 +1,47 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef SYNC_INTERNAL_API_EVENTS_COMMIT_RESPONSE_EVENT_H_
+#define SYNC_INTERNAL_API_EVENTS_COMMIT_RESPONSE_EVENT_H_
+
+#include <cstddef>
+
+#include "base/memory/scoped_ptr.h"
+#include "base/time/time.h"
+#include "base/values.h"
+#include "sync/internal_api/public/events/protocol_event.h"
+#include "sync/internal_api/public/util/syncer_error.h"
+#include "sync/protocol/sync.pb.h"
+
+namespace syncer {
+
+// An event representing a commit response event from the server.
+class CommitResponseEvent : public ProtocolEvent {
+ public:
+ CommitResponseEvent(
+ base::Time timestamp,
+ SyncerError result,
+ const sync_pb::ClientToServerResponse& response);
+ virtual ~CommitResponseEvent();
+
+ virtual base::Time GetTimestamp() const OVERRIDE;
+ virtual std::string GetType() const OVERRIDE;
+ virtual std::string GetDetails() const OVERRIDE;
+ virtual scoped_ptr<base::DictionaryValue> GetProtoMessage() const OVERRIDE;
+ virtual scoped_ptr<ProtocolEvent> Clone() const OVERRIDE;
+
+ static scoped_ptr<base::DictionaryValue> ToValue(
+ const ProtocolEvent& event);
+
+ private:
+ const base::Time timestamp_;
+ const SyncerError result_;
+ const sync_pb::ClientToServerResponse response_;
+
+ DISALLOW_COPY_AND_ASSIGN(CommitResponseEvent);
+};
+
+} // namespace syncer
+
+#endif // SYNC_INTERNAL_API_EVENTS_COMMIT_RESPONSE_EVENT_H_
diff --git a/sync/internal_api/public/events/configure_get_updates_request_event.h b/sync/internal_api/public/events/configure_get_updates_request_event.h
new file mode 100644
index 0000000..eb783ab
--- /dev/null
+++ b/sync/internal_api/public/events/configure_get_updates_request_event.h
@@ -0,0 +1,41 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef SYNC_INTERNAL_API_EVENTS_CONFIGURE_GET_UPDATES_REQUEST_H
+#define SYNC_INTERNAL_API_EVENTS_CONFIGURE_GET_UPDATES_REQUEST_H
+
+#include "base/memory/scoped_ptr.h"
+#include "base/time/time.h"
+#include "base/values.h"
+#include "sync/internal_api/public/events/protocol_event.h"
+#include "sync/protocol/sync.pb.h"
+
+namespace syncer {
+
+// An event representing a configure GetUpdates request to the server.
+class ConfigureGetUpdatesRequestEvent : public ProtocolEvent {
+ public:
+ ConfigureGetUpdatesRequestEvent(
+ base::Time timestamp,
+ sync_pb::SyncEnums::GetUpdatesOrigin origin,
+ const sync_pb::ClientToServerMessage& request);
+ virtual ~ConfigureGetUpdatesRequestEvent();
+
+ virtual base::Time GetTimestamp() const OVERRIDE;
+ virtual std::string GetType() const OVERRIDE;
+ virtual std::string GetDetails() const OVERRIDE;
+ virtual scoped_ptr<base::DictionaryValue> GetProtoMessage() const OVERRIDE;
+ virtual scoped_ptr<ProtocolEvent> Clone() const OVERRIDE;
+
+ private:
+ const base::Time timestamp_;
+ const sync_pb::SyncEnums::GetUpdatesOrigin origin_;
+ const sync_pb::ClientToServerMessage request_;
+
+ DISALLOW_COPY_AND_ASSIGN(ConfigureGetUpdatesRequestEvent);
+};
+
+} // namespace syncer
+
+#endif // SYNC_INTERNAL_API_EVENTS_CONFIGURE_GET_UPDATES_REQUEST_H
diff --git a/sync/internal_api/public/events/get_updates_response_event.h b/sync/internal_api/public/events/get_updates_response_event.h
new file mode 100644
index 0000000..1d31ccc
--- /dev/null
+++ b/sync/internal_api/public/events/get_updates_response_event.h
@@ -0,0 +1,46 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef SYNC_INTERNAL_API_EVENTS_GET_UPDATES_RESPONSE_EVENT_H
+#define SYNC_INTERNAL_API_EVENTS_GET_UPDATES_RESPONSE_EVENT_H
+
+#include "base/memory/scoped_ptr.h"
+#include "base/time/time.h"
+#include "base/values.h"
+#include "sync/internal_api/public/events/protocol_event.h"
+#include "sync/internal_api/public/util/syncer_error.h"
+#include "sync/protocol/sync.pb.h"
+
+namespace syncer {
+
+// An event representing a GetUpdates response event from the server.
+//
+// Unlike the events for the request message, the response events are generic
+// and do not vary for each type of GetUpdate cycle.
+class GetUpdatesResponseEvent : public ProtocolEvent {
+ public:
+ GetUpdatesResponseEvent(
+ base::Time timestamp,
+ const sync_pb::ClientToServerResponse& response,
+ SyncerError error);
+
+ virtual ~GetUpdatesResponseEvent();
+
+ virtual base::Time GetTimestamp() const OVERRIDE;
+ virtual std::string GetType() const OVERRIDE;
+ virtual std::string GetDetails() const OVERRIDE;
+ virtual scoped_ptr<base::DictionaryValue> GetProtoMessage() const OVERRIDE;
+ virtual scoped_ptr<ProtocolEvent> Clone() const OVERRIDE;
+
+ private:
+ const base::Time timestamp_;
+ const sync_pb::ClientToServerResponse response_;
+ const SyncerError error_;
+
+ DISALLOW_COPY_AND_ASSIGN(GetUpdatesResponseEvent);
+};
+
+} // namespace syncer
+
+#endif // SYNC_INTERNAL_API_EVENTS_GET_UPDATES_RESPONSE_EVENT_H
diff --git a/sync/internal_api/public/events/normal_get_updates_request_event.h b/sync/internal_api/public/events/normal_get_updates_request_event.h
new file mode 100644
index 0000000..7d0b874
--- /dev/null
+++ b/sync/internal_api/public/events/normal_get_updates_request_event.h
@@ -0,0 +1,60 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef SYNC_INTERNAL_API_EVENTS_NORMAL_GET_UPDATES_REQUEST_H
+#define SYNC_INTERNAL_API_EVENTS_NORMAL_GET_UPDATES_REQUEST_H
+
+#include "base/memory/scoped_ptr.h"
+#include "base/time/time.h"
+#include "base/values.h"
+#include "sync/internal_api/public/base/model_type.h"
+#include "sync/internal_api/public/events/protocol_event.h"
+#include "sync/protocol/sync.pb.h"
+
+namespace syncer {
+
+namespace sessions {
+class NudgeTracker;
+} // namespace sessions
+
+// An event representing a 'normal mode' GetUpdate request to the server.
+class NormalGetUpdatesRequestEvent : public ProtocolEvent {
+ public:
+ NormalGetUpdatesRequestEvent(
+ base::Time timestamp,
+ const sessions::NudgeTracker& nudge_tracker,
+ const sync_pb::ClientToServerMessage& request);
+
+ virtual ~NormalGetUpdatesRequestEvent();
+
+ virtual base::Time GetTimestamp() const OVERRIDE;
+ virtual std::string GetType() const OVERRIDE;
+ virtual std::string GetDetails() const OVERRIDE;
+ virtual scoped_ptr<base::DictionaryValue> GetProtoMessage() const OVERRIDE;
+ virtual scoped_ptr<ProtocolEvent> Clone() const OVERRIDE;
+
+ private:
+ NormalGetUpdatesRequestEvent(
+ base::Time timestamp,
+ ModelTypeSet nudged_types,
+ ModelTypeSet notified_types,
+ ModelTypeSet refresh_requested_types,
+ bool is_retry,
+ sync_pb::ClientToServerMessage request);
+
+ const base::Time timestamp_;
+
+ const ModelTypeSet nudged_types_;
+ const ModelTypeSet notified_types_;
+ const ModelTypeSet refresh_requested_types_;
+ const bool is_retry_;
+
+ const sync_pb::ClientToServerMessage request_;
+
+ DISALLOW_COPY_AND_ASSIGN(NormalGetUpdatesRequestEvent);
+};
+
+}
+
+#endif // SYNC_INTERNAL_API_EVENTS_NORMAL_GET_UPDATES_REQUEST_H
diff --git a/sync/internal_api/public/events/poll_get_updates_request_event.h b/sync/internal_api/public/events/poll_get_updates_request_event.h
new file mode 100644
index 0000000..d4a679c
--- /dev/null
+++ b/sync/internal_api/public/events/poll_get_updates_request_event.h
@@ -0,0 +1,44 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef SYNC_INTERNAL_API_EVENTS_POLL_GET_UPDATES_REQUEST_H
+#define SYNC_INTERNAL_API_EVENTS_POLL_GET_UPDATES_REQUEST_H
+
+#include "base/memory/scoped_ptr.h"
+#include "base/time/time.h"
+#include "base/values.h"
+#include "sync/internal_api/public/base/model_type.h"
+#include "sync/internal_api/public/events/protocol_event.h"
+#include "sync/protocol/sync.pb.h"
+
+namespace syncer {
+
+namespace sessions {
+class NudgeTracker;
+} // namespace sessions
+
+// An event representing a poll request sent to the server.
+class PollGetUpdatesRequestEvent : public ProtocolEvent {
+ public:
+ PollGetUpdatesRequestEvent(
+ base::Time timestamp,
+ const sync_pb::ClientToServerMessage& request);
+ virtual ~PollGetUpdatesRequestEvent();
+
+ virtual base::Time GetTimestamp() const OVERRIDE;
+ virtual std::string GetType() const OVERRIDE;
+ virtual std::string GetDetails() const OVERRIDE;
+ virtual scoped_ptr<base::DictionaryValue> GetProtoMessage() const OVERRIDE;
+ virtual scoped_ptr<ProtocolEvent> Clone() const OVERRIDE;
+
+ private:
+ const base::Time timestamp_;
+ const sync_pb::ClientToServerMessage request_;
+
+ DISALLOW_COPY_AND_ASSIGN(PollGetUpdatesRequestEvent);
+};
+
+}
+
+#endif // SYNC_INTERNAL_API_EVENTS_POLL_GET_UPDATES_REQUEST_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();
};