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

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

Issue 9732008: [Sync] Store the past 10 traffic records in memory. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: For review. Created 8 years, 8 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
(Empty)
1 // Copyright (c) 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.
4
5 #ifndef CHROME_BROWSER_SYNC_ENGINE_TRAFFIC_RECORDER_H_
6 #define CHROME_BROWSER_SYNC_ENGINE_TRAFFIC_RECORDER_H_
7 #pragma once
8
9 #include <deque>
10 #include <string>
11
12 #include "base/gtest_prod_util.h"
13 #include "sync/protocol/sync.pb.h"
14
15 namespace sync_pb {
16 class ClientToServerResponse;
17 class ClientToServerMessage;
18 }
19
20 namespace browser_sync {
21
22 extern const unsigned int kMaxMessages;
23 extern const unsigned int kMaxMessageSize;
24
25 class TrafficRecorder {
26 enum TrafficMessageType {
27 CLIENT_TO_SERVER_MESSAGE,
28 CLIENT_TO_SERVER_RESPONSE,
29 UNKNOWN_MESSAGE_TYPE
30 };
31
32 struct TrafficRecord {
33 // The serialized message.
34 std::string message;
35 TrafficMessageType message_type;
36 // 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 // TODO(lipalani): Truncate the specifics to fit with in size.
39 bool truncated;
40
41 TrafficRecord(const std::string& message,
42 TrafficMessageType message_type,
43 bool truncated);
44 TrafficRecord();
45 ~TrafficRecord();
46 };
47
48 public:
49 TrafficRecorder();
50 ~TrafficRecorder();
51
52 void RecordClientToServerMessage(const sync_pb::ClientToServerMessage& msg);
53 void RecordClientToServerResponse(
54 const sync_pb::ClientToServerResponse& response);
55
56 private:
57 FRIEND_TEST_ALL_PREFIXES(TrafficRecorderTest, MaxRecordsTest);
akalin 2012/03/27 23:53:44 I prefer doing read accessors over giving tests ac
lipalani1 2012/03/29 00:23:13 Done.
58 FRIEND_TEST_ALL_PREFIXES(TrafficRecorderTest, MaxMessageSizeTest);
59 void AddTrafficToQueue(const TrafficRecord& record);
60 void StoreProtoInQueue(const ::google::protobuf::MessageLite& msg,
61 TrafficMessageType type);
62
63 std::deque<TrafficRecord> records_;
akalin 2012/03/27 23:53:44 DISALLOW_COPY_AND_ASSIGN() (don't forget to inclu
lipalani1 2012/03/29 00:23:13 Done.
64 };
65
66 } // namespace browser_sync
67
68 #endif // CHROME_BROWSER_SYNC_ENGINE_TRAFFIC_RECORDER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698