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 "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/strings/stringprintf.h" | 8 #include "base/strings/stringprintf.h" |
9 #include "google_apis/google_api_keys.h" | 9 #include "google_apis/google_api_keys.h" |
10 #include "sync/engine/net/server_connection_manager.h" | 10 #include "sync/engine/net/server_connection_manager.h" |
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
351 AddRequestBirthday(session->context()->directory(), msg); | 351 AddRequestBirthday(session->context()->directory(), msg); |
352 DCHECK(msg->has_store_birthday() || IsVeryFirstGetUpdates(*msg)); | 352 DCHECK(msg->has_store_birthday() || IsVeryFirstGetUpdates(*msg)); |
353 AddBagOfChips(session->context()->directory(), msg); | 353 AddBagOfChips(session->context()->directory(), msg); |
354 msg->set_api_key(google_apis::GetAPIKey()); | 354 msg->set_api_key(google_apis::GetAPIKey()); |
355 msg->mutable_client_status()->CopyFrom(session->context()->client_status()); | 355 msg->mutable_client_status()->CopyFrom(session->context()->client_status()); |
356 msg->set_invalidator_client_id(session->context()->invalidator_client_id()); | 356 msg->set_invalidator_client_id(session->context()->invalidator_client_id()); |
357 | 357 |
358 syncable::Directory* dir = session->context()->directory(); | 358 syncable::Directory* dir = session->context()->directory(); |
359 | 359 |
360 LogClientToServerMessage(*msg); | 360 LogClientToServerMessage(*msg); |
361 session->context()->traffic_recorder()->RecordClientToServerMessage(*msg); | |
362 if (!PostAndProcessHeaders(session->context()->connection_manager(), session, | 361 if (!PostAndProcessHeaders(session->context()->connection_manager(), session, |
363 *msg, response)) { | 362 *msg, response)) { |
364 // There was an error establishing communication with the server. | 363 // There was an error establishing communication with the server. |
365 // We can not proceed beyond this point. | 364 // We can not proceed beyond this point. |
366 const HttpResponse::ServerConnectionCode server_status = | 365 const HttpResponse::ServerConnectionCode server_status = |
367 session->context()->connection_manager()->server_status(); | 366 session->context()->connection_manager()->server_status(); |
368 | 367 |
369 DCHECK_NE(server_status, HttpResponse::NONE); | 368 DCHECK_NE(server_status, HttpResponse::NONE); |
370 DCHECK_NE(server_status, HttpResponse::SERVER_CONNECTION_OK); | 369 DCHECK_NE(server_status, HttpResponse::SERVER_CONNECTION_OK); |
371 | 370 |
372 return ServerConnectionErrorAsSyncerError(server_status); | 371 return ServerConnectionErrorAsSyncerError(server_status); |
373 } | 372 } |
374 | |
375 LogClientToServerResponse(*response); | 373 LogClientToServerResponse(*response); |
376 session->context()->traffic_recorder()->RecordClientToServerResponse( | |
377 *response); | |
378 | 374 |
379 // Persist a bag of chips if it has been sent by the server. | 375 // Persist a bag of chips if it has been sent by the server. |
380 PersistBagOfChips(dir, *response); | 376 PersistBagOfChips(dir, *response); |
381 | 377 |
382 SyncProtocolError sync_protocol_error; | 378 SyncProtocolError sync_protocol_error; |
383 | 379 |
384 // The DISABLED_BY_ADMIN error overrides other errors sent by the server. | 380 // The DISABLED_BY_ADMIN error overrides other errors sent by the server. |
385 if (IsSyncDisabledByAdmin(*response)) { | 381 if (IsSyncDisabledByAdmin(*response)) { |
386 sync_protocol_error.error_type = DISABLED_BY_ADMIN; | 382 sync_protocol_error.error_type = DISABLED_BY_ADMIN; |
387 sync_protocol_error.action = STOP_SYNC_FOR_DISABLED_ACCOUNT; | 383 sync_protocol_error.action = STOP_SYNC_FOR_DISABLED_ACCOUNT; |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
573 std::string SyncerProtoUtil::ClientToServerResponseDebugString( | 569 std::string SyncerProtoUtil::ClientToServerResponseDebugString( |
574 const ClientToServerResponse& response) { | 570 const ClientToServerResponse& response) { |
575 // Add more handlers as needed. | 571 // Add more handlers as needed. |
576 std::string output; | 572 std::string output; |
577 if (response.has_get_updates()) | 573 if (response.has_get_updates()) |
578 output.append(GetUpdatesResponseString(response.get_updates())); | 574 output.append(GetUpdatesResponseString(response.get_updates())); |
579 return output; | 575 return output; |
580 } | 576 } |
581 | 577 |
582 } // namespace syncer | 578 } // namespace syncer |
OLD | NEW |