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

Unified Diff: chrome/browser/sync/sessions/status_controller.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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/sync/sessions/status_controller.cc
diff --git a/chrome/browser/sync/sessions/status_controller.cc b/chrome/browser/sync/sessions/status_controller.cc
index 7c1602df0776e78e7e4b1ae793a78335c0c322b3..c8d6866b78c95f2a71814b7c6f29a738ebcd30e6 100644
--- a/chrome/browser/sync/sessions/status_controller.cc
+++ b/chrome/browser/sync/sessions/status_controller.cc
@@ -16,7 +16,6 @@ using syncable::MODEL_TYPE_COUNT;
StatusController::StatusController(const ModelSafeRoutingInfo& routes)
: shared_(&is_dirty_),
per_model_group_deleter_(&per_model_group_),
- per_model_type_deleter_(&per_model_type_),
is_dirty_(false),
group_restriction_in_effect_(false),
group_restriction_(GROUP_PASSIVE),
@@ -42,26 +41,22 @@ PerModelSafeGroupState* StatusController::GetOrCreateModelSafeGroupState(
return per_model_group_[group];
}
-PerModelTypeState* StatusController::GetOrCreateModelTypeState(
- bool restrict, syncable::ModelType model) {
- if (restrict) {
- DCHECK(group_restriction_in_effect_) << "No group restriction in effect!";
- DCHECK_EQ(group_restriction_, GetGroupForModelType(model, routing_info_));
- }
- if (per_model_type_.find(model) == per_model_type_.end()) {
- PerModelTypeState* state = new PerModelTypeState(&is_dirty_);
- per_model_type_[model] = state;
- return state;
- }
- return per_model_type_[model];
-}
-
void StatusController::increment_num_conflicting_commits_by(int value) {
if (value == 0)
return;
shared_.error_counters.mutate()->num_conflicting_commits += value;
}
+void StatusController::increment_num_updates_downloaded_by(int value) {
+ shared_.syncer_status.mutate()->num_updates_downloaded_total += value;
+}
+
+void StatusController::increment_num_tombstone_updates_downloaded_by(
+ int value) {
+ shared_.syncer_status.mutate()->num_tombstone_updates_downloaded_total +=
+ value;
+}
+
void StatusController::reset_num_conflicting_commits() {
if (shared_.error_counters.value().num_conflicting_commits != 0)
shared_.error_counters.mutate()->num_conflicting_commits = 0;
@@ -87,14 +82,6 @@ void StatusController::set_num_consecutive_errors(int value) {
shared_.error_counters.mutate()->consecutive_errors = value;
}
-void StatusController::set_current_download_timestamp(
- syncable::ModelType model,
- int64 current_timestamp) {
- PerModelTypeState* state = GetOrCreateModelTypeState(false, model);
- if (current_timestamp > state->current_download_timestamp.value())
- *(state->current_download_timestamp.mutate()) = current_timestamp;
-}
-
void StatusController::set_num_server_changes_remaining(
int64 changes_remaining) {
if (shared_.num_server_changes_remaining.value() != changes_remaining)
@@ -181,17 +168,6 @@ bool StatusController::CurrentCommitIdProjectionHasIndex(size_t index) {
return std::binary_search(proj.begin(), proj.end(), index);
}
-int64 StatusController::ComputeMaxLocalTimestamp() const {
- std::map<syncable::ModelType, PerModelTypeState*>::const_iterator it =
- per_model_type_.begin();
- int64 max_timestamp = 0;
- for (; it != per_model_type_.end(); ++it) {
- if (it->second->current_download_timestamp.value() > max_timestamp)
- max_timestamp = it->second->current_download_timestamp.value();
- }
- return max_timestamp;
-}
-
bool StatusController::HasConflictingUpdates() const {
DCHECK(!group_restriction_in_effect_)
<< "HasConflictingUpdates applies to all ModelSafeGroups";
@@ -219,23 +195,14 @@ int StatusController::TotalNumConflictingItems() const {
bool StatusController::ServerSaysNothingMoreToDownload() const {
if (!download_updates_succeeded())
return false;
- // If we didn't request every enabled datatype, then we can't say for
- // sure that there's nothing left to download.
- for (int i = FIRST_REAL_MODEL_TYPE; i < MODEL_TYPE_COUNT; ++i) {
- if (!updates_request_parameters().data_types[i] &&
- routing_info_.count(syncable::ModelTypeFromInt(i)) != 0) {
- return false;
- }
+
+ if (!updates_response().get_updates().has_changes_remaining()) {
+ NOTREACHED(); // Server should always send changes remaining.
+ return false; // Avoid looping forever.
}
// Changes remaining is an estimate, but if it's estimated to be
// zero, that's firm and we don't have to ask again.
- if (updates_response().get_updates().has_changes_remaining() &&
- updates_response().get_updates().changes_remaining() == 0) {
- return true;
- }
- // Otherwise, the server can also indicate "you're up to date"
- // by not sending a new timestamp.
- return !updates_response().get_updates().has_new_timestamp();
+ return updates_response().get_updates().changes_remaining() == 0;
}
} // namespace sessions
« no previous file with comments | « chrome/browser/sync/sessions/status_controller.h ('k') | chrome/browser/sync/sessions/status_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698