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