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

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

Issue 7477004: Simulate transient error and verify exponential backoff. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Upload before commit. Created 9 years, 4 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/engine/syncer.h ('k') | chrome/browser/sync/engine/syncer_end_command.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/engine/syncer.h" 5 #include "chrome/browser/sync/engine/syncer.h"
6 6
7 #include "base/message_loop.h" 7 #include "base/message_loop.h"
8 #include "base/time.h" 8 #include "base/time.h"
9 #include "base/tracked.h" 9 #include "base/tracked.h"
10 #include "chrome/browser/sync/engine/apply_updates_command.h" 10 #include "chrome/browser/sync/engine/apply_updates_command.h"
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 using syncable::ScopedDirLookup; 47 using syncable::ScopedDirLookup;
48 using syncable::WriteTransaction; 48 using syncable::WriteTransaction;
49 49
50 namespace browser_sync { 50 namespace browser_sync {
51 51
52 using sessions::ScopedSessionContextConflictResolver; 52 using sessions::ScopedSessionContextConflictResolver;
53 using sessions::StatusController; 53 using sessions::StatusController;
54 using sessions::SyncSession; 54 using sessions::SyncSession;
55 using sessions::ConflictProgress; 55 using sessions::ConflictProgress;
56 56
57 Syncer::ScopedSyncStartStopTracker::ScopedSyncStartStopTracker(
58 sessions::SyncSession* session) : session_(session) {
59 session_->status_controller()->SetSyncInProgressAndUpdateStartTime(true);
60 }
61
62 Syncer::ScopedSyncStartStopTracker::~ScopedSyncStartStopTracker() {
63 session_->status_controller()->SetSyncInProgressAndUpdateStartTime(false);
64 }
65
57 Syncer::Syncer() 66 Syncer::Syncer()
58 : early_exit_requested_(false), 67 : early_exit_requested_(false),
59 pre_conflict_resolution_closure_(NULL) { 68 pre_conflict_resolution_closure_(NULL) {
60 } 69 }
61 70
62 Syncer::~Syncer() {} 71 Syncer::~Syncer() {}
63 72
64 bool Syncer::ExitRequested() { 73 bool Syncer::ExitRequested() {
65 base::AutoLock lock(early_exit_requested_lock_); 74 base::AutoLock lock(early_exit_requested_lock_);
66 return early_exit_requested_; 75 return early_exit_requested_;
67 } 76 }
68 77
69 void Syncer::RequestEarlyExit() { 78 void Syncer::RequestEarlyExit() {
70 base::AutoLock lock(early_exit_requested_lock_); 79 base::AutoLock lock(early_exit_requested_lock_);
71 early_exit_requested_ = true; 80 early_exit_requested_ = true;
72 } 81 }
73 82
74 void Syncer::SyncShare(sessions::SyncSession* session, 83 void Syncer::SyncShare(sessions::SyncSession* session,
75 SyncerStep first_step, 84 SyncerStep first_step,
76 SyncerStep last_step) { 85 SyncerStep last_step) {
77 { 86 {
78 ScopedDirLookup dir(session->context()->directory_manager(), 87 ScopedDirLookup dir(session->context()->directory_manager(),
79 session->context()->account_name()); 88 session->context()->account_name());
80 // The directory must be good here. 89 // The directory must be good here.
81 CHECK(dir.good()); 90 CHECK(dir.good());
82 } 91 }
83 92
84 ScopedSessionContextConflictResolver scoped(session->context(), 93 ScopedSessionContextConflictResolver scoped(session->context(),
85 &resolver_); 94 &resolver_);
95
96 ScopedSyncStartStopTracker start_stop_tracker(session);
86 SyncerStep current_step = first_step; 97 SyncerStep current_step = first_step;
87 98
88 SyncerStep next_step = current_step; 99 SyncerStep next_step = current_step;
89 while (!ExitRequested()) { 100 while (!ExitRequested()) {
90 switch (current_step) { 101 switch (current_step) {
91 case SYNCER_BEGIN: 102 case SYNCER_BEGIN:
92 VLOG(1) << "Syncer Begin"; 103 VLOG(1) << "Syncer Begin";
93 // This isn't perfect, as we can end up bundling extensions activity 104 // This isn't perfect, as we can end up bundling extensions activity
94 // intended for the next session into the current one. We could do a 105 // intended for the next session into the current one. We could do a
95 // test-and-reset as with the source, but note that also falls short if 106 // test-and-reset as with the source, but note that also falls short if
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 last_step = SYNCER_END; 172 last_step = SYNCER_END;
162 next_step = SYNCER_END; 173 next_step = SYNCER_END;
163 } else { 174 } else {
164 next_step = BUILD_COMMIT_REQUEST; 175 next_step = BUILD_COMMIT_REQUEST;
165 } 176 }
166 break; 177 break;
167 } 178 }
168 // These two steps are combined since they are executed within the same 179 // These two steps are combined since they are executed within the same
169 // write transaction. 180 // write transaction.
170 case BUILD_COMMIT_REQUEST: { 181 case BUILD_COMMIT_REQUEST: {
171 session->status_controller()->set_syncing(true);
172
173 VLOG(1) << "Processing Commit Request"; 182 VLOG(1) << "Processing Commit Request";
174 ScopedDirLookup dir(session->context()->directory_manager(), 183 ScopedDirLookup dir(session->context()->directory_manager(),
175 session->context()->account_name()); 184 session->context()->account_name());
176 if (!dir.good()) { 185 if (!dir.good()) {
177 LOG(ERROR) << "Scoped dir lookup failed!"; 186 LOG(ERROR) << "Scoped dir lookup failed!";
178 return; 187 return;
179 } 188 }
180 WriteTransaction trans(FROM_HERE, SYNCER, dir); 189 WriteTransaction trans(FROM_HERE, SYNCER, dir);
181 sessions::ScopedSetSessionWriteTransaction set_trans(session, &trans); 190 sessions::ScopedSetSessionWriteTransaction set_trans(session, &trans);
182 191
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 entry->Put(SERVER_CTIME, 0); 343 entry->Put(SERVER_CTIME, 0);
335 entry->Put(SERVER_VERSION, 0); 344 entry->Put(SERVER_VERSION, 0);
336 entry->Put(SERVER_IS_DIR, false); 345 entry->Put(SERVER_IS_DIR, false);
337 entry->Put(SERVER_IS_DEL, false); 346 entry->Put(SERVER_IS_DEL, false);
338 entry->Put(IS_UNAPPLIED_UPDATE, false); 347 entry->Put(IS_UNAPPLIED_UPDATE, false);
339 entry->Put(SERVER_SPECIFICS, sync_pb::EntitySpecifics::default_instance()); 348 entry->Put(SERVER_SPECIFICS, sync_pb::EntitySpecifics::default_instance());
340 entry->Put(SERVER_POSITION_IN_PARENT, 0); 349 entry->Put(SERVER_POSITION_IN_PARENT, 0);
341 } 350 }
342 351
343 } // namespace browser_sync 352 } // namespace browser_sync
OLDNEW
« no previous file with comments | « chrome/browser/sync/engine/syncer.h ('k') | chrome/browser/sync/engine/syncer_end_command.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698