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

Unified 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, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sync/engine/traffic_logger.cc ('k') | sync/engine/traffic_recorder.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..52bf8cee768159bc375b82ccbd6b8295f2f8bbc7
--- /dev/null
+++ b/sync/engine/traffic_recorder.h
@@ -0,0 +1,75 @@
+// 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/basictypes.h"
+#include "base/gtest_prod_util.h"
+#include "sync/protocol/sync.pb.h"
+
+namespace sync_pb {
+class ClientToServerResponse;
+class ClientToServerMessage;
+}
+
+namespace browser_sync {
+
+class TrafficRecorder {
+ public:
+ 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 within size.
+ bool truncated;
+
+ TrafficRecord(const std::string& message,
+ TrafficMessageType message_type,
+ bool truncated);
+ TrafficRecord();
+ ~TrafficRecord();
+ };
+
+ TrafficRecorder(unsigned int max_messages, unsigned int max_message_size);
+ ~TrafficRecorder();
+
+ void RecordClientToServerMessage(const sync_pb::ClientToServerMessage& msg);
+ void RecordClientToServerResponse(
+ const sync_pb::ClientToServerResponse& response);
+
+ const std::deque<TrafficRecord>& records() {
+ return records_;
+ }
+
+ private:
+ void AddTrafficToQueue(TrafficRecord* record);
+ void StoreProtoInQueue(const ::google::protobuf::MessageLite& msg,
+ TrafficMessageType type);
+
+ // Maximum number of messages stored in the queue.
+ unsigned int max_messages_;
+
+ // Maximum size of each message.
+ unsigned int max_message_size_;
+ std::deque<TrafficRecord> records_;
+ DISALLOW_COPY_AND_ASSIGN(TrafficRecorder);
+};
+
+} // namespace browser_sync
+
+#endif // CHROME_BROWSER_SYNC_ENGINE_TRAFFIC_RECORDER_H_
+
« 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