Make sure webview uses embedder display DPI.
[chromium-blink-merge.git] / sync / engine / traffic_recorder.h
blob65e652e4731d425c2c17b47de4046d0f1101dfaa
1 // Copyright 2012 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.
5 #ifndef CHROME_BROWSER_SYNC_ENGINE_TRAFFIC_RECORDER_H_
6 #define CHROME_BROWSER_SYNC_ENGINE_TRAFFIC_RECORDER_H_
8 #include <deque>
9 #include <string>
11 #include "base/basictypes.h"
12 #include "base/gtest_prod_util.h"
13 #include "base/time.h"
14 #include "base/values.h"
15 #include "sync/base/sync_export.h"
16 #include "sync/protocol/sync.pb.h"
18 namespace sync_pb {
19 class ClientToServerResponse;
20 class ClientToServerMessage;
23 namespace syncer {
25 class SYNC_EXPORT_PRIVATE TrafficRecorder {
26 public:
27 enum TrafficMessageType {
28 CLIENT_TO_SERVER_MESSAGE,
29 CLIENT_TO_SERVER_RESPONSE,
30 UNKNOWN_MESSAGE_TYPE
33 struct SYNC_EXPORT_PRIVATE TrafficRecord {
34 // The serialized message.
35 std::string message;
36 TrafficMessageType message_type;
37 // If the message is too big to be kept in memory then it should be
38 // truncated. For now the entire message is omitted if it is too big.
39 // TODO(lipalani): Truncate the specifics to fit within size.
40 bool truncated;
42 TrafficRecord(const std::string& message,
43 TrafficMessageType message_type,
44 bool truncated,
45 base::Time time);
46 TrafficRecord();
47 ~TrafficRecord();
48 DictionaryValue* ToValue() const;
50 // Time of record creation.
51 base::Time timestamp;
54 TrafficRecorder(unsigned int max_messages, unsigned int max_message_size);
55 virtual ~TrafficRecorder();
57 void RecordClientToServerMessage(const sync_pb::ClientToServerMessage& msg);
58 void RecordClientToServerResponse(
59 const sync_pb::ClientToServerResponse& response);
60 ListValue* ToValue() const;
62 const std::deque<TrafficRecord>& records() {
63 return records_;
66 private:
67 void AddTrafficToQueue(TrafficRecord* record);
68 void StoreProtoInQueue(const ::google::protobuf::MessageLite& msg,
69 TrafficMessageType type);
71 // Method to get record creation time.
72 virtual base::Time GetTime();
74 // Maximum number of messages stored in the queue.
75 unsigned int max_messages_;
77 // Maximum size of each message.
78 unsigned int max_message_size_;
79 std::deque<TrafficRecord> records_;
80 DISALLOW_COPY_AND_ASSIGN(TrafficRecorder);
83 } // namespace syncer
85 #endif // CHROME_BROWSER_SYNC_ENGINE_TRAFFIC_RECORDER_H_