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

Unified Diff: chrome/browser/sync/sessions/sync_session.cc

Issue 7861013: Fix the false-positive detection of commit errors (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Another attempt at detecting errors Created 9 years, 2 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/sessions/sync_session.h ('k') | chrome/browser/sync/sessions/test_util.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/sync/sessions/sync_session.cc
diff --git a/chrome/browser/sync/sessions/sync_session.cc b/chrome/browser/sync/sessions/sync_session.cc
index f399d7d7904ed1fee8a5425a8641cfaaab04675e..42ee29845e6104aa9af7a96fcc2fdaeb9ef8310b 100644
--- a/chrome/browser/sync/sessions/sync_session.cc
+++ b/chrome/browser/sync/sessions/sync_session.cc
@@ -141,7 +141,71 @@ bool SyncSession::HasMoreToSync() const {
status->conflicts_resolved();
// Or, we have conflicting updates, but we're making progress on
// resolving them...
+}
+
+static bool IndicatesTransientError(SyncOperationResult result) {
+ switch (result.error_type) {
+ // Not errors at all
+ case OPERATION_SUCCESS:
+ return false;
+
+ // These errors require some action on our part. They'll still be there if
+ // we retry the request without changing anything.
+ case DIRECTORY_LOOKUP_FAILED:
+ case SYNC_AUTH_ERROR:
+ case NOT_MY_BIRTHDAY:
+ case CLEAR_PENDING:
+ case MIGRATION_DONE:
+ return false;
+
+ // Technically, this will go away on its own. However, we don't want to
+ // simply retry the request. We can handle this better if we pretend it's
+ // not a transient error in need of exponential backoff.
+ case THROTTLED:
+ return false;
+
+ // We don't know whether or not this is transient. To avoid overloading the
+ // server, let's assume that it isn't.
+ case UNKNOWN_ERROR:
+ return false;
+
+ // Network errors might go away on their own.
+ case NETWORK_CONNECTION_UNAVAILABLE:
+ case NETWORK_IO_ERROR:
+ case SYNC_SERVER_ERROR:
+ return true;
+
+ // The server thinks we should try again later.
+ case TRANSIENT_ERROR:
+ return true;
+
+ default:
+ NOTREACHED();
+ return false;
}
+}
+
+bool SyncSession::ExperiencedTransientError() const {
+ const StatusController* status = status_controller_.get();
+
+ // In the future, we should be able to report more about the cause of the
+ // errors and return an enum value. Right now that's not possible because
+ // our error detection is based on state that can tell us only that an
+ // error exists, but not much else.
+
+ // We were unable to download all updates, for some unknown reason.
+ if (status->num_server_changes_remaining() > 0)
+ return true;
+
+ // Did we run into any temporary network or server issues?
+ if (IndicatesTransientError(status->last_download_updates_result()) ||
+ IndicatesTransientError(status->last_post_commit_result()) ||
+ IndicatesTransientError(status->last_clear_data_result())) {
+ return true;
+ }
+
+ return false;
+}
} // namespace sessions
} // namespace browser_sync
« no previous file with comments | « chrome/browser/sync/sessions/sync_session.h ('k') | chrome/browser/sync/sessions/test_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698