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..9c315bd58e68c04c397fd334b73987f2ab7dea51 |
| --- /dev/null |
| +++ b/sync/engine/traffic_recorder.h |
| @@ -0,0 +1,68 @@ |
| +// 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. |
| + |
| +#ifndef CHROME_BROWSER_SYNC_ENGINE_TRAFFIC_RECORDER_H_ |
| +#define CHROME_BROWSER_SYNC_ENGINE_TRAFFIC_RECORDER_H_ |
| +#pragma once |
| + |
| +#include <deque> |
| +#include <string> |
| + |
| +#include "base/gtest_prod_util.h" |
| +#include "sync/protocol/sync.pb.h" |
| + |
| +namespace sync_pb { |
| +class ClientToServerResponse; |
| +class ClientToServerMessage; |
| +} |
| + |
| +namespace browser_sync { |
| + |
| +extern const unsigned int kMaxMessages; |
| +extern const unsigned int kMaxMessageSize; |
| + |
| +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 should be |
| + // truncated. For now the entire message is omitted if it is too big. |
| + // 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: |
| + 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.
|
| + FRIEND_TEST_ALL_PREFIXES(TrafficRecorderTest, MaxMessageSizeTest); |
| + void AddTrafficToQueue(const TrafficRecord& record); |
| + void StoreProtoInQueue(const ::google::protobuf::MessageLite& msg, |
| + TrafficMessageType type); |
| + |
| + 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.
|
| +}; |
| + |
| +} // namespace browser_sync |
| + |
| +#endif // CHROME_BROWSER_SYNC_ENGINE_TRAFFIC_RECORDER_H_ |