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

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 submitting. 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
« no previous file with comments | « sync/engine/traffic_logger.cc ('k') | sync/engine/traffic_recorder.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/basictypes.h"
13 #include "base/gtest_prod_util.h"
14 #include "sync/protocol/sync.pb.h"
15
16 namespace sync_pb {
17 class ClientToServerResponse;
18 class ClientToServerMessage;
19 }
20
21 namespace browser_sync {
22
23 class TrafficRecorder {
24 public:
25 enum TrafficMessageType {
26 CLIENT_TO_SERVER_MESSAGE,
27 CLIENT_TO_SERVER_RESPONSE,
28 UNKNOWN_MESSAGE_TYPE
29 };
30
31 struct TrafficRecord {
32 // The serialized message.
33 std::string message;
34 TrafficMessageType message_type;
35 // If the message is too big to be kept in memory then it should be
36 // truncated. For now the entire message is omitted if it is too big.
37 // TODO(lipalani): Truncate the specifics to fit within size.
38 bool truncated;
39
40 TrafficRecord(const std::string& message,
41 TrafficMessageType message_type,
42 bool truncated);
43 TrafficRecord();
44 ~TrafficRecord();
45 };
46
47 TrafficRecorder(unsigned int max_messages, unsigned int max_message_size);
48 ~TrafficRecorder();
49
50 void RecordClientToServerMessage(const sync_pb::ClientToServerMessage& msg);
51 void RecordClientToServerResponse(
52 const sync_pb::ClientToServerResponse& response);
53
54 const std::deque<TrafficRecord>& records() {
55 return records_;
56 }
57
58 private:
59 void AddTrafficToQueue(TrafficRecord* record);
60 void StoreProtoInQueue(const ::google::protobuf::MessageLite& msg,
61 TrafficMessageType type);
62
63 // Maximum number of messages stored in the queue.
64 unsigned int max_messages_;
65
66 // Maximum size of each message.
67 unsigned int max_message_size_;
68 std::deque<TrafficRecord> records_;
69 DISALLOW_COPY_AND_ASSIGN(TrafficRecorder);
70 };
71
72 } // namespace browser_sync
73
74 #endif // CHROME_BROWSER_SYNC_ENGINE_TRAFFIC_RECORDER_H_
75
OLDNEW
« no previous file with comments | « sync/engine/traffic_logger.cc ('k') | sync/engine/traffic_recorder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698