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

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 committing. 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/syncer_unittest.cc » ('j') | no next file with comments »
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/stringprintf.h" 8 #include "base/stringprintf.h"
9 #include "sync/engine/net/server_connection_manager.h" 9 #include "sync/engine/net/server_connection_manager.h"
10 #include "sync/engine/syncer.h" 10 #include "sync/engine/syncer.h"
11 #include "sync/engine/syncer_types.h" 11 #include "sync/engine/syncer_types.h"
12 #include "sync/engine/traffic_logger.h"
12 #include "sync/protocol/service_constants.h" 13 #include "sync/protocol/service_constants.h"
13 #include "sync/protocol/sync.pb.h" 14 #include "sync/protocol/sync.pb.h"
14 #include "sync/protocol/sync_enums.pb.h" 15 #include "sync/protocol/sync_enums.pb.h"
15 #include "sync/protocol/sync_protocol_error.h" 16 #include "sync/protocol/sync_protocol_error.h"
16 #include "sync/sessions/sync_session.h" 17 #include "sync/sessions/sync_session.h"
17 #include "sync/syncable/model_type.h" 18 #include "sync/syncable/model_type.h"
18 #include "sync/syncable/syncable-inl.h" 19 #include "sync/syncable/syncable-inl.h"
19 #include "sync/syncable/syncable.h" 20 #include "sync/syncable/syncable.h"
20 #include "sync/util/time.h" 21 #include "sync/util/time.h"
21 22
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 SyncSession* session) { 331 SyncSession* session) {
331 332
332 CHECK(response); 333 CHECK(response);
333 DCHECK(!msg.get_updates().has_from_timestamp()); // Deprecated. 334 DCHECK(!msg.get_updates().has_from_timestamp()); // Deprecated.
334 DCHECK(!msg.get_updates().has_requested_types()); // Deprecated. 335 DCHECK(!msg.get_updates().has_requested_types()); // Deprecated.
335 DCHECK(msg.has_store_birthday() || IsVeryFirstGetUpdates(msg)) 336 DCHECK(msg.has_store_birthday() || IsVeryFirstGetUpdates(msg))
336 << "Must call AddRequestBirthday to set birthday."; 337 << "Must call AddRequestBirthday to set birthday.";
337 338
338 syncable::Directory* dir = session->context()->directory(); 339 syncable::Directory* dir = session->context()->directory();
339 340
341 LogClientToServerMessage(msg);
340 if (!PostAndProcessHeaders(session->context()->connection_manager(), session, 342 if (!PostAndProcessHeaders(session->context()->connection_manager(), session,
341 msg, response)) { 343 msg, response)) {
342 // There was an error establishing communication with the server. 344 // There was an error establishing communication with the server.
343 // We can not proceed beyond this point. 345 // We can not proceed beyond this point.
344 const browser_sync::HttpResponse::ServerConnectionCode server_status = 346 const browser_sync::HttpResponse::ServerConnectionCode server_status =
345 session->context()->connection_manager()->server_status(); 347 session->context()->connection_manager()->server_status();
346 348
347 DCHECK_NE(server_status, browser_sync::HttpResponse::NONE); 349 DCHECK_NE(server_status, browser_sync::HttpResponse::NONE);
348 DCHECK_NE(server_status, browser_sync::HttpResponse::SERVER_CONNECTION_OK); 350 DCHECK_NE(server_status, browser_sync::HttpResponse::SERVER_CONNECTION_OK);
349 351
350 return ServerConnectionErrorAsSyncerError(server_status); 352 return ServerConnectionErrorAsSyncerError(server_status);
351 } 353 }
352 354
355 LogClientToServerResponse(*response);
356
353 browser_sync::SyncProtocolError sync_protocol_error; 357 browser_sync::SyncProtocolError sync_protocol_error;
354 358
355 // Birthday mismatch overrides any error that is sent by the server. 359 // Birthday mismatch overrides any error that is sent by the server.
356 if (!VerifyResponseBirthday(dir, response)) { 360 if (!VerifyResponseBirthday(dir, response)) {
357 sync_protocol_error.error_type = browser_sync::NOT_MY_BIRTHDAY; 361 sync_protocol_error.error_type = browser_sync::NOT_MY_BIRTHDAY;
358 sync_protocol_error.action = 362 sync_protocol_error.action =
359 browser_sync::DISABLE_SYNC_ON_CLIENT; 363 browser_sync::DISABLE_SYNC_ON_CLIENT;
360 } else if (response->has_error()) { 364 } else if (response->has_error()) {
361 // This is a new server. Just get the error from the protocol. 365 // This is a new server. Just get the error from the protocol.
362 sync_protocol_error = ConvertErrorPBToLocalType(response->error()); 366 sync_protocol_error = ConvertErrorPBToLocalType(response->error());
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
528 std::string SyncerProtoUtil::ClientToServerResponseDebugString( 532 std::string SyncerProtoUtil::ClientToServerResponseDebugString(
529 const sync_pb::ClientToServerResponse& response) { 533 const sync_pb::ClientToServerResponse& response) {
530 // Add more handlers as needed. 534 // Add more handlers as needed.
531 std::string output; 535 std::string output;
532 if (response.has_get_updates()) 536 if (response.has_get_updates())
533 output.append(GetUpdatesResponseString(response.get_updates())); 537 output.append(GetUpdatesResponseString(response.get_updates()));
534 return output; 538 return output;
535 } 539 }
536 540
537 } // namespace browser_sync 541 } // namespace browser_sync
OLDNEW
« no previous file with comments | « no previous file | sync/engine/syncer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698