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

Unified Diff: sync/engine/traffic_recorder.cc

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 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_recorder.h ('k') | sync/engine/traffic_recorder_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sync/engine/traffic_recorder.cc
diff --git a/sync/engine/traffic_recorder.cc b/sync/engine/traffic_recorder.cc
index e9ea716c03b0076e170c6c2ffbb7678c34d315a4..ae0a05968bb73f5eee25deb758c3a9ecde5badb7 100644
--- a/sync/engine/traffic_recorder.cc
+++ b/sync/engine/traffic_recorder.cc
@@ -39,6 +39,58 @@ TrafficRecorder::TrafficRecorder(unsigned int max_messages,
TrafficRecorder::~TrafficRecorder() {
}
+namespace {
+const char* GetMessageTypeString(TrafficRecorder::TrafficMessageType type) {
+ switch(type) {
+ case TrafficRecorder::CLIENT_TO_SERVER_MESSAGE:
+ return "Request";
+ case TrafficRecorder::CLIENT_TO_SERVER_RESPONSE:
+ return "Response";
+ default:
+ NOTREACHED();
+ return "";
+ }
+}
+}
+
+DictionaryValue* TrafficRecorder::TrafficRecord::ToValue() const {
+ scoped_ptr<DictionaryValue> value;
+ if (truncated) {
+ value.reset(new DictionaryValue());
+ value->SetString("message_type",
+ GetMessageTypeString(message_type));
+ value->SetBoolean("truncated", true);
+ } else if (message_type == TrafficRecorder::CLIENT_TO_SERVER_MESSAGE) {
+ sync_pb::ClientToServerMessage message_proto;
+ if (message_proto.ParseFromString(message))
+ value.reset(
+ ClientToServerMessageToValue(message_proto,
+ false /* include_specifics */));
+ } else if (message_type == TrafficRecorder::CLIENT_TO_SERVER_RESPONSE) {
+ sync_pb::ClientToServerResponse message_proto;
+ if (message_proto.ParseFromString(message))
+ value.reset(
+ ClientToServerResponseToValue(message_proto,
+ false /* include_specifics */));
+ } else {
+ NOTREACHED();
+ }
+
+ return value.release();
+}
+
+
+ListValue* TrafficRecorder::ToValue() const {
+ scoped_ptr<ListValue> value(new ListValue());
+ std::deque<TrafficRecord>::const_iterator it;
+ for (it = records_.begin(); it != records_.end(); ++it) {
+ const TrafficRecord& record = *it;
+ value->Append(record.ToValue());
+ }
+
+ return value.release();
+}
+
void TrafficRecorder::AddTrafficToQueue(TrafficRecord* record) {
records_.resize(records_.size() + 1);
« no previous file with comments | « sync/engine/traffic_recorder.h ('k') | sync/engine/traffic_recorder_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698