Chromium Code Reviews| 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..6a39c7dc6f12d9a51ac8d51bd09590923a87761a |
| --- /dev/null |
| +++ b/chrome/browser/sync/engine/traffic_logger.cc |
| @@ -0,0 +1,47 @@ |
| +// 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 "chrome/browser/sync/protocol/proto_value_conversions.h" |
| +#include "chrome/browser/sync/protocol/sync.pb.h" |
| + |
| +namespace browser_sync { |
| + |
| +namespace { |
| +template<class T> |
|
akalin
2012/03/13 00:20:43
space before <
lipalani1
2012/03/13 21:32:40
Done.
|
| +void LogData(const T& data, |
| + DictionaryValue*(to_dictionary_value)(const T&, bool), |
|
akalin
2012/03/13 00:20:43
the right syntax is:
DictionaryValue* (*to_dictio
lipalani1
2012/03/13 21:32:40
Yeah that is correct. I have seen this convention
|
| + const std::string& description) { |
| + if (VLOG_IS_ON(1)) { |
| + scoped_ptr<DictionaryValue> value(to_dictionary_value(data, true)); |
|
akalin
2012/03/13 00:20:43
(*to_dictionary_value)(data, true)
akalin
2012/03/13 00:20:43
comment what "true" means, like
(data, true /* pa
lipalani1
2012/03/13 21:32:40
Done.
|
| + std::string message; |
| + base::JSONWriter::Write(value.get(), true, &message); |
|
akalin
2012/03/13 00:20:43
here too
lipalani1
2012/03/13 21:32:40
Done.
|
| + VLOG(1) << "\n" << description; |
| + VLOG(1) << "\n" << message; |
| + } |
| +} |
| +} // namespace |
| + |
| +void LogClientToServerMessage(const ClientToServerMessage& msg) { |
| + LogData((sync_pb::ClientToServerMessage)msg, ClientToServerMessageToValue, |
|
akalin
2012/03/13 00:20:43
this is rendered moot by the comment in the header
akalin
2012/03/13 00:20:43
&ClientToServerMessageToValue
lipalani1
2012/03/13 21:32:40
Done.
lipalani1
2012/03/13 21:32:40
The necessity for the cast was to have the templat
lipalani1
2012/03/13 21:32:40
Done.
|
| + "******Client To Server Message******"); |
| + // TODO(lipalani) : Store the data(minus specifics) |
| + // in a circular buffer in memory. |
| +} |
| + |
| +void LogClientToServerResponse( |
| + const sync_pb::ClientToServerResponse& response) { |
| + LogData(response, ClientToServerResponseToValue, |
|
akalin
2012/03/13 00:20:43
&ClientToServerResponseToValue
lipalani1
2012/03/13 21:32:40
Done.
|
| + "******Server Response******"); |
| + // TODO(lipalani) : Store the data(minus specifics) |
| + // in a circular buffer in memory. |
| +} |
| + |
| +} // namespace browser_sync |