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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/sessions/sync_session.h" 5 #include "chrome/browser/sync/sessions/sync_session.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
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 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 } 134 }
135 135
136 bool SyncSession::HasMoreToSync() const { 136 bool SyncSession::HasMoreToSync() const {
137 const StatusController* status = status_controller_.get(); 137 const StatusController* status = status_controller_.get();
138 return ((status->commit_ids().size() < status->unsynced_handles().size()) && 138 return ((status->commit_ids().size() < status->unsynced_handles().size()) &&
139 status->syncer_status().num_successful_commits > 0) || 139 status->syncer_status().num_successful_commits > 0) ||
140 status->conflict_sets_built() || 140 status->conflict_sets_built() ||
141 status->conflicts_resolved(); 141 status->conflicts_resolved();
142 // Or, we have conflicting updates, but we're making progress on 142 // Or, we have conflicting updates, but we're making progress on
143 // resolving them... 143 // resolving them...
144 }
145
146 static bool IndicatesTransientError(SyncOperationResult result) {
147 switch (result.error_type) {
148 // Not errors at all
149 case OPERATION_SUCCESS:
150 return false;
151
152 // These errors require some action on our part. They'll still be there if
153 // we retry the request without changing anything.
154 case DIRECTORY_LOOKUP_FAILED:
155 case SYNC_AUTH_ERROR:
156 case NOT_MY_BIRTHDAY:
157 case CLEAR_PENDING:
158 case MIGRATION_DONE:
159 return false;
160
161 // Technically, this will go away on its own. However, we don't want to
162 // simply retry the request. We can handle this better if we pretend it's
163 // not a transient error in need of exponential backoff.
164 case THROTTLED:
165 return false;
166
167 // We don't know whether or not this is transient. To avoid overloading the
168 // server, let's assume that it isn't.
169 case UNKNOWN_ERROR:
170 return false;
171
172 // Network errors might go away on their own.
173 case NETWORK_CONNECTION_UNAVAILABLE:
174 case NETWORK_IO_ERROR:
175 case SYNC_SERVER_ERROR:
176 return true;
177
178 // The server thinks we should try again later.
179 case TRANSIENT_ERROR:
180 return true;
181
182 default:
183 NOTREACHED();
184 return false;
144 } 185 }
186 }
187
188 bool SyncSession::ExperiencedTransientError() const {
189 const StatusController* status = status_controller_.get();
190
191 // In the future, we should be able to report more about the cause of the
192 // errors and return an enum value. Right now that's not possible because
193 // our error detection is based on state that can tell us only that an
194 // error exists, but not much else.
195
196 // We were unable to download all updates, for some unknown reason.
197 if (status->num_server_changes_remaining() > 0)
198 return true;
199
200 // Did we run into any temporary network or server issues?
201 if (IndicatesTransientError(status->last_download_updates_result()) ||
202 IndicatesTransientError(status->last_post_commit_result()) ||
203 IndicatesTransientError(status->last_clear_data_result())) {
204 return true;
205 }
206
207 return false;
208 }
145 209
146 } // namespace sessions 210 } // namespace sessions
147 } // namespace browser_sync 211 } // namespace browser_sync
OLDNEW
« 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