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

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

Issue 9826035: [Sync] Display the client server traffic log in about:sync. (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
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 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 #pragma once 7 #pragma once
8 8
9 #include <deque> 9 #include <deque>
10 #include <string> 10 #include <string>
11 11
12 #include "base/basictypes.h" 12 #include "base/basictypes.h"
13 #include "base/gtest_prod_util.h" 13 #include "base/gtest_prod_util.h"
14 #include "base/values.h"
14 #include "sync/protocol/sync.pb.h" 15 #include "sync/protocol/sync.pb.h"
15 16
16 namespace sync_pb { 17 namespace sync_pb {
17 class ClientToServerResponse; 18 class ClientToServerResponse;
18 class ClientToServerMessage; 19 class ClientToServerMessage;
19 } 20 }
20 21
21 namespace browser_sync { 22 namespace browser_sync {
22 23
23 class TrafficRecorder { 24 class TrafficRecorder {
(...skipping 11 matching lines...) Expand all
35 // 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
36 // 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.
37 // TODO(lipalani): Truncate the specifics to fit within size. 38 // TODO(lipalani): Truncate the specifics to fit within size.
38 bool truncated; 39 bool truncated;
39 40
40 TrafficRecord(const std::string& message, 41 TrafficRecord(const std::string& message,
41 TrafficMessageType message_type, 42 TrafficMessageType message_type,
42 bool truncated); 43 bool truncated);
43 TrafficRecord(); 44 TrafficRecord();
44 ~TrafficRecord(); 45 ~TrafficRecord();
46
47 DictionaryValue* ToValue() const;
45 }; 48 };
46 49
47 TrafficRecorder(unsigned int max_messages, unsigned int max_message_size); 50 TrafficRecorder(unsigned int max_messages, unsigned int max_message_size);
48 ~TrafficRecorder(); 51 ~TrafficRecorder();
49 52
50 void RecordClientToServerMessage(const sync_pb::ClientToServerMessage& msg); 53 void RecordClientToServerMessage(const sync_pb::ClientToServerMessage& msg);
51 void RecordClientToServerResponse( 54 void RecordClientToServerResponse(
52 const sync_pb::ClientToServerResponse& response); 55 const sync_pb::ClientToServerResponse& response);
56 ListValue* ToValue() const;
53 57
54 const std::deque<TrafficRecord>& records() { 58 const std::deque<TrafficRecord>& records() {
55 return records_; 59 return records_;
56 } 60 }
57 61
58 private: 62 private:
59 void AddTrafficToQueue(TrafficRecord* record); 63 void AddTrafficToQueue(TrafficRecord* record);
60 void StoreProtoInQueue(const ::google::protobuf::MessageLite& msg, 64 void StoreProtoInQueue(const ::google::protobuf::MessageLite& msg,
61 TrafficMessageType type); 65 TrafficMessageType type);
62 66
63 // Maximum number of messages stored in the queue. 67 // Maximum number of messages stored in the queue.
64 unsigned int max_messages_; 68 unsigned int max_messages_;
65 69
66 // Maximum size of each message. 70 // Maximum size of each message.
67 unsigned int max_message_size_; 71 unsigned int max_message_size_;
68 std::deque<TrafficRecord> records_; 72 std::deque<TrafficRecord> records_;
69 DISALLOW_COPY_AND_ASSIGN(TrafficRecorder); 73 DISALLOW_COPY_AND_ASSIGN(TrafficRecorder);
70 }; 74 };
71 75
72 } // namespace browser_sync 76 } // namespace browser_sync
73 77
74 #endif // CHROME_BROWSER_SYNC_ENGINE_TRAFFIC_RECORDER_H_ 78 #endif // CHROME_BROWSER_SYNC_ENGINE_TRAFFIC_RECORDER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698