OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_SYNC_ENGINE_TRAFFIC_RECORDER_H_ | 5 #ifndef CHROME_BROWSER_SYNC_ENGINE_TRAFFIC_RECORDER_H_ |
6 #define CHROME_BROWSER_SYNC_ENGINE_TRAFFIC_RECORDER_H_ | 6 #define CHROME_BROWSER_SYNC_ENGINE_TRAFFIC_RECORDER_H_ |
7 | 7 |
8 #include <deque> | 8 #include <deque> |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 27 matching lines...) Expand all Loading... |
38 // truncated. For now the entire message is omitted if it is too big. | 38 // truncated. For now the entire message is omitted if it is too big. |
39 // TODO(lipalani): Truncate the specifics to fit within size. | 39 // TODO(lipalani): Truncate the specifics to fit within size. |
40 bool truncated; | 40 bool truncated; |
41 | 41 |
42 TrafficRecord(const std::string& message, | 42 TrafficRecord(const std::string& message, |
43 TrafficMessageType message_type, | 43 TrafficMessageType message_type, |
44 bool truncated, | 44 bool truncated, |
45 base::Time time); | 45 base::Time time); |
46 TrafficRecord(); | 46 TrafficRecord(); |
47 ~TrafficRecord(); | 47 ~TrafficRecord(); |
48 DictionaryValue* ToValue() const; | 48 base::DictionaryValue* ToValue() const; |
49 | 49 |
50 // Time of record creation. | 50 // Time of record creation. |
51 base::Time timestamp; | 51 base::Time timestamp; |
52 }; | 52 }; |
53 | 53 |
54 TrafficRecorder(unsigned int max_messages, unsigned int max_message_size); | 54 TrafficRecorder(unsigned int max_messages, unsigned int max_message_size); |
55 virtual ~TrafficRecorder(); | 55 virtual ~TrafficRecorder(); |
56 | 56 |
57 void RecordClientToServerMessage(const sync_pb::ClientToServerMessage& msg); | 57 void RecordClientToServerMessage(const sync_pb::ClientToServerMessage& msg); |
58 void RecordClientToServerResponse( | 58 void RecordClientToServerResponse( |
59 const sync_pb::ClientToServerResponse& response); | 59 const sync_pb::ClientToServerResponse& response); |
60 ListValue* ToValue() const; | 60 base::ListValue* ToValue() const; |
61 | 61 |
62 const std::deque<TrafficRecord>& records() { | 62 const std::deque<TrafficRecord>& records() { |
63 return records_; | 63 return records_; |
64 } | 64 } |
65 | 65 |
66 private: | 66 private: |
67 void AddTrafficToQueue(TrafficRecord* record); | 67 void AddTrafficToQueue(TrafficRecord* record); |
68 void StoreProtoInQueue(const ::google::protobuf::MessageLite& msg, | 68 void StoreProtoInQueue(const ::google::protobuf::MessageLite& msg, |
69 TrafficMessageType type); | 69 TrafficMessageType type); |
70 | 70 |
71 // Method to get record creation time. | 71 // Method to get record creation time. |
72 virtual base::Time GetTime(); | 72 virtual base::Time GetTime(); |
73 | 73 |
74 // Maximum number of messages stored in the queue. | 74 // Maximum number of messages stored in the queue. |
75 unsigned int max_messages_; | 75 unsigned int max_messages_; |
76 | 76 |
77 // Maximum size of each message. | 77 // Maximum size of each message. |
78 unsigned int max_message_size_; | 78 unsigned int max_message_size_; |
79 std::deque<TrafficRecord> records_; | 79 std::deque<TrafficRecord> records_; |
80 DISALLOW_COPY_AND_ASSIGN(TrafficRecorder); | 80 DISALLOW_COPY_AND_ASSIGN(TrafficRecorder); |
81 }; | 81 }; |
82 | 82 |
83 } // namespace syncer | 83 } // namespace syncer |
84 | 84 |
85 #endif // CHROME_BROWSER_SYNC_ENGINE_TRAFFIC_RECORDER_H_ | 85 #endif // CHROME_BROWSER_SYNC_ENGINE_TRAFFIC_RECORDER_H_ |
86 | 86 |
OLD | NEW |