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

Side by Side Diff: chrome/browser/sync/sessions/sync_session.cc

Issue 8366030: Introduce the plumbing necessary to report Unrecoverable error from model safe workers. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: For a high level review. 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
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"
11 11
12
13 #include "chrome/browser/sync/sessions/unrecoverable_error_info.cc"
12 namespace browser_sync { 14 namespace browser_sync {
13 namespace sessions { 15 namespace sessions {
14 16
15 SyncSession::SyncSession(SyncSessionContext* context, Delegate* delegate, 17 SyncSession::SyncSession(SyncSessionContext* context, Delegate* delegate,
16 const SyncSourceInfo& source, 18 const SyncSourceInfo& source,
17 const ModelSafeRoutingInfo& routing_info, 19 const ModelSafeRoutingInfo& routing_info,
18 const std::vector<ModelSafeWorker*>& workers) 20 const std::vector<ModelSafeWorker*>& workers)
19 : context_(context), 21 : context_(context),
20 source_(source), 22 source_(source),
21 write_transaction_(NULL), 23 write_transaction_(NULL),
22 delegate_(delegate), 24 delegate_(delegate),
23 workers_(workers), 25 workers_(workers),
24 routing_info_(routing_info) { 26 routing_info_(routing_info),
27 unrecoverable_error_(false) {
25 status_controller_.reset(new StatusController(routing_info_)); 28 status_controller_.reset(new StatusController(routing_info_));
26 std::sort(workers_.begin(), workers_.end()); 29 std::sort(workers_.begin(), workers_.end());
27 } 30 }
28 31
29 SyncSession::~SyncSession() {} 32 SyncSession::~SyncSession() {}
30 33
31 void SyncSession::Coalesce(const SyncSession& session) { 34 void SyncSession::Coalesce(const SyncSession& session) {
32 if (context_ != session.context() || delegate_ != session.delegate_) { 35 if (context_ != session.context() || delegate_ != session.delegate_) {
33 NOTREACHED(); 36 NOTREACHED();
34 return; 37 return;
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 } 129 }
127 130
128 SyncSourceInfo SyncSession::TestAndSetSource() { 131 SyncSourceInfo SyncSession::TestAndSetSource() {
129 SyncSourceInfo old_source = source_; 132 SyncSourceInfo old_source = source_;
130 source_ = SyncSourceInfo( 133 source_ = SyncSourceInfo(
131 sync_pb::GetUpdatesCallerInfo::SYNC_CYCLE_CONTINUATION, 134 sync_pb::GetUpdatesCallerInfo::SYNC_CYCLE_CONTINUATION,
132 source_.types); 135 source_.types);
133 return old_source; 136 return old_source;
134 } 137 }
135 138
139 void SyncSession::SetUnrecoverableError(
140 const tracked_objects::Location& location,
141 const std::string& message,
142 syncable::BaseTransaction* trans) {
143 unrecoverable_error_ = true;
144 unrecoverable_error_info_.reset(new UnrecoverableErrorInfo(location,
145 message));
146 // If a transaction if provided then make sure it does not check tree
147 // invariants. We know it is corrupted.
148 trans->set_unrecoverable_error();
149 }
150
136 bool SyncSession::HasMoreToSync() const { 151 bool SyncSession::HasMoreToSync() const {
137 const StatusController* status = status_controller_.get(); 152 const StatusController* status = status_controller_.get();
138 return ((status->commit_ids().size() < status->unsynced_handles().size()) && 153 return ((status->commit_ids().size() < status->unsynced_handles().size()) &&
139 status->syncer_status().num_successful_commits > 0) || 154 status->syncer_status().num_successful_commits > 0) ||
140 status->conflict_sets_built() || 155 status->conflict_sets_built() ||
141 status->conflicts_resolved(); 156 status->conflicts_resolved();
142 // Or, we have conflicting updates, but we're making progress on 157 // Or, we have conflicting updates, but we're making progress on
143 // resolving them... 158 // resolving them...
144 } 159 }
145 160
146 } // namespace sessions 161 } // namespace sessions
147 } // namespace browser_sync 162 } // namespace browser_sync
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698