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

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

Issue 11490018: [Sync] Handle invalid specifics field numbers gracefully (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | sync/engine/syncer_proto_util.cc » ('j') | sync/engine/syncer_proto_util.cc » ('J')
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/store_timestamps_command.h" 5 #include "sync/engine/store_timestamps_command.h"
6 6
7 #include "sync/internal_api/public/base/model_type.h" 7 #include "sync/internal_api/public/base/model_type.h"
8 #include "sync/sessions/status_controller.h" 8 #include "sync/sessions/status_controller.h"
9 #include "sync/sessions/sync_session.h" 9 #include "sync/sessions/sync_session.h"
10 #include "sync/syncable/directory.h" 10 #include "sync/syncable/directory.h"
(...skipping 10 matching lines...) Expand all
21 const sync_pb::GetUpdatesResponse& updates = 21 const sync_pb::GetUpdatesResponse& updates =
22 session->status_controller().updates_response().get_updates(); 22 session->status_controller().updates_response().get_updates();
23 23
24 sessions::StatusController* status = session->mutable_status_controller(); 24 sessions::StatusController* status = session->mutable_status_controller();
25 25
26 // Update the progress marker tokens from the server result. If a marker 26 // Update the progress marker tokens from the server result. If a marker
27 // was omitted for any one type, that indicates no change from the previous 27 // was omitted for any one type, that indicates no change from the previous
28 // state. 28 // state.
29 ModelTypeSet forward_progress_types; 29 ModelTypeSet forward_progress_types;
30 for (int i = 0; i < updates.new_progress_marker_size(); ++i) { 30 for (int i = 0; i < updates.new_progress_marker_size(); ++i) {
31 ModelType model = 31 int field_number = updates.new_progress_marker(i).data_type_id();
32 GetModelTypeFromSpecificsFieldNumber( 32 ModelType model_type = GetModelTypeFromSpecificsFieldNumber(field_number);
33 updates.new_progress_marker(i).data_type_id()); 33 if (!IsRealDataType(model_type)) {
34 if (model == UNSPECIFIED || model == TOP_LEVEL_FOLDER) { 34 NOTREACHED() << "Unknown field number " << field_number;
35 NOTREACHED() << "Unintelligible server response.";
36 continue; 35 continue;
37 } 36 }
38 forward_progress_types.Put(model); 37 forward_progress_types.Put(model_type);
39 dir->SetDownloadProgress(model, updates.new_progress_marker(i)); 38 dir->SetDownloadProgress(model_type, updates.new_progress_marker(i));
40 } 39 }
41 DCHECK(!forward_progress_types.Empty() || 40 DCHECK(!forward_progress_types.Empty() ||
42 updates.changes_remaining() == 0); 41 updates.changes_remaining() == 0);
43 if (VLOG_IS_ON(1)) { 42 if (VLOG_IS_ON(1)) {
44 DVLOG_IF(1, !forward_progress_types.Empty()) 43 DVLOG_IF(1, !forward_progress_types.Empty())
45 << "Get Updates got new progress marker for types: " 44 << "Get Updates got new progress marker for types: "
46 << ModelTypeSetToString(forward_progress_types) 45 << ModelTypeSetToString(forward_progress_types)
47 << " out of possible: " 46 << " out of possible: "
48 << ModelTypeSetToString(status->updates_request_types()); 47 << ModelTypeSetToString(status->updates_request_types());
49 } 48 }
50 if (updates.has_changes_remaining()) { 49 if (updates.has_changes_remaining()) {
51 int64 changes_left = updates.changes_remaining(); 50 int64 changes_left = updates.changes_remaining();
52 DVLOG(1) << "Changes remaining: " << changes_left; 51 DVLOG(1) << "Changes remaining: " << changes_left;
53 status->set_num_server_changes_remaining(changes_left); 52 status->set_num_server_changes_remaining(changes_left);
54 } 53 }
55 54
56 return SYNCER_OK; 55 return SYNCER_OK;
57 } 56 }
58 57
59 } // namespace syncer 58 } // namespace syncer
OLDNEW
« no previous file with comments | « no previous file | sync/engine/syncer_proto_util.cc » ('j') | sync/engine/syncer_proto_util.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698