Chromium Code Reviews| OLD | NEW |
|---|---|
| (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 // This file has the functions to log all the sync related HTTP communication. | |
|
akalin
2012/03/27 20:21:04
fix this comment
lipalani1
2012/03/27 21:08:57
Done.
| |
| 6 // To get the log run a debug build of chrome with the flag | |
| 7 // --vmodule=traffic_recorder=1. | |
| 8 | |
| 9 #ifndef CHROME_BROWSER_SYNC_ENGINE_TRAFFIC_RECORDER_H_ | |
| 10 #define CHROME_BROWSER_SYNC_ENGINE_TRAFFIC_RECORDER_H_ | |
| 11 #pragma once | |
| 12 | |
| 13 #include <deque> | |
| 14 #include <string> | |
| 15 | |
| 16 #include "sync/protocol/sync.pb.h" | |
| 17 | |
| 18 namespace sync_pb { | |
| 19 class ClientToServerResponse; | |
| 20 class ClientToServerMessage; | |
| 21 } | |
| 22 | |
| 23 namespace browser_sync { | |
| 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 would be trucated. | |
|
akalin
2012/03/27 20:21:04
would be trucated -> should be truncated
lipalani1
2012/03/27 21:08:57
Done.
| |
| 37 // For now the entire message would be truncated if it is big. | |
|
akalin
2012/03/27 20:21:04
would be truncated -> is omitted
is big -> is too
lipalani1
2012/03/27 21:08:57
Done.
| |
| 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 void AddTrafficToQueue(const TrafficRecord& record); | |
| 58 void StoreProtoInQueue(const ::google::protobuf::MessageLite& msg, | |
| 59 TrafficMessageType type); | |
| 60 | |
| 61 std::deque<TrafficRecord> records_; | |
| 62 }; | |
| 63 | |
| 64 } // namespace browser_sync | |
| 65 | |
| 66 #endif // CHROME_BROWSER_SYNC_ENGINE_TRAFFIC_RECORDER_H_ | |
| OLD | NEW |