| 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/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" |
| (...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 387 response->error_code()); | 387 response->error_code()); |
| 388 } | 388 } |
| 389 | 389 |
| 390 // Now set the error into the status so the layers above us could read it. | 390 // Now set the error into the status so the layers above us could read it. |
| 391 sessions::StatusController* status = session->mutable_status_controller(); | 391 sessions::StatusController* status = session->mutable_status_controller(); |
| 392 status->set_sync_protocol_error(sync_protocol_error); | 392 status->set_sync_protocol_error(sync_protocol_error); |
| 393 | 393 |
| 394 // Inform the delegate of the error we got. | 394 // Inform the delegate of the error we got. |
| 395 session->delegate()->OnSyncProtocolError(session->TakeSnapshot()); | 395 session->delegate()->OnSyncProtocolError(session->TakeSnapshot()); |
| 396 | 396 |
| 397 // Update our state for any other commands we've received. |
| 398 if (response->has_client_command()) { |
| 399 const sync_pb::ClientCommand& command = response->client_command(); |
| 400 if (command.has_max_commit_batch_size()) { |
| 401 session->context()->set_max_commit_batch_size( |
| 402 command.max_commit_batch_size()); |
| 403 } |
| 404 |
| 405 if (command.has_set_sync_long_poll_interval()) { |
| 406 session->delegate()->OnReceivedLongPollIntervalUpdate( |
| 407 base::TimeDelta::FromSeconds(command.set_sync_long_poll_interval())); |
| 408 } |
| 409 |
| 410 if (command.has_set_sync_poll_interval()) { |
| 411 session->delegate()->OnReceivedShortPollIntervalUpdate( |
| 412 base::TimeDelta::FromSeconds(command.set_sync_poll_interval())); |
| 413 } |
| 414 |
| 415 if (command.has_sessions_commit_delay_seconds()) { |
| 416 session->delegate()->OnReceivedSessionsCommitDelay( |
| 417 base::TimeDelta::FromSeconds( |
| 418 command.sessions_commit_delay_seconds())); |
| 419 } |
| 420 } |
| 421 |
| 397 // Now do any special handling for the error type and decide on the return | 422 // Now do any special handling for the error type and decide on the return |
| 398 // value. | 423 // value. |
| 399 switch (sync_protocol_error.error_type) { | 424 switch (sync_protocol_error.error_type) { |
| 400 case UNKNOWN_ERROR: | 425 case UNKNOWN_ERROR: |
| 401 LOG(WARNING) << "Sync protocol out-of-date. The server is using a more " | 426 LOG(WARNING) << "Sync protocol out-of-date. The server is using a more " |
| 402 << "recent version."; | 427 << "recent version."; |
| 403 return SERVER_RETURN_UNKNOWN_ERROR; | 428 return SERVER_RETURN_UNKNOWN_ERROR; |
| 404 case SYNC_SUCCESS: | 429 case SYNC_SUCCESS: |
| 405 LogResponseProfilingData(*response); | 430 LogResponseProfilingData(*response); |
| 406 return SYNCER_OK; | 431 return SYNCER_OK; |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 547 std::string SyncerProtoUtil::ClientToServerResponseDebugString( | 572 std::string SyncerProtoUtil::ClientToServerResponseDebugString( |
| 548 const ClientToServerResponse& response) { | 573 const ClientToServerResponse& response) { |
| 549 // Add more handlers as needed. | 574 // Add more handlers as needed. |
| 550 std::string output; | 575 std::string output; |
| 551 if (response.has_get_updates()) | 576 if (response.has_get_updates()) |
| 552 output.append(GetUpdatesResponseString(response.get_updates())); | 577 output.append(GetUpdatesResponseString(response.get_updates())); |
| 553 return output; | 578 return output; |
| 554 } | 579 } |
| 555 | 580 |
| 556 } // namespace syncer | 581 } // namespace syncer |
| OLD | NEW |