| Index: sync/engine/traffic_logger.cc
|
| diff --git a/sync/engine/traffic_logger.cc b/sync/engine/traffic_logger.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..b066af5902c5319facc0d8e06c9c0d08c839ce64
|
| --- /dev/null
|
| +++ b/sync/engine/traffic_logger.cc
|
| @@ -0,0 +1,50 @@
|
| +// 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 "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 "sync/protocol/proto_value_conversions.h"
|
| +#include "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 (::logging::DEBUG_MODE && VLOG_IS_ON(1)) {
|
| + scoped_ptr<DictionaryValue> value(
|
| + (*to_dictionary_value)(data, true /* include_specifics */));
|
| + std::string message;
|
| + base::JSONWriter::WriteWithOptions(value.get(),
|
| + base::JSONWriter::OPTIONS_PRETTY_PRINT,
|
| + &message);
|
| + DVLOG(1) << "\n" << description << "\n" << message << "\n";
|
| + }
|
| +}
|
| +} // namespace
|
| +
|
| +void LogClientToServerMessage(const sync_pb::ClientToServerMessage& msg) {
|
| + LogData(msg, &ClientToServerMessageToValue,
|
| + "******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,
|
| + "******Server Response******");
|
| + // TODO(lipalani) : Store the data (minus specifics)
|
| + // in a circular buffer in memory.
|
| +}
|
| +
|
| +} // namespace browser_sync
|
|
|