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

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

Issue 6104003: sync: use progress markers instead of timestamps during GetUpdates (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Tim's fixes Created 9 years, 11 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "chrome/browser/sync/engine/store_timestamps_command.h" 5 #include "chrome/browser/sync/engine/store_timestamps_command.h"
6 6
7 #include "chrome/browser/sync/sessions/status_controller.h" 7 #include "chrome/browser/sync/sessions/status_controller.h"
8 #include "chrome/browser/sync/sessions/sync_session.h" 8 #include "chrome/browser/sync/sessions/sync_session.h"
9 #include "chrome/browser/sync/syncable/directory_manager.h" 9 #include "chrome/browser/sync/syncable/directory_manager.h"
10 #include "chrome/browser/sync/syncable/model_type.h" 10 #include "chrome/browser/sync/syncable/model_type.h"
(...skipping 10 matching lines...) Expand all
21 21
22 if (!dir.good()) { 22 if (!dir.good()) {
23 LOG(ERROR) << "Scoped dir lookup failed!"; 23 LOG(ERROR) << "Scoped dir lookup failed!";
24 return; 24 return;
25 } 25 }
26 26
27 const GetUpdatesResponse& updates = 27 const GetUpdatesResponse& updates =
28 session->status_controller()->updates_response().get_updates(); 28 session->status_controller()->updates_response().get_updates();
29 29
30 sessions::StatusController* status = session->status_controller(); 30 sessions::StatusController* status = session->status_controller();
31
32 // Update the progress marker tokens from the server result. If a marker
33 // was omitted for any one type, that indicates no change from the previous
34 // state.
35 syncable::ModelTypeBitSet forward_progress_types;
36 for (int i = 0; i < updates.new_progress_marker_size(); ++i) {
37 syncable::ModelType model =
38 syncable::GetModelTypeFromExtensionFieldNumber(
39 updates.new_progress_marker(i).data_type_id());
40 if (model == syncable::UNSPECIFIED || model == syncable::TOP_LEVEL_FOLDER) {
41 NOTREACHED() << "Unintelligible server response.";
42 continue;
43 }
44 forward_progress_types[model] = true;
45 dir->SetDownloadProgress(model, updates.new_progress_marker(i));
46 }
47 DCHECK(forward_progress_types.any() ||
48 updates.changes_remaining() == 0);
49 if (VLOG_IS_ON(1)) {
50 VLOG_IF(1, forward_progress_types.any())
51 << "Get Updates got new progress marker for types: "
52 << forward_progress_types.to_string() << " out of possible: "
53 << status->updates_request_types().to_string();
54 }
31 if (updates.has_changes_remaining()) { 55 if (updates.has_changes_remaining()) {
32 int64 changes_left = updates.changes_remaining(); 56 int64 changes_left = updates.changes_remaining();
33 VLOG(1) << "Changes remaining:" << changes_left; 57 VLOG(1) << "Changes remaining: " << changes_left;
34 status->set_num_server_changes_remaining(changes_left); 58 status->set_num_server_changes_remaining(changes_left);
35 } 59 }
36
37 VLOG_IF(1, updates.has_new_timestamp())
38 << "Get Updates got new timestamp: " << updates.new_timestamp()
39 << " for type mask: "
40 << status->updates_request_parameters().data_types.to_string();
41
42 // Update the saved download timestamp for any items we fetched.
43 for (int i = 0; i < syncable::MODEL_TYPE_COUNT; ++i) {
44 syncable::ModelType model = syncable::ModelTypeFromInt(i);
45 if (status->updates_request_parameters().data_types[i] &&
46 updates.has_new_timestamp() &&
47 (updates.new_timestamp() > dir->last_download_timestamp(model))) {
48 dir->set_last_download_timestamp(model, updates.new_timestamp());
49 }
50 status->set_current_download_timestamp(model,
51 dir->last_download_timestamp(model));
52 }
53 } 60 }
54 61
55 } // namespace browser_sync 62 } // namespace browser_sync
OLDNEW
« no previous file with comments | « chrome/browser/sync/engine/download_updates_command_unittest.cc ('k') | chrome/browser/sync/engine/syncapi.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698