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

Side by Side Diff: chrome/browser/sync/profile_sync_service.cc

Issue 10520010: Not for review: Support sync init with missing or corrupt store (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Documentation Created 8 years, 6 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/profile_sync_service.h" 5 #include "chrome/browser/sync/profile_sync_service.h"
6 6
7 #include <cstddef> 7 #include <cstddef>
8 #include <map> 8 #include <map>
9 #include <set> 9 #include <set>
10 #include <utility> 10 #include <utility>
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 } 322 }
323 return credentials; 323 return credentials;
324 } 324 }
325 325
326 void ProfileSyncService::InitializeBackend(bool delete_stale_data) { 326 void ProfileSyncService::InitializeBackend(bool delete_stale_data) {
327 if (!backend_.get()) { 327 if (!backend_.get()) {
328 NOTREACHED(); 328 NOTREACHED();
329 return; 329 return;
330 } 330 }
331 331
332 syncable::ModelTypeSet initial_types;
333 // If sync setup hasn't finished, we don't want to initialize routing info
334 // for any data types so that we don't download updates for types that the
335 // user chooses not to sync on the first DownloadUpdatesCommand.
336 if (HasSyncSetupCompleted()) {
337 initial_types = GetPreferredDataTypes();
338 }
339
340 SyncCredentials credentials = GetCredentials(); 332 SyncCredentials credentials = GetCredentials();
341 333
342 scoped_refptr<net::URLRequestContextGetter> request_context_getter( 334 scoped_refptr<net::URLRequestContextGetter> request_context_getter(
343 profile_->GetRequestContext()); 335 profile_->GetRequestContext());
344 336
345 if (delete_stale_data) 337 if (delete_stale_data)
346 ClearStaleErrors(); 338 ClearStaleErrors();
347 339
348 backend_unrecoverable_error_handler_.reset( 340 backend_unrecoverable_error_handler_.reset(
349 new browser_sync::BackendUnrecoverableErrorHandler( 341 new browser_sync::BackendUnrecoverableErrorHandler(
350 MakeWeakHandle(AsWeakPtr()))); 342 MakeWeakHandle(AsWeakPtr())));
351 343
352 backend_->Initialize( 344 backend_->Initialize(
353 this, 345 this,
354 MakeWeakHandle(sync_js_controller_.AsWeakPtr()), 346 MakeWeakHandle(sync_js_controller_.AsWeakPtr()),
355 sync_service_url_, 347 sync_service_url_,
356 initial_types,
357 credentials, 348 credentials,
358 delete_stale_data, 349 delete_stale_data,
359 backend_unrecoverable_error_handler_.get(), 350 backend_unrecoverable_error_handler_.get(),
360 &browser_sync::ChromeReportUnrecoverableError); 351 &browser_sync::ChromeReportUnrecoverableError);
361 } 352 }
362 353
363 void ProfileSyncService::CreateBackend() { 354 void ProfileSyncService::CreateBackend() {
364 backend_.reset( 355 backend_.reset(
365 new SyncBackendHost(profile_->GetDebugName(), 356 new SyncBackendHost(profile_->GetDebugName(),
366 profile_, sync_prefs_.AsWeakPtr(), 357 profile_, sync_prefs_.AsWeakPtr(),
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
645 636
646 void ProfileSyncService::OnBackendInitialized( 637 void ProfileSyncService::OnBackendInitialized(
647 const WeakHandle<JsBackend>& js_backend, bool success) { 638 const WeakHandle<JsBackend>& js_backend, bool success) {
648 if (!HasSyncSetupCompleted()) { 639 if (!HasSyncSetupCompleted()) {
649 UMA_HISTOGRAM_BOOLEAN("Sync.BackendInitializeFirstTimeSuccess", success); 640 UMA_HISTOGRAM_BOOLEAN("Sync.BackendInitializeFirstTimeSuccess", success);
650 } else { 641 } else {
651 UMA_HISTOGRAM_BOOLEAN("Sync.BackendInitializeRestoreSuccess", success); 642 UMA_HISTOGRAM_BOOLEAN("Sync.BackendInitializeRestoreSuccess", success);
652 } 643 }
653 644
654 if (!success) { 645 if (!success) {
655 // Something went unexpectedly wrong. Play it safe: stop syncing at once 646 // Something went unexpectedly wrong. Stop syncing at once and surface
656 // and surface error UI to alert the user sync has stopped. 647 // error UI to alert the user sync has stopped.
657 // Keep the directory around for now so that on restart we will retry 648 OnUnrecoverableErrorImpl(FROM_HERE, "BackendInitialize failure", true);
658 // again and potentially succeed in presence of transient file IO failures
659 // or permissions issues, etc.
660 OnUnrecoverableErrorImpl(FROM_HERE, "BackendInitialize failure", false);
661 return; 649 return;
662 } 650 }
663 651
664 backend_initialized_ = true; 652 backend_initialized_ = true;
665 653
666 sync_js_controller_.AttachJsBackend(js_backend); 654 sync_js_controller_.AttachJsBackend(js_backend);
667 655
668 // If we have a cached passphrase use it to decrypt/encrypt data now that the 656 // If we have a cached passphrase use it to decrypt/encrypt data now that the
669 // backend is initialized. We want to call this before notifying observers in 657 // backend is initialized. We want to call this before notifying observers in
670 // case this operation affects the "passphrase required" status. 658 // case this operation affects the "passphrase required" status.
(...skipping 993 matching lines...) Expand 10 before | Expand all | Expand 10 after
1664 // See http://stackoverflow.com/questions/6224121/is-new-this-myclass-undefine d-behaviour-after-directly-calling-the-destru. 1652 // See http://stackoverflow.com/questions/6224121/is-new-this-myclass-undefine d-behaviour-after-directly-calling-the-destru.
1665 ProfileSyncService* old_this = this; 1653 ProfileSyncService* old_this = this;
1666 this->~ProfileSyncService(); 1654 this->~ProfileSyncService();
1667 new(old_this) ProfileSyncService( 1655 new(old_this) ProfileSyncService(
1668 new ProfileSyncComponentsFactoryImpl(profile, 1656 new ProfileSyncComponentsFactoryImpl(profile,
1669 CommandLine::ForCurrentProcess()), 1657 CommandLine::ForCurrentProcess()),
1670 profile, 1658 profile,
1671 signin, 1659 signin,
1672 behavior); 1660 behavior);
1673 } 1661 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698