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

Unified Diff: chrome/browser/sync/engine/traffic_logger.cc

Issue 9663023: Log the sync communication that happens between client and server. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: For review. 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
Index: chrome/browser/sync/engine/traffic_logger.cc
diff --git a/chrome/browser/sync/engine/traffic_logger.cc b/chrome/browser/sync/engine/traffic_logger.cc
new file mode 100644
index 0000000000000000000000000000000000000000..21f800e503914fa58fdcee5f3643fb9c9b32f330
--- /dev/null
+++ b/chrome/browser/sync/engine/traffic_logger.cc
@@ -0,0 +1,49 @@
+// 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.
+
+#include "chrome/browser/sync/engine/traffic_logger.h"
+
+#include <string>
+
+#include "base/json/json_writer.h"
+#include "base/logging.h"
+#include "base/memory/scoped_ptr.h"
+#include "base/values.h"
+#include "chrome/browser/sync/protocol/proto_value_conversions.h"
+#include "chrome/browser/sync/protocol/sync.pb.h"
+
+namespace browser_sync {
+
+namespace {
+template <class T>
+void LogData(const T& data,
+ DictionaryValue* (*to_dictionary_value)(const T&, bool),
+ const std::string& description) {
+ if (VLOG_IS_ON(1)) {
+ scoped_ptr<DictionaryValue> value((*to_dictionary_value)(data,
+ true /* decode_specifics */));
+ std::string message;
+ base::JSONWriter::Write(value.get(), true /* pretty_print */, &message);
+ VLOG(1) << "\n" << description;
+ VLOG(1) << "\n" << message;
akalin 2012/03/14 00:17:30 may want to make it a single line, like: VLOG(1)
lipalani1 2012/03/15 00:02:13 Done.
+ }
+}
+} // namespace
+
+void LogClientToServerMessage(const sync_pb::ClientToServerMessage& msg) {
+ LogData(msg, &ClientToServerMessageToValue,
+ "******Client To Server Message******");
+ // TODO(lipalani) : Store the data(minus specifics)
akalin 2012/03/14 00:17:30 space before '(minus'
lipalani1 2012/03/15 00:02:13 Done.
+ // in a circular buffer in memory.
+}
+
+void LogClientToServerResponse(
+ const sync_pb::ClientToServerResponse& response) {
+ LogData(response, &ClientToServerResponseToValue,
+ "******Server Response******");
+ // TODO(lipalani) : Store the data(minus specifics)
akalin 2012/03/14 00:17:30 here too
lipalani1 2012/03/15 00:02:13 Done.
+ // in a circular buffer in memory.
+}
+
+} // namespace browser_sync

Powered by Google App Engine
This is Rietveld 408576698