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