1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef SYNC_INTERNAL_API_PUBLIC_EVENTS_PROTOCOL_EVENT_H 6 #define SYNC_INTERNAL_API_PUBLIC_EVENTS_PROTOCOL_EVENT_H 7 8 #include "base/memory/scoped_ptr.h" 9 #include "base/time/time.h" 10 #include "base/values.h" 11 #include "sync/base/sync_export.h" 12 13 namespace syncer { 14 15 // SyncNetworkEvents represent a single client <-> server sync protocol event 16 // that recently took place. Sync protocol events occur when the client decides 17 // to send a sync protocol request (such as GetUpdates or Commit) to the server, 18 // and when the server responds. Note that the requests and responses themselves 19 // are modelled by {GetUpdates, Commit}x{Request,Response} objects. 20 // 21 // These objects are intended to be used for displaying information on 22 // about:sync. They should be considered to be immutable and opaque. No 23 // program behavior should depend on their contents. 24 // 25 // Each type of request can maintain its own set of additional metadata and have 26 // its own custom serialization routines. For example, the "configure" 27 // GetUpdates request will include information about its "origin" in its debug 28 // info. 29 class SYNC_EXPORT ProtocolEvent { 30 public: 31 ProtocolEvent(); 32 virtual ~ProtocolEvent(); 33 34 // Returns the time when the request was sent or received. 35 virtual base::Time GetTimestamp() const = 0; 36 37 // Returns a string representing they type of the request. Should be short. 38 virtual std::string GetType() const = 0; 39 40 // Returns a string representing details of the request. May be verbose. The 41 // implementer is allowed to return lots of data separated by newlines. 42 virtual std::string GetDetails() const = 0; 43 44 // Returns a DictionaryValue representing the protobuf message associated with 45 // this event. 46 virtual scoped_ptr<base::DictionaryValue> GetProtoMessage() const = 0; 47 48 // Need a virtual copy contructor to copy this object across threads. 49 virtual scoped_ptr<ProtocolEvent> Clone() const = 0; 50 51 // A static function that assembles the data exposed through the 52 // ProtocolEvent's interface into a single DictionaryValue. 53 static scoped_ptr<base::DictionaryValue> ToValue( 54 const ProtocolEvent& event); 55 }; 56 57 } // namespace syncer 58 59 #endif // SYNC_INTERNAL_API_PUBLIC_EVENTS_PROTOCOL_EVENT_H 60