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

Side by Side Diff: sync/engine/syncer_proto_util.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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | sync/engine/traffic_logger.h » ('j') | sync/engine/traffic_logger.h » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "sync/engine/syncer_proto_util.h" 5 #include "sync/engine/syncer_proto_util.h"
6 6
7 #include "base/format_macros.h" 7 #include "base/format_macros.h"
8 #include "base/json/json_writer.h"
8 #include "base/stringprintf.h" 9 #include "base/stringprintf.h"
9 #include "sync/engine/net/server_connection_manager.h" 10 #include "sync/engine/net/server_connection_manager.h"
10 #include "sync/engine/syncer.h" 11 #include "sync/engine/syncer.h"
11 #include "sync/engine/syncer_types.h" 12 #include "sync/engine/syncer_types.h"
13 #include "sync/engine/traffic_logger.h"
12 #include "sync/protocol/service_constants.h" 14 #include "sync/protocol/service_constants.h"
13 #include "sync/protocol/sync.pb.h" 15 #include "sync/protocol/sync.pb.h"
14 #include "sync/protocol/sync_enums.pb.h" 16 #include "sync/protocol/sync_enums.pb.h"
15 #include "sync/protocol/sync_protocol_error.h" 17 #include "sync/protocol/sync_protocol_error.h"
16 #include "sync/sessions/sync_session.h" 18 #include "sync/sessions/sync_session.h"
17 #include "sync/syncable/model_type.h" 19 #include "sync/syncable/model_type.h"
18 #include "sync/syncable/syncable-inl.h" 20 #include "sync/syncable/syncable-inl.h"
19 #include "sync/syncable/syncable.h" 21 #include "sync/syncable/syncable.h"
20 #include "sync/util/time.h" 22 #include "sync/util/time.h"
21 23
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 SyncSession* session) { 332 SyncSession* session) {
331 333
332 CHECK(response); 334 CHECK(response);
333 DCHECK(!msg.get_updates().has_from_timestamp()); // Deprecated. 335 DCHECK(!msg.get_updates().has_from_timestamp()); // Deprecated.
334 DCHECK(!msg.get_updates().has_requested_types()); // Deprecated. 336 DCHECK(!msg.get_updates().has_requested_types()); // Deprecated.
335 DCHECK(msg.has_store_birthday() || IsVeryFirstGetUpdates(msg)) 337 DCHECK(msg.has_store_birthday() || IsVeryFirstGetUpdates(msg))
336 << "Must call AddRequestBirthday to set birthday."; 338 << "Must call AddRequestBirthday to set birthday.";
337 339
338 syncable::Directory* dir = session->context()->directory(); 340 syncable::Directory* dir = session->context()->directory();
339 341
342 LogClientToServerMessage(msg);
340 if (!PostAndProcessHeaders(session->context()->connection_manager(), session, 343 if (!PostAndProcessHeaders(session->context()->connection_manager(), session,
341 msg, response)) { 344 msg, response)) {
342 // There was an error establishing communication with the server. 345 // There was an error establishing communication with the server.
343 // We can not proceed beyond this point. 346 // We can not proceed beyond this point.
344 const browser_sync::HttpResponse::ServerConnectionCode server_status = 347 const browser_sync::HttpResponse::ServerConnectionCode server_status =
345 session->context()->connection_manager()->server_status(); 348 session->context()->connection_manager()->server_status();
346 349
347 DCHECK_NE(server_status, browser_sync::HttpResponse::NONE); 350 DCHECK_NE(server_status, browser_sync::HttpResponse::NONE);
348 DCHECK_NE(server_status, browser_sync::HttpResponse::SERVER_CONNECTION_OK); 351 DCHECK_NE(server_status, browser_sync::HttpResponse::SERVER_CONNECTION_OK);
349 352
350 return ServerConnectionErrorAsSyncerError(server_status); 353 return ServerConnectionErrorAsSyncerError(server_status);
351 } 354 }
352 355
356 LogClientToServerResponse(*response);
357
353 browser_sync::SyncProtocolError sync_protocol_error; 358 browser_sync::SyncProtocolError sync_protocol_error;
354 359
355 // Birthday mismatch overrides any error that is sent by the server. 360 // Birthday mismatch overrides any error that is sent by the server.
356 if (!VerifyResponseBirthday(dir, response)) { 361 if (!VerifyResponseBirthday(dir, response)) {
357 sync_protocol_error.error_type = browser_sync::NOT_MY_BIRTHDAY; 362 sync_protocol_error.error_type = browser_sync::NOT_MY_BIRTHDAY;
358 sync_protocol_error.action = 363 sync_protocol_error.action =
359 browser_sync::DISABLE_SYNC_ON_CLIENT; 364 browser_sync::DISABLE_SYNC_ON_CLIENT;
360 } else if (response->has_error()) { 365 } else if (response->has_error()) {
361 // This is a new server. Just get the error from the protocol. 366 // This is a new server. Just get the error from the protocol.
362 sync_protocol_error = ConvertErrorPBToLocalType(response->error()); 367 sync_protocol_error = ConvertErrorPBToLocalType(response->error());
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
528 std::string SyncerProtoUtil::ClientToServerResponseDebugString( 533 std::string SyncerProtoUtil::ClientToServerResponseDebugString(
529 const sync_pb::ClientToServerResponse& response) { 534 const sync_pb::ClientToServerResponse& response) {
530 // Add more handlers as needed. 535 // Add more handlers as needed.
531 std::string output; 536 std::string output;
532 if (response.has_get_updates()) 537 if (response.has_get_updates())
533 output.append(GetUpdatesResponseString(response.get_updates())); 538 output.append(GetUpdatesResponseString(response.get_updates()));
534 return output; 539 return output;
535 } 540 }
536 541
537 } // namespace browser_sync 542 } // namespace browser_sync
OLDNEW
« no previous file with comments | « no previous file | sync/engine/traffic_logger.h » ('j') | sync/engine/traffic_logger.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698