Chromium Code Reviews| Index: sync/engine/traffic_recorder.h |
| diff --git a/sync/engine/traffic_recorder.h b/sync/engine/traffic_recorder.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..e6c226cfc793f6ad09263482b77930250996f57e |
| --- /dev/null |
| +++ b/sync/engine/traffic_recorder.h |
| @@ -0,0 +1,66 @@ |
| +// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +// 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.
|
| +// To get the log run a debug build of chrome with the flag |
| +// --vmodule=traffic_recorder=1. |
| + |
| +#ifndef CHROME_BROWSER_SYNC_ENGINE_TRAFFIC_RECORDER_H_ |
| +#define CHROME_BROWSER_SYNC_ENGINE_TRAFFIC_RECORDER_H_ |
| +#pragma once |
| + |
| +#include <deque> |
| +#include <string> |
| + |
| +#include "sync/protocol/sync.pb.h" |
| + |
| +namespace sync_pb { |
| +class ClientToServerResponse; |
| +class ClientToServerMessage; |
| +} |
| + |
| +namespace browser_sync { |
| + |
| +class TrafficRecorder { |
| + enum TrafficMessageType { |
| + CLIENT_TO_SERVER_MESSAGE, |
| + CLIENT_TO_SERVER_RESPONSE, |
| + UNKNOWN_MESSAGE_TYPE |
| + }; |
| + |
| + struct TrafficRecord { |
| + // The serialized message. |
| + std::string message; |
| + TrafficMessageType message_type; |
| + // 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.
|
| + // 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.
|
| + // TODO(lipalani): Truncate the specifics to fit with in size. |
| + bool truncated; |
| + |
| + TrafficRecord(const std::string& message, |
| + TrafficMessageType message_type, |
| + bool truncated); |
| + TrafficRecord(); |
| + ~TrafficRecord(); |
| + }; |
| + |
| + public: |
| + TrafficRecorder(); |
| + ~TrafficRecorder(); |
| + |
| + void RecordClientToServerMessage(const sync_pb::ClientToServerMessage& msg); |
| + void RecordClientToServerResponse( |
| + const sync_pb::ClientToServerResponse& response); |
| + |
| + private: |
| + void AddTrafficToQueue(const TrafficRecord& record); |
| + void StoreProtoInQueue(const ::google::protobuf::MessageLite& msg, |
| + TrafficMessageType type); |
| + |
| + std::deque<TrafficRecord> records_; |
| +}; |
| + |
| +} // namespace browser_sync |
| + |
| +#endif // CHROME_BROWSER_SYNC_ENGINE_TRAFFIC_RECORDER_H_ |