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

Side by Side Diff: sync/engine/syncer_proto_util.cc

Issue 488843002: [Sync] Add support for server controlled nudge delays (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 6 years, 4 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 | « sync/engine/sync_scheduler_unittest.cc ('k') | 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/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 402 matching lines...) Expand 10 before | Expand all | Expand 10 after
413 session->delegate()->OnReceivedLongPollIntervalUpdate( 413 session->delegate()->OnReceivedLongPollIntervalUpdate(
414 base::TimeDelta::FromSeconds(command.set_sync_long_poll_interval())); 414 base::TimeDelta::FromSeconds(command.set_sync_long_poll_interval()));
415 } 415 }
416 416
417 if (command.has_set_sync_poll_interval()) { 417 if (command.has_set_sync_poll_interval()) {
418 session->delegate()->OnReceivedShortPollIntervalUpdate( 418 session->delegate()->OnReceivedShortPollIntervalUpdate(
419 base::TimeDelta::FromSeconds(command.set_sync_poll_interval())); 419 base::TimeDelta::FromSeconds(command.set_sync_poll_interval()));
420 } 420 }
421 421
422 if (command.has_sessions_commit_delay_seconds()) { 422 if (command.has_sessions_commit_delay_seconds()) {
423 session->delegate()->OnReceivedSessionsCommitDelay( 423 std::map<ModelType, base::TimeDelta> delay_map;
424 base::TimeDelta::FromSeconds( 424 delay_map[SESSIONS] =
425 command.sessions_commit_delay_seconds())); 425 base::TimeDelta::FromSeconds(command.sessions_commit_delay_seconds());
426 session->delegate()->OnReceivedCustomNudgeDelays(delay_map);
426 } 427 }
427 428
428 if (command.has_client_invalidation_hint_buffer_size()) { 429 if (command.has_client_invalidation_hint_buffer_size()) {
429 session->delegate()->OnReceivedClientInvalidationHintBufferSize( 430 session->delegate()->OnReceivedClientInvalidationHintBufferSize(
430 command.client_invalidation_hint_buffer_size()); 431 command.client_invalidation_hint_buffer_size());
431 } 432 }
432 433
433 if (command.has_gu_retry_delay_seconds()) { 434 if (command.has_gu_retry_delay_seconds()) {
434 session->delegate()->OnReceivedGuRetryDelay( 435 session->delegate()->OnReceivedGuRetryDelay(
435 base::TimeDelta::FromSeconds(command.gu_retry_delay_seconds())); 436 base::TimeDelta::FromSeconds(command.gu_retry_delay_seconds()));
436 } 437 }
438
439 if (command.custom_nudge_delays_size() > 0) {
440 // Note that because this happens after the sessions_commit_delay_seconds
441 // handling, any SESSIONS value in this map will override the one in
442 // sessions_commit_delay_seconds.
443 std::map<ModelType, base::TimeDelta> delay_map;
444 for (int i = 0; i < command.custom_nudge_delays_size(); ++i) {
445 ModelType type = GetModelTypeFromSpecificsFieldNumber(
446 command.custom_nudge_delays(i).datatype_id());
447 if (ProtocolTypes().Has(type)) {
448 delay_map[type] = base::TimeDelta::FromMilliseconds(
449 command.custom_nudge_delays(i).delay_ms());
450 }
451 }
452 session->delegate()->OnReceivedCustomNudgeDelays(delay_map);
453 }
437 } 454 }
438 455
439 // Now do any special handling for the error type and decide on the return 456 // Now do any special handling for the error type and decide on the return
440 // value. 457 // value.
441 switch (sync_protocol_error.error_type) { 458 switch (sync_protocol_error.error_type) {
442 case UNKNOWN_ERROR: 459 case UNKNOWN_ERROR:
443 LOG(WARNING) << "Sync protocol out-of-date. The server is using a more " 460 LOG(WARNING) << "Sync protocol out-of-date. The server is using a more "
444 << "recent version."; 461 << "recent version.";
445 return SERVER_RETURN_UNKNOWN_ERROR; 462 return SERVER_RETURN_UNKNOWN_ERROR;
446 case SYNC_SUCCESS: 463 case SYNC_SUCCESS:
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
575 std::string SyncerProtoUtil::ClientToServerResponseDebugString( 592 std::string SyncerProtoUtil::ClientToServerResponseDebugString(
576 const ClientToServerResponse& response) { 593 const ClientToServerResponse& response) {
577 // Add more handlers as needed. 594 // Add more handlers as needed.
578 std::string output; 595 std::string output;
579 if (response.has_get_updates()) 596 if (response.has_get_updates())
580 output.append(GetUpdatesResponseString(response.get_updates())); 597 output.append(GetUpdatesResponseString(response.get_updates()));
581 return output; 598 return output;
582 } 599 }
583 600
584 } // namespace syncer 601 } // namespace syncer
OLDNEW
« no previous file with comments | « sync/engine/sync_scheduler_unittest.cc ('k') | sync/engine/syncer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698