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

Side by Side Diff: sync/engine/sync_scheduler.cc

Issue 10197004: [Sync] Convert SyncSessionSnapshot to a copy-able class. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments. Created 8 years, 8 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 | « sync/engine/sync_engine_event.cc ('k') | sync/engine/sync_scheduler_unittest.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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "sync/engine/sync_scheduler.h" 5 #include "sync/engine/sync_scheduler.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cstring> 8 #include <cstring>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 base::Bind(&SyncScheduler::StartImpl, 263 base::Bind(&SyncScheduler::StartImpl,
264 weak_ptr_factory_.GetWeakPtr(), mode, callback)); 264 weak_ptr_factory_.GetWeakPtr(), mode, callback));
265 } 265 }
266 266
267 void SyncScheduler::SendInitialSnapshot() { 267 void SyncScheduler::SendInitialSnapshot() {
268 DCHECK_EQ(MessageLoop::current(), sync_loop_); 268 DCHECK_EQ(MessageLoop::current(), sync_loop_);
269 scoped_ptr<SyncSession> dummy(new SyncSession(session_context_.get(), this, 269 scoped_ptr<SyncSession> dummy(new SyncSession(session_context_.get(), this,
270 SyncSourceInfo(), ModelSafeRoutingInfo(), 270 SyncSourceInfo(), ModelSafeRoutingInfo(),
271 std::vector<ModelSafeWorker*>())); 271 std::vector<ModelSafeWorker*>()));
272 SyncEngineEvent event(SyncEngineEvent::STATUS_CHANGED); 272 SyncEngineEvent event(SyncEngineEvent::STATUS_CHANGED);
273 sessions::SyncSessionSnapshot snapshot(dummy->TakeSnapshot()); 273 event.snapshot = dummy->TakeSnapshot();
274 event.snapshot = &snapshot;
275 session_context_->NotifyListeners(event); 274 session_context_->NotifyListeners(event);
276 } 275 }
277 276
278 void SyncScheduler::StartImpl(Mode mode, const base::Closure& callback) { 277 void SyncScheduler::StartImpl(Mode mode, const base::Closure& callback) {
279 DCHECK_EQ(MessageLoop::current(), sync_loop_); 278 DCHECK_EQ(MessageLoop::current(), sync_loop_);
280 SDVLOG(2) << "In StartImpl with mode " << GetModeString(mode); 279 SDVLOG(2) << "In StartImpl with mode " << GetModeString(mode);
281 280
282 DCHECK_EQ(MessageLoop::current(), sync_loop_); 281 DCHECK_EQ(MessageLoop::current(), sync_loop_);
283 DCHECK(!session_context_->account_name().empty()); 282 DCHECK(!session_context_->account_name().empty());
284 DCHECK(syncer_.get()); 283 DCHECK(syncer_.get());
(...skipping 876 matching lines...) Expand 10 before | Expand all | Expand 10 after
1161 SDVLOG(2) << "OnShouldStopSyncingPermanently"; 1160 SDVLOG(2) << "OnShouldStopSyncingPermanently";
1162 syncer_->RequestEarlyExit(); // Thread-safe. 1161 syncer_->RequestEarlyExit(); // Thread-safe.
1163 Notify(SyncEngineEvent::STOP_SYNCING_PERMANENTLY); 1162 Notify(SyncEngineEvent::STOP_SYNCING_PERMANENTLY);
1164 } 1163 }
1165 1164
1166 void SyncScheduler::OnActionableError( 1165 void SyncScheduler::OnActionableError(
1167 const sessions::SyncSessionSnapshot& snap) { 1166 const sessions::SyncSessionSnapshot& snap) {
1168 DCHECK_EQ(MessageLoop::current(), sync_loop_); 1167 DCHECK_EQ(MessageLoop::current(), sync_loop_);
1169 SDVLOG(2) << "OnActionableError"; 1168 SDVLOG(2) << "OnActionableError";
1170 SyncEngineEvent event(SyncEngineEvent::ACTIONABLE_ERROR); 1169 SyncEngineEvent event(SyncEngineEvent::ACTIONABLE_ERROR);
1171 sessions::SyncSessionSnapshot snapshot(snap); 1170 event.snapshot = snap;
1172 event.snapshot = &snapshot;
1173 session_context_->NotifyListeners(event); 1171 session_context_->NotifyListeners(event);
1174 } 1172 }
1175 1173
1176 void SyncScheduler::OnSyncProtocolError( 1174 void SyncScheduler::OnSyncProtocolError(
1177 const sessions::SyncSessionSnapshot& snapshot) { 1175 const sessions::SyncSessionSnapshot& snapshot) {
1178 DCHECK_EQ(MessageLoop::current(), sync_loop_); 1176 DCHECK_EQ(MessageLoop::current(), sync_loop_);
1179 if (ShouldRequestEarlyExit(snapshot.errors.sync_protocol_error)) { 1177 if (ShouldRequestEarlyExit(snapshot.errors().sync_protocol_error)) {
1180 SDVLOG(2) << "Sync Scheduler requesting early exit."; 1178 SDVLOG(2) << "Sync Scheduler requesting early exit.";
1181 syncer_->RequestEarlyExit(); // Thread-safe. 1179 syncer_->RequestEarlyExit(); // Thread-safe.
1182 } 1180 }
1183 if (IsActionableError(snapshot.errors.sync_protocol_error)) 1181 if (IsActionableError(snapshot.errors().sync_protocol_error))
1184 OnActionableError(snapshot); 1182 OnActionableError(snapshot);
1185 } 1183 }
1186 1184
1187 void SyncScheduler::set_notifications_enabled(bool notifications_enabled) { 1185 void SyncScheduler::set_notifications_enabled(bool notifications_enabled) {
1188 DCHECK_EQ(MessageLoop::current(), sync_loop_); 1186 DCHECK_EQ(MessageLoop::current(), sync_loop_);
1189 session_context_->set_notifications_enabled(notifications_enabled); 1187 session_context_->set_notifications_enabled(notifications_enabled);
1190 } 1188 }
1191 1189
1192 base::TimeDelta SyncScheduler::sessions_commit_delay() const { 1190 base::TimeDelta SyncScheduler::sessions_commit_delay() const {
1193 DCHECK_EQ(MessageLoop::current(), sync_loop_); 1191 DCHECK_EQ(MessageLoop::current(), sync_loop_);
1194 return sessions_commit_delay_; 1192 return sessions_commit_delay_;
1195 } 1193 }
1196 1194
1197 #undef SDVLOG_LOC 1195 #undef SDVLOG_LOC
1198 1196
1199 #undef SDVLOG 1197 #undef SDVLOG
1200 1198
1201 #undef SLOG 1199 #undef SLOG
1202 1200
1203 #undef ENUM_CASE 1201 #undef ENUM_CASE
1204 1202
1205 } // browser_sync 1203 } // browser_sync
OLDNEW
« no previous file with comments | « sync/engine/sync_engine_event.cc ('k') | sync/engine/sync_scheduler_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698