Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "chrome/browser/sync/engine/traffic_logger.h" | |
| 6 | |
| 7 #include <string> | |
| 8 | |
| 9 #include "base/json/json_writer.h" | |
| 10 #include "base/logging.h" | |
| 11 #include "base/memory/scoped_ptr.h" | |
| 12 #include "base/values.h" | |
| 13 #include "chrome/browser/sync/protocol/proto_value_conversions.h" | |
| 14 #include "chrome/browser/sync/protocol/sync.pb.h" | |
| 15 | |
| 16 namespace browser_sync { | |
| 17 | |
| 18 namespace { | |
| 19 template <class T> | |
| 20 void LogData(const T& data, | |
| 21 DictionaryValue* (*to_dictionary_value)(const T&, bool), | |
| 22 const std::string& description) { | |
| 23 if (VLOG_IS_ON(1)) { | |
| 24 scoped_ptr<DictionaryValue> value((*to_dictionary_value)(data, | |
| 25 true /* decode_specifics */)); | |
| 26 std::string message; | |
| 27 base::JSONWriter::Write(value.get(), true /* pretty_print */, &message); | |
| 28 VLOG(1) << "\n" << description; | |
| 29 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.
| |
| 30 } | |
| 31 } | |
| 32 } // namespace | |
| 33 | |
| 34 void LogClientToServerMessage(const sync_pb::ClientToServerMessage& msg) { | |
| 35 LogData(msg, &ClientToServerMessageToValue, | |
| 36 "******Client To Server Message******"); | |
| 37 // 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.
| |
| 38 // in a circular buffer in memory. | |
| 39 } | |
| 40 | |
| 41 void LogClientToServerResponse( | |
| 42 const sync_pb::ClientToServerResponse& response) { | |
| 43 LogData(response, &ClientToServerResponseToValue, | |
| 44 "******Server Response******"); | |
| 45 // TODO(lipalani) : Store the data(minus specifics) | |
|
akalin
2012/03/14 00:17:30
here too
lipalani1
2012/03/15 00:02:13
Done.
| |
| 46 // in a circular buffer in memory. | |
| 47 } | |
| 48 | |
| 49 } // namespace browser_sync | |
| OLD | NEW |