Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1079)

Side by Side Diff: sync/engine/traffic_recorder.h

Issue 12088080: [Sync] Add timestamp to TrafficRecorder records (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix comment Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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"
13 #include "base/values.h" 14 #include "base/values.h"
14 #include "sync/base/sync_export.h" 15 #include "sync/base/sync_export.h"
15 #include "sync/protocol/sync.pb.h" 16 #include "sync/protocol/sync.pb.h"
16 17
17 namespace sync_pb { 18 namespace sync_pb {
18 class ClientToServerResponse; 19 class ClientToServerResponse;
19 class ClientToServerMessage; 20 class ClientToServerMessage;
20 } 21 }
21 22
22 namespace syncer { 23 namespace syncer {
(...skipping 10 matching lines...) Expand all
33 // The serialized message. 34 // The serialized message.
34 std::string message; 35 std::string message;
35 TrafficMessageType message_type; 36 TrafficMessageType message_type;
36 // If the message is too big to be kept in memory then it should be 37 // If the message is too big to be kept in memory then it should be
37 // 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.
38 // TODO(lipalani): Truncate the specifics to fit within size. 39 // TODO(lipalani): Truncate the specifics to fit within size.
39 bool truncated; 40 bool truncated;
40 41
41 TrafficRecord(const std::string& message, 42 TrafficRecord(const std::string& message,
42 TrafficMessageType message_type, 43 TrafficMessageType message_type,
43 bool truncated); 44 bool truncated,
45 base::Time time);
44 TrafficRecord(); 46 TrafficRecord();
45 ~TrafficRecord(); 47 ~TrafficRecord();
46 DictionaryValue* ToValue() const; 48 DictionaryValue* ToValue() const;
49
50 // Time of record creation.
51 base::Time timestamp;
47 }; 52 };
48 53
49 TrafficRecorder(unsigned int max_messages, unsigned int max_message_size); 54 TrafficRecorder(unsigned int max_messages, unsigned int max_message_size);
50 ~TrafficRecorder(); 55 virtual ~TrafficRecorder();
51 56
52 void RecordClientToServerMessage(const sync_pb::ClientToServerMessage& msg); 57 void RecordClientToServerMessage(const sync_pb::ClientToServerMessage& msg);
53 void RecordClientToServerResponse( 58 void RecordClientToServerResponse(
54 const sync_pb::ClientToServerResponse& response); 59 const sync_pb::ClientToServerResponse& response);
55 ListValue* ToValue() const; 60 ListValue* ToValue() const;
56 61
57 const std::deque<TrafficRecord>& records() { 62 const std::deque<TrafficRecord>& records() {
58 return records_; 63 return records_;
59 } 64 }
60 65
61 private: 66 private:
62 void AddTrafficToQueue(TrafficRecord* record); 67 void AddTrafficToQueue(TrafficRecord* record);
63 void StoreProtoInQueue(const ::google::protobuf::MessageLite& msg, 68 void StoreProtoInQueue(const ::google::protobuf::MessageLite& msg,
64 TrafficMessageType type); 69 TrafficMessageType type);
65 70
71 // Method to get record creation time.
72 virtual base::Time GetTime();
73
66 // Maximum number of messages stored in the queue. 74 // Maximum number of messages stored in the queue.
67 unsigned int max_messages_; 75 unsigned int max_messages_;
68 76
69 // Maximum size of each message. 77 // Maximum size of each message.
70 unsigned int max_message_size_; 78 unsigned int max_message_size_;
71 std::deque<TrafficRecord> records_; 79 std::deque<TrafficRecord> records_;
72 DISALLOW_COPY_AND_ASSIGN(TrafficRecorder); 80 DISALLOW_COPY_AND_ASSIGN(TrafficRecorder);
73 }; 81 };
74 82
75 } // namespace syncer 83 } // namespace syncer
76 84
77 #endif // CHROME_BROWSER_SYNC_ENGINE_TRAFFIC_RECORDER_H_ 85 #endif // CHROME_BROWSER_SYNC_ENGINE_TRAFFIC_RECORDER_H_
78 86
OLDNEW
« no previous file with comments | « no previous file | sync/engine/traffic_recorder.cc » ('j') | sync/engine/traffic_recorder_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698