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

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: Self review 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
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, int> delay_map;
424 base::TimeDelta::FromSeconds( 424 delay_map[SESSIONS] = command.sessions_commit_delay_seconds() * 1000;
425 command.sessions_commit_delay_seconds())); 425 session->delegate()->OnReceivedCustomNudgeDelays(delay_map);
426 } 426 }
427 427
428 if (command.has_client_invalidation_hint_buffer_size()) { 428 if (command.has_client_invalidation_hint_buffer_size()) {
429 session->delegate()->OnReceivedClientInvalidationHintBufferSize( 429 session->delegate()->OnReceivedClientInvalidationHintBufferSize(
430 command.client_invalidation_hint_buffer_size()); 430 command.client_invalidation_hint_buffer_size());
431 } 431 }
432 432
433 if (command.has_gu_retry_delay_seconds()) { 433 if (command.has_gu_retry_delay_seconds()) {
434 session->delegate()->OnReceivedGuRetryDelay( 434 session->delegate()->OnReceivedGuRetryDelay(
435 base::TimeDelta::FromSeconds(command.gu_retry_delay_seconds())); 435 base::TimeDelta::FromSeconds(command.gu_retry_delay_seconds()));
436 } 436 }
437
438 if (command.custom_nudge_delays_size() > 0) {
439 // Note that because this happens after the sessions_commit_delay_seconds
440 // handling, any SESSIONS value in this map will override the one in
441 // sessions_commit_delay_seconds.
442 std::map<ModelType, int> delay_map;
443 for (int i = 0; i < command.custom_nudge_delays_size(); ++i) {
444 delay_map[GetModelTypeFromSpecificsFieldNumber(
rlarocque 2014/08/20 00:13:31 Should we be more defensive against unknown model
Nicolas Zea 2014/08/20 22:49:43 Good call, this has bitten us before.
445 command.custom_nudge_delays(i).datatype_id())] =
446 command.custom_nudge_delays(i).delay_ms();
447 }
448 session->delegate()->OnReceivedCustomNudgeDelays(delay_map);
449 }
437 } 450 }
438 451
439 // Now do any special handling for the error type and decide on the return 452 // Now do any special handling for the error type and decide on the return
440 // value. 453 // value.
441 switch (sync_protocol_error.error_type) { 454 switch (sync_protocol_error.error_type) {
442 case UNKNOWN_ERROR: 455 case UNKNOWN_ERROR:
443 LOG(WARNING) << "Sync protocol out-of-date. The server is using a more " 456 LOG(WARNING) << "Sync protocol out-of-date. The server is using a more "
444 << "recent version."; 457 << "recent version.";
445 return SERVER_RETURN_UNKNOWN_ERROR; 458 return SERVER_RETURN_UNKNOWN_ERROR;
446 case SYNC_SUCCESS: 459 case SYNC_SUCCESS:
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
575 std::string SyncerProtoUtil::ClientToServerResponseDebugString( 588 std::string SyncerProtoUtil::ClientToServerResponseDebugString(
576 const ClientToServerResponse& response) { 589 const ClientToServerResponse& response) {
577 // Add more handlers as needed. 590 // Add more handlers as needed.
578 std::string output; 591 std::string output;
579 if (response.has_get_updates()) 592 if (response.has_get_updates())
580 output.append(GetUpdatesResponseString(response.get_updates())); 593 output.append(GetUpdatesResponseString(response.get_updates()));
581 return output; 594 return output;
582 } 595 }
583 596
584 } // namespace syncer 597 } // namespace syncer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698