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

Unified Diff: sync/engine/store_timestamps_command.cc

Issue 11485019: [Sync] Add tests for invalid specifics field number handling (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 8 years 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 side-by-side diff with in-line comments
Download patch
Index: sync/engine/store_timestamps_command.cc
diff --git a/sync/engine/store_timestamps_command.cc b/sync/engine/store_timestamps_command.cc
index 6f381b0d7a36510fdb1f0e64a658c5d001f47422..cbff68fec50df8a8344d596ae2cdadc4706a620c 100644
--- a/sync/engine/store_timestamps_command.cc
+++ b/sync/engine/store_timestamps_command.cc
@@ -4,39 +4,44 @@
#include "sync/engine/store_timestamps_command.h"
-#include "sync/internal_api/public/base/model_type.h"
+#include "base/logging.h"
#include "sync/sessions/status_controller.h"
#include "sync/sessions/sync_session.h"
#include "sync/syncable/directory.h"
namespace syncer {
+ModelTypeSet ProcessNewProgressMarkers(
+ const sync_pb::GetUpdatesResponse& response,
+ syncable::Directory* dir) {
+ ModelTypeSet forward_progress_types;
+ // If a marker was omitted for any one type, that indicates no
+ // change from the previous state.
+ for (int i = 0; i < response.new_progress_marker_size(); ++i) {
+ int field_number = response.new_progress_marker(i).data_type_id();
+ ModelType model_type = GetModelTypeFromSpecificsFieldNumber(field_number);
+ if (!IsRealDataType(model_type)) {
+ DLOG(WARNING) << "Unknown field number " << field_number;
+ continue;
+ }
+ forward_progress_types.Put(model_type);
+ dir->SetDownloadProgress(model_type, response.new_progress_marker(i));
+ }
+ return forward_progress_types;
+}
+
StoreTimestampsCommand::StoreTimestampsCommand() {}
StoreTimestampsCommand::~StoreTimestampsCommand() {}
SyncerError StoreTimestampsCommand::ExecuteImpl(
sessions::SyncSession* session) {
- syncable::Directory* dir = session->context()->directory();
-
const sync_pb::GetUpdatesResponse& updates =
session->status_controller().updates_response().get_updates();
sessions::StatusController* status = session->mutable_status_controller();
- // Update the progress marker tokens from the server result. If a marker
- // was omitted for any one type, that indicates no change from the previous
- // state.
- ModelTypeSet forward_progress_types;
- for (int i = 0; i < updates.new_progress_marker_size(); ++i) {
- int field_number = updates.new_progress_marker(i).data_type_id();
- ModelType model_type = GetModelTypeFromSpecificsFieldNumber(field_number);
- if (!IsRealDataType(model_type)) {
- NOTREACHED() << "Unknown field number " << field_number;
- continue;
- }
- forward_progress_types.Put(model_type);
- dir->SetDownloadProgress(model_type, updates.new_progress_marker(i));
- }
+ ModelTypeSet forward_progress_types =
+ ProcessNewProgressMarkers(updates, session->context()->directory());
DCHECK(!forward_progress_types.Empty() ||
updates.changes_remaining() == 0);
if (VLOG_IS_ON(1)) {

Powered by Google App Engine
This is Rietveld 408576698