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

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

Issue 10454105: sync: Refactor per-datatype throttling (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Cleaned up and rebased Created 8 years, 6 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/stringprintf.h" 8 #include "base/stringprintf.h"
9 #include "sync/engine/throttled_data_type_tracker.h"
tim (not reviewing) 2012/06/11 18:53:46 include order (tools/sort-headers.py is great!)
rlarocque 2012/06/11 23:28:51 Done.
9 #include "sync/engine/net/server_connection_manager.h" 10 #include "sync/engine/net/server_connection_manager.h"
10 #include "sync/engine/syncer.h" 11 #include "sync/engine/syncer.h"
11 #include "sync/engine/syncer_types.h" 12 #include "sync/engine/syncer_types.h"
12 #include "sync/engine/traffic_logger.h" 13 #include "sync/engine/traffic_logger.h"
13 #include "sync/protocol/sync.pb.h" 14 #include "sync/protocol/sync.pb.h"
14 #include "sync/protocol/sync_enums.pb.h" 15 #include "sync/protocol/sync_enums.pb.h"
15 #include "sync/protocol/sync_protocol_error.h" 16 #include "sync/protocol/sync_protocol_error.h"
16 #include "sync/sessions/sync_session.h" 17 #include "sync/sessions/sync_session.h"
17 #include "sync/syncable/model_type.h" 18 #include "sync/syncable/model_type.h"
18 #include "sync/syncable/syncable-inl.h" 19 #include "sync/syncable/syncable-inl.h"
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 throttle_delay = 207 throttle_delay =
207 base::TimeDelta::FromSeconds(command.throttle_delay_seconds()); 208 base::TimeDelta::FromSeconds(command.throttle_delay_seconds());
208 } 209 }
209 } 210 }
210 return throttle_delay; 211 return throttle_delay;
211 } 212 }
212 213
213 void SyncerProtoUtil::HandleThrottleError( 214 void SyncerProtoUtil::HandleThrottleError(
214 const SyncProtocolError& error, 215 const SyncProtocolError& error,
215 const base::TimeTicks& throttled_until, 216 const base::TimeTicks& throttled_until,
216 sessions::SyncSessionContext* context, 217 ThrottledDataTypeTracker* tdtt,
tim (not reviewing) 2012/06/11 18:53:46 We should try to use as meaningful a name as possi
rlarocque 2012/06/11 23:28:51 Done.
217 sessions::SyncSession::Delegate* delegate) { 218 sessions::SyncSession::Delegate* delegate) {
218 DCHECK_EQ(error.error_type, browser_sync::THROTTLED); 219 DCHECK_EQ(error.error_type, browser_sync::THROTTLED);
219 if (error.error_data_types.Empty()) { 220 if (error.error_data_types.Empty()) {
220 // No datatypes indicates the client should be completely throttled. 221 // No datatypes indicates the client should be completely throttled.
221 delegate->OnSilencedUntil(throttled_until); 222 delegate->OnSilencedUntil(throttled_until);
222 } else { 223 } else {
223 context->SetUnthrottleTime(error.error_data_types, throttled_until); 224 tdtt->SetUnthrottleTime(error.error_data_types, throttled_until);
224 } 225 }
225 } 226 }
226 227
227 namespace { 228 namespace {
228 229
229 // Helper function for an assertion in PostClientToServerMessage. 230 // Helper function for an assertion in PostClientToServerMessage.
230 bool IsVeryFirstGetUpdates(const ClientToServerMessage& message) { 231 bool IsVeryFirstGetUpdates(const ClientToServerMessage& message) {
231 if (!message.has_get_updates()) 232 if (!message.has_get_updates())
232 return false; 233 return false;
233 DCHECK_LT(0, message.get_updates().from_progress_marker_size()); 234 DCHECK_LT(0, message.get_updates().from_progress_marker_size());
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
386 LOG(WARNING) << "Sync protocol out-of-date. The server is using a more " 387 LOG(WARNING) << "Sync protocol out-of-date. The server is using a more "
387 << "recent version."; 388 << "recent version.";
388 return SERVER_RETURN_UNKNOWN_ERROR; 389 return SERVER_RETURN_UNKNOWN_ERROR;
389 case browser_sync::SYNC_SUCCESS: 390 case browser_sync::SYNC_SUCCESS:
390 LogResponseProfilingData(*response); 391 LogResponseProfilingData(*response);
391 return SYNCER_OK; 392 return SYNCER_OK;
392 case browser_sync::THROTTLED: 393 case browser_sync::THROTTLED:
393 LOG(WARNING) << "Client silenced by server."; 394 LOG(WARNING) << "Client silenced by server.";
394 HandleThrottleError(sync_protocol_error, 395 HandleThrottleError(sync_protocol_error,
395 base::TimeTicks::Now() + GetThrottleDelay(*response), 396 base::TimeTicks::Now() + GetThrottleDelay(*response),
396 session->context(), 397 session->context()->throttled_data_type_tracker(),
397 session->delegate()); 398 session->delegate());
398 return SERVER_RETURN_THROTTLED; 399 return SERVER_RETURN_THROTTLED;
399 case browser_sync::TRANSIENT_ERROR: 400 case browser_sync::TRANSIENT_ERROR:
400 return SERVER_RETURN_TRANSIENT_ERROR; 401 return SERVER_RETURN_TRANSIENT_ERROR;
401 case browser_sync::MIGRATION_DONE: 402 case browser_sync::MIGRATION_DONE:
402 HandleMigrationDoneResponse(response, session); 403 HandleMigrationDoneResponse(response, session);
403 return SERVER_RETURN_MIGRATION_DONE; 404 return SERVER_RETURN_MIGRATION_DONE;
404 case browser_sync::CLEAR_PENDING: 405 case browser_sync::CLEAR_PENDING:
405 return SERVER_RETURN_CLEAR_PENDING; 406 return SERVER_RETURN_CLEAR_PENDING;
406 case browser_sync::NOT_MY_BIRTHDAY: 407 case browser_sync::NOT_MY_BIRTHDAY:
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
534 std::string SyncerProtoUtil::ClientToServerResponseDebugString( 535 std::string SyncerProtoUtil::ClientToServerResponseDebugString(
535 const sync_pb::ClientToServerResponse& response) { 536 const sync_pb::ClientToServerResponse& response) {
536 // Add more handlers as needed. 537 // Add more handlers as needed.
537 std::string output; 538 std::string output;
538 if (response.has_get_updates()) 539 if (response.has_get_updates())
539 output.append(GetUpdatesResponseString(response.get_updates())); 540 output.append(GetUpdatesResponseString(response.get_updates()));
540 return output; 541 return output;
541 } 542 }
542 543
543 } // namespace browser_sync 544 } // namespace browser_sync
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698