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

Side by Side Diff: chrome/browser/sync/glue/data_type_manager_impl.cc

Issue 10662035: [Sync] Put everything in sync/api into csync namespace (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix comments Created 8 years, 5 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) 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 "chrome/browser/sync/glue/data_type_manager_impl.h" 5 #include "chrome/browser/sync/glue/data_type_manager_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <functional> 8 #include <functional>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 model_association_manager_.ResetForReconfiguration(); 190 model_association_manager_.ResetForReconfiguration();
191 ProcessReconfigure(); 191 ProcessReconfigure();
192 return; 192 return;
193 } 193 }
194 194
195 if (!failed_configuration_types.Empty()) { 195 if (!failed_configuration_types.Empty()) {
196 ChromeReportUnrecoverableError(); 196 ChromeReportUnrecoverableError();
197 std::string error_msg = 197 std::string error_msg =
198 "Configuration failed for types " + 198 "Configuration failed for types " +
199 syncable::ModelTypeSetToString(failed_configuration_types); 199 syncable::ModelTypeSetToString(failed_configuration_types);
200 SyncError error(FROM_HERE, error_msg, 200 csync::SyncError error(FROM_HERE, error_msg,
201 failed_configuration_types.First().Get()); 201 failed_configuration_types.First().Get());
202 Abort(UNRECOVERABLE_ERROR, error); 202 Abort(UNRECOVERABLE_ERROR, error);
203 return; 203 return;
204 } 204 }
205 205
206 state_ = CONFIGURING; 206 state_ = CONFIGURING;
207 model_association_manager_.StartAssociationAsync(); 207 model_association_manager_.StartAssociationAsync();
208 } 208 }
209 209
210 void DataTypeManagerImpl::OnModelAssociationDone( 210 void DataTypeManagerImpl::OnModelAssociationDone(
211 const DataTypeManager::ConfigureResult& result) { 211 const DataTypeManager::ConfigureResult& result) {
212 if (result.status == ABORTED || result.status == UNRECOVERABLE_ERROR) { 212 if (result.status == ABORTED || result.status == UNRECOVERABLE_ERROR) {
213 Abort(result.status, result.failed_data_types.size() >= 1 ? 213 Abort(result.status, result.failed_data_types.size() >= 1 ?
214 result.failed_data_types.front() : 214 result.failed_data_types.front() :
215 SyncError()); 215 csync::SyncError());
216 return; 216 return;
217 } 217 }
218 218
219 if (ProcessReconfigure()) { 219 if (ProcessReconfigure()) {
220 return; 220 return;
221 } 221 }
222 222
223 if (result.status == CONFIGURE_BLOCKED) { 223 if (result.status == CONFIGURE_BLOCKED) {
224 failed_datatypes_info_.insert(failed_datatypes_info_.end(), 224 failed_datatypes_info_.insert(failed_datatypes_info_.end(),
225 result.failed_data_types.begin(), 225 result.failed_data_types.begin(),
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 267
268 return; 268 return;
269 } 269 }
270 270
271 const bool download_pending = state_ == DOWNLOAD_PENDING; 271 const bool download_pending = state_ == DOWNLOAD_PENDING;
272 state_ = STOPPING; 272 state_ = STOPPING;
273 if (download_pending) { 273 if (download_pending) {
274 // If Stop() is called while waiting for download, cancel all 274 // If Stop() is called while waiting for download, cancel all
275 // outstanding tasks. 275 // outstanding tasks.
276 weak_ptr_factory_.InvalidateWeakPtrs(); 276 weak_ptr_factory_.InvalidateWeakPtrs();
277 Abort(ABORTED, SyncError()); 277 Abort(ABORTED, csync::SyncError());
278 return; 278 return;
279 } 279 }
280 280
281 FinishStop(); 281 FinishStop();
282 } 282 }
283 283
284 void DataTypeManagerImpl::FinishStop() { 284 void DataTypeManagerImpl::FinishStop() {
285 DCHECK(state_== CONFIGURING || state_ == STOPPING || state_ == BLOCKED || 285 DCHECK(state_== CONFIGURING || state_ == STOPPING || state_ == BLOCKED ||
286 state_ == DOWNLOAD_PENDING); 286 state_ == DOWNLOAD_PENDING);
287 model_association_manager_.Stop(); 287 model_association_manager_.Stop();
288 288
289 failed_datatypes_info_.clear(); 289 failed_datatypes_info_.clear();
290 state_ = STOPPED; 290 state_ = STOPPED;
291 } 291 }
292 292
293 void DataTypeManagerImpl::Abort(ConfigureStatus status, 293 void DataTypeManagerImpl::Abort(ConfigureStatus status,
294 const SyncError& error) { 294 const csync::SyncError& error) {
295 DCHECK_NE(OK, status); 295 DCHECK_NE(OK, status);
296 FinishStop(); 296 FinishStop();
297 std::list<SyncError> error_list; 297 std::list<csync::SyncError> error_list;
298 if (error.IsSet()) 298 if (error.IsSet())
299 error_list.push_back(error); 299 error_list.push_back(error);
300 ConfigureResult result(status, 300 ConfigureResult result(status,
301 last_requested_types_, 301 last_requested_types_,
302 error_list, 302 error_list,
303 syncable::ModelTypeSet()); 303 syncable::ModelTypeSet());
304 NotifyDone(result); 304 NotifyDone(result);
305 } 305 }
306 306
307 void DataTypeManagerImpl::NotifyStart() { 307 void DataTypeManagerImpl::NotifyStart() {
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
361 content::Source<DataTypeManager>(this), 361 content::Source<DataTypeManager>(this),
362 content::NotificationService::NoDetails()); 362 content::NotificationService::NoDetails());
363 } 363 }
364 364
365 void DataTypeManagerImpl::AddToConfigureTime() { 365 void DataTypeManagerImpl::AddToConfigureTime() {
366 DCHECK(!last_restart_time_.is_null()); 366 DCHECK(!last_restart_time_.is_null());
367 configure_time_delta_ += (base::Time::Now() - last_restart_time_); 367 configure_time_delta_ += (base::Time::Now() - last_restart_time_);
368 } 368 }
369 369
370 } // namespace browser_sync 370 } // namespace browser_sync
OLDNEW
« no previous file with comments | « chrome/browser/sync/glue/data_type_manager_impl.h ('k') | chrome/browser/sync/glue/data_type_manager_mock.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698