| Index: chrome/browser/sync/internal_api/sync_manager.cc
|
| diff --git a/chrome/browser/sync/internal_api/sync_manager.cc b/chrome/browser/sync/internal_api/sync_manager.cc
|
| index 469f7df0cf813fae822c4b20f06436ae6e555b51..68ef8af6a7d13a72b4a0e73210144e3422e1fb66 100644
|
| --- a/chrome/browser/sync/internal_api/sync_manager.cc
|
| +++ b/chrome/browser/sync/internal_api/sync_manager.cc
|
| @@ -122,6 +122,10 @@ namespace sync_api {
|
| const int SyncManager::kDefaultNudgeDelayMilliseconds = 200;
|
| const int SyncManager::kPreferencesNudgeDelayMilliseconds = 2000;
|
|
|
| +// Maximum count and size for traffic recorder.
|
| +const unsigned int kMaxMessagesToRecord = 10;
|
| +const unsigned int kMaxMessageSizeToRecord = 5 * 1024;
|
| +
|
| //////////////////////////////////////////////////////////////////////////
|
| // SyncManager's implementation: SyncManager::SyncInternal
|
| class SyncManager::SyncInternal
|
| @@ -146,7 +150,8 @@ class SyncManager::SyncInternal
|
| unrecoverable_error_handler_(NULL),
|
| report_unrecoverable_error_function_(NULL),
|
| created_on_loop_(MessageLoop::current()),
|
| - nigori_overwrite_count_(0) {
|
| + nigori_overwrite_count_(0),
|
| + traffic_recorder_(kMaxMessagesToRecord, kMaxMessageSizeToRecord) {
|
| // Pre-fill |notification_info_map_|.
|
| for (int i = syncable::FIRST_REAL_MODEL_TYPE;
|
| i < syncable::MODEL_TYPE_COUNT; ++i) {
|
| @@ -176,6 +181,9 @@ class SyncManager::SyncInternal
|
| BindJsMessageHandler(
|
| "findNodesContainingString",
|
| &SyncManager::SyncInternal::FindNodesContainingString);
|
| + BindJsMessageHandler(
|
| + "getClientServerTraffic",
|
| + &SyncManager::SyncInternal::GetClientServerTraffic);
|
| }
|
|
|
| virtual ~SyncInternal() {
|
| @@ -520,6 +528,7 @@ class SyncManager::SyncInternal
|
| JsArgList GetNodeDetailsById(const JsArgList& args);
|
| JsArgList GetChildNodeIds(const JsArgList& args);
|
| JsArgList FindNodesContainingString(const JsArgList& args);
|
| + JsArgList GetClientServerTraffic(const JsArgList& args);
|
|
|
| FilePath database_path_;
|
|
|
| @@ -609,6 +618,8 @@ class SyncManager::SyncInternal
|
| // This is for keeping track of client events to send to the server.
|
| DebugInfoEventListener debug_info_event_listener_;
|
|
|
| + browser_sync::TrafficRecorder traffic_recorder_;
|
| +
|
| Encryptor* encryptor_;
|
| UnrecoverableErrorHandler* unrecoverable_error_handler_;
|
| ReportUnrecoverableErrorFunction report_unrecoverable_error_function_;
|
| @@ -961,7 +972,8 @@ bool SyncManager::SyncInternal::Init(
|
| model_safe_worker_registrar,
|
| extensions_activity_monitor,
|
| listeners,
|
| - &debug_info_event_listener_);
|
| + &debug_info_event_listener_,
|
| + &traffic_recorder_);
|
| context->set_account_name(credentials.email);
|
| // The SyncScheduler takes ownership of |context|.
|
| scheduler_.reset(new SyncScheduler(name_, context, new Syncer()));
|
| @@ -2207,6 +2219,15 @@ JsArgList SyncManager::SyncInternal::GetRootNodeDetails(
|
| return JsArgList(&return_args);
|
| }
|
|
|
| +JsArgList SyncManager::SyncInternal::GetClientServerTraffic(
|
| + const JsArgList& args) {
|
| + ListValue return_args;
|
| + ListValue* value = traffic_recorder_.ToValue();
|
| + if (value != NULL)
|
| + return_args.Append(value);
|
| + return JsArgList(&return_args);
|
| +}
|
| +
|
| namespace {
|
|
|
| int64 GetId(const ListValue& ids, int i) {
|
|
|