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

Unified Diff: chrome/browser/sync/engine/all_status.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
« no previous file with comments | « chrome/browser/sync/engine/all_status.h ('k') | chrome/browser/sync/engine/download_updates_command.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/sync/engine/all_status.cc
diff --git a/chrome/browser/sync/engine/all_status.cc b/chrome/browser/sync/engine/all_status.cc
index 5beaa80c060ed80793d0a8d255927f5beec022a2..8d4b85e54b30380df6df50d89d0e58d64e1860c6 100644
--- a/chrome/browser/sync/engine/all_status.cc
+++ b/chrome/browser/sync/engine/all_status.cc
@@ -15,17 +15,8 @@
namespace browser_sync {
-const char* AllStatus::GetSyncStatusString(SyncStatus icon) {
- const char* strings[] = {"OFFLINE", "OFFLINE_UNSYNCED", "SYNCING", "READY",
- "CONFLICT", "OFFLINE_UNUSABLE"};
- COMPILE_ASSERT(arraysize(strings) == ICON_STATUS_COUNT, enum_indexed_array);
- if (icon < 0 || icon >= static_cast<SyncStatus>(arraysize(strings)))
- LOG(FATAL) << "Illegal Icon State:" << icon;
- return strings[icon];
-}
-
-static const AllStatus::Status init_status =
- { AllStatus::OFFLINE };
+static const sync_api::SyncManager::Status init_status =
+ { sync_api::SyncManager::Status::OFFLINE };
AllStatus::AllStatus() : status_(init_status) {
status_.initial_sync_ended = true;
@@ -35,8 +26,11 @@ AllStatus::AllStatus() : status_(init_status) {
AllStatus::~AllStatus() {
}
-AllStatus::Status AllStatus::CreateBlankStatus() const {
- Status status = status_;
+sync_api::SyncManager::Status AllStatus::CreateBlankStatus() const {
+ // Status is initialized with the previous status value. Variables
+ // whose values accumulate (e.g. lifetime counters like updates_received)
+ // are not to be cleared here.
+ sync_api::SyncManager::Status status = status_;
status.syncing = true;
status.unsynced_count = 0;
status.conflicting_count = 0;
@@ -45,12 +39,12 @@ AllStatus::Status AllStatus::CreateBlankStatus() const {
status.max_consecutive_errors = 0;
status.server_broken = false;
status.updates_available = 0;
- status.updates_received = 0;
return status;
}
-AllStatus::Status AllStatus::CalcSyncing(const SyncEngineEvent &event) const {
- Status status = CreateBlankStatus();
+sync_api::SyncManager::Status AllStatus::CalcSyncing(
+ const SyncEngineEvent &event) const {
+ sync_api::SyncManager::Status status = CreateBlankStatus();
const sessions::SyncSessionSnapshot* snapshot = event.snapshot;
status.unsynced_count += static_cast<int>(snapshot->unsynced_count);
status.conflicting_count += snapshot->errors.num_conflicting_commits;
@@ -72,7 +66,16 @@ AllStatus::Status AllStatus::CalcSyncing(const SyncEngineEvent &event) const {
status.server_broken = true;
status.updates_available += snapshot->num_server_changes_remaining;
- status.updates_received += snapshot->max_local_timestamp;
+
+ // Accumulate update count only once per session to avoid double-counting.
+ // TODO(ncarter): Make this realtime by having the syncer_status
+ // counter preserve its value across sessions. http://crbug.com/26339
+ if (event.what_happened == SyncEngineEvent::SYNC_CYCLE_ENDED) {
+ status.updates_received +=
+ snapshot->syncer_status.num_updates_downloaded_total;
+ status.tombstone_updates_received +=
+ snapshot->syncer_status.num_tombstone_updates_downloaded_total;
+ }
return status;
}
@@ -82,17 +85,17 @@ void AllStatus::CalcStatusChanges() {
status_.server_reachable && status_.server_up && !status_.server_broken;
if (online) {
if (status_.syncer_stuck)
- status_.icon = CONFLICT;
+ status_.summary = sync_api::SyncManager::Status::CONFLICT;
else if (unsynced_changes || status_.syncing)
- status_.icon = SYNCING;
+ status_.summary = sync_api::SyncManager::Status::SYNCING;
else
- status_.icon = READY;
+ status_.summary = sync_api::SyncManager::Status::READY;
} else if (!status_.initial_sync_ended) {
- status_.icon = OFFLINE_UNUSABLE;
+ status_.summary = sync_api::SyncManager::Status::OFFLINE_UNUSABLE;
} else if (unsynced_changes) {
- status_.icon = OFFLINE_UNSYNCED;
+ status_.summary = sync_api::SyncManager::Status::OFFLINE_UNSYNCED;
} else {
- status_.icon = OFFLINE;
+ status_.summary = sync_api::SyncManager::Status::OFFLINE;
}
}
@@ -134,7 +137,7 @@ void AllStatus::HandleServerConnectionEvent(
}
}
-AllStatus::Status AllStatus::status() const {
+sync_api::SyncManager::Status AllStatus::status() const {
AutoLock lock(mutex_);
return status_;
}
« no previous file with comments | « chrome/browser/sync/engine/all_status.h ('k') | chrome/browser/sync/engine/download_updates_command.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698