| 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 |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/gtest_prod_util.h" | 12 #include "base/gtest_prod_util.h" |
| 13 #include "base/time.h" | |
| 14 #include "base/values.h" | 13 #include "base/values.h" |
| 15 #include "sync/base/sync_export.h" | 14 #include "sync/base/sync_export.h" |
| 16 #include "sync/protocol/sync.pb.h" | 15 #include "sync/protocol/sync.pb.h" |
| 17 | 16 |
| 18 namespace sync_pb { | 17 namespace sync_pb { |
| 19 class ClientToServerResponse; | 18 class ClientToServerResponse; |
| 20 class ClientToServerMessage; | 19 class ClientToServerMessage; |
| 21 } | 20 } |
| 22 | 21 |
| 23 namespace syncer { | 22 namespace syncer { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 34 // The serialized message. | 33 // The serialized message. |
| 35 std::string message; | 34 std::string message; |
| 36 TrafficMessageType message_type; | 35 TrafficMessageType message_type; |
| 37 // If the message is too big to be kept in memory then it should be | 36 // 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. | 37 // truncated. For now the entire message is omitted if it is too big. |
| 39 // TODO(lipalani): Truncate the specifics to fit within size. | 38 // TODO(lipalani): Truncate the specifics to fit within size. |
| 40 bool truncated; | 39 bool truncated; |
| 41 | 40 |
| 42 TrafficRecord(const std::string& message, | 41 TrafficRecord(const std::string& message, |
| 43 TrafficMessageType message_type, | 42 TrafficMessageType message_type, |
| 44 bool truncated, | 43 bool truncated); |
| 45 base::Time time); | |
| 46 TrafficRecord(); | 44 TrafficRecord(); |
| 47 ~TrafficRecord(); | 45 ~TrafficRecord(); |
| 48 DictionaryValue* ToValue() const; | 46 DictionaryValue* ToValue() const; |
| 49 | |
| 50 // Time of record creation. | |
| 51 base::Time timestamp; | |
| 52 }; | 47 }; |
| 53 | 48 |
| 54 TrafficRecorder(unsigned int max_messages, unsigned int max_message_size); | 49 TrafficRecorder(unsigned int max_messages, unsigned int max_message_size); |
| 55 virtual ~TrafficRecorder(); | 50 ~TrafficRecorder(); |
| 56 | 51 |
| 57 void RecordClientToServerMessage(const sync_pb::ClientToServerMessage& msg); | 52 void RecordClientToServerMessage(const sync_pb::ClientToServerMessage& msg); |
| 58 void RecordClientToServerResponse( | 53 void RecordClientToServerResponse( |
| 59 const sync_pb::ClientToServerResponse& response); | 54 const sync_pb::ClientToServerResponse& response); |
| 60 ListValue* ToValue() const; | 55 ListValue* ToValue() const; |
| 61 | 56 |
| 62 const std::deque<TrafficRecord>& records() { | 57 const std::deque<TrafficRecord>& records() { |
| 63 return records_; | 58 return records_; |
| 64 } | 59 } |
| 65 | 60 |
| 66 private: | 61 private: |
| 67 void AddTrafficToQueue(TrafficRecord* record); | 62 void AddTrafficToQueue(TrafficRecord* record); |
| 68 void StoreProtoInQueue(const ::google::protobuf::MessageLite& msg, | 63 void StoreProtoInQueue(const ::google::protobuf::MessageLite& msg, |
| 69 TrafficMessageType type); | 64 TrafficMessageType type); |
| 70 | 65 |
| 71 // Method to get record creation time. | |
| 72 virtual base::Time GetTime(); | |
| 73 | |
| 74 // Maximum number of messages stored in the queue. | 66 // Maximum number of messages stored in the queue. |
| 75 unsigned int max_messages_; | 67 unsigned int max_messages_; |
| 76 | 68 |
| 77 // Maximum size of each message. | 69 // Maximum size of each message. |
| 78 unsigned int max_message_size_; | 70 unsigned int max_message_size_; |
| 79 std::deque<TrafficRecord> records_; | 71 std::deque<TrafficRecord> records_; |
| 80 DISALLOW_COPY_AND_ASSIGN(TrafficRecorder); | 72 DISALLOW_COPY_AND_ASSIGN(TrafficRecorder); |
| 81 }; | 73 }; |
| 82 | 74 |
| 83 } // namespace syncer | 75 } // namespace syncer |
| 84 | 76 |
| 85 #endif // CHROME_BROWSER_SYNC_ENGINE_TRAFFIC_RECORDER_H_ | 77 #endif // CHROME_BROWSER_SYNC_ENGINE_TRAFFIC_RECORDER_H_ |
| 86 | 78 |
| OLD | NEW |