diff options
author | rlarocque@chromium.org <rlarocque@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-03-18 18:44:49 +0000 |
---|---|---|
committer | rlarocque@chromium.org <rlarocque@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-03-18 18:44:49 +0000 |
commit | e480e169e72bceecef04fe63c3bfea1f201af3bd (patch) | |
tree | 98a47302e51322f715095a49712bf8bc3a856fae /sync/internal_api/public | |
parent | 392767f9bea403dc9274b2ce3146ad027d6adb4d (diff) | |
download | chromium_src-e480e169e72bceecef04fe63c3bfea1f201af3bd.zip chromium_src-e480e169e72bceecef04fe63c3bfea1f201af3bd.tar.gz chromium_src-e480e169e72bceecef04fe63c3bfea1f201af3bd.tar.bz2 |
sync: Add definitions for ProtocolEvents
This is a part of a much larger change list. The eventual goal is to
have these ProtocolEvents emitted all the way to the UI thread, where
they can be displayed on about:sync.
This CL just defines the objects without using them.
BUG=349301
R=tim@chromium.org
Review URL: https://codereview.chromium.org/187083003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@257700 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'sync/internal_api/public')
-rw-r--r-- | sync/internal_api/public/events/protocol_event.h | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/sync/internal_api/public/events/protocol_event.h b/sync/internal_api/public/events/protocol_event.h new file mode 100644 index 0000000..fc69e00 --- /dev/null +++ b/sync/internal_api/public/events/protocol_event.h @@ -0,0 +1,59 @@ +// Copyright (c) 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_PUBLIC_EVENTS_PROTOCOL_EVENT_H +#define SYNC_INTERNAL_API_PUBLIC_EVENTS_PROTOCOL_EVENT_H + +#include "base/memory/scoped_ptr.h" +#include "base/time/time.h" +#include "base/values.h" +#include "sync/base/sync_export.h" + +namespace syncer { + +// SyncNetworkEvents represent a single client <-> server sync protocol event +// that recently took place. Sync protocol events occur when the client decides +// to send a sync protocol request (such as GetUpdates or Commit) to the server, +// and when the server responds. Note that the requests and responses themselves +// are modelled by {GetUpdates, Commit}x{Request,Response} objects. +// +// These objects are intended to be used for displaying information on +// about:sync. They should be considered to be immutable and opaque. No +// program behavior should depend on their contents. +// +// Each type of request can maintain its own set of additional metadata and have +// its own custom serialization routines. For example, the "configure" +// GetUpdates request will include information about its "origin" in its debug +// info. +class SYNC_EXPORT ProtocolEvent { + public: + ProtocolEvent(); + virtual ~ProtocolEvent(); + + // Returns the time when the request was sent or received. + virtual base::Time GetTimestamp() const = 0; + + // Returns a string representing they type of the request. Should be short. + virtual std::string GetType() const = 0; + + // Returns a string representing details of the request. May be verbose. The + // implementer is allowed to return lots of data separated by newlines. + virtual std::string GetDetails() const = 0; + + // Returns a DictionaryValue representing the protobuf message associated with + // this event. + virtual scoped_ptr<base::DictionaryValue> GetProtoMessage() const = 0; + + // Need a virtual copy contructor to copy this object across threads. + virtual scoped_ptr<ProtocolEvent> Clone() const = 0; + + // A static function that assembles the data exposed through the + // ProtocolEvent's interface into a single DictionaryValue. + static scoped_ptr<base::DictionaryValue> ToValue( + const ProtocolEvent& event); +}; + +} // namespace syncer + +#endif // SYNC_INTERNAL_API_PUBLIC_EVENTS_PROTOCOL_EVENT_H |