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

Side by Side Diff: sync/internal_api/sync_manager_impl.cc

Issue 10830100: Fix SyncManager initialization failure crash. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add virtual destructor Created 8 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
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/internal_api/sync_manager_impl.h" 5 #include "sync/internal_api/sync_manager_impl.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/base64.h" 9 #include "base/base64.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after
419 credentials.email, absolute_db_path).Pass(); 419 credentials.email, absolute_db_path).Pass();
420 420
421 DCHECK(backing_store.get()); 421 DCHECK(backing_store.get());
422 share_.name = credentials.email; 422 share_.name = credentials.email;
423 share_.directory.reset( 423 share_.directory.reset(
424 new syncable::Directory(encryptor_, 424 new syncable::Directory(encryptor_,
425 unrecoverable_error_handler_, 425 unrecoverable_error_handler_,
426 report_unrecoverable_error_function_, 426 report_unrecoverable_error_function_,
427 backing_store.release())); 427 backing_store.release()));
428 428
429 connection_manager_.reset(new SyncAPIServerConnectionManager(
430 sync_server_and_path, port, use_ssl, post_factory.release()));
431 connection_manager_->AddListener(this);
432
433 DVLOG(1) << "Username: " << username_for_share(); 429 DVLOG(1) << "Username: " << username_for_share();
434 if (!OpenDirectory()) { 430 if (!OpenDirectory()) {
435 FOR_EACH_OBSERVER(SyncManager::Observer, observers_, 431 FOR_EACH_OBSERVER(SyncManager::Observer, observers_,
436 OnInitializationComplete( 432 OnInitializationComplete(
437 MakeWeakHandle(weak_ptr_factory_.GetWeakPtr()), 433 MakeWeakHandle(weak_ptr_factory_.GetWeakPtr()),
438 false, syncer::ModelTypeSet())); 434 false, syncer::ModelTypeSet()));
439 return false; 435 return false;
440 } 436 }
441 437
438 connection_manager_.reset(new SyncAPIServerConnectionManager(
439 sync_server_and_path, port, use_ssl, post_factory.release()));
440 connection_manager_->set_client_id(directory()->cache_guid());
441 connection_manager_->AddListener(this);
442
442 // Retrieve and set the sync notifier state. 443 // Retrieve and set the sync notifier state.
443 std::string unique_id = directory()->cache_guid(); 444 std::string unique_id = directory()->cache_guid();
444 DVLOG(1) << "Read notification unique ID: " << unique_id; 445 DVLOG(1) << "Read notification unique ID: " << unique_id;
445 allstatus_.SetUniqueId(unique_id); 446 allstatus_.SetUniqueId(unique_id);
446 sync_notifier_->SetUniqueId(unique_id); 447 sync_notifier_->SetUniqueId(unique_id);
447 448
448 std::string state = directory()->GetNotificationState(); 449 std::string state = directory()->GetNotificationState();
449 if (VLOG_IS_ON(1)) { 450 if (VLOG_IS_ON(1)) {
450 std::string encoded_state; 451 std::string encoded_state;
451 base::Base64Encode(state, &encoded_state); 452 base::Base64Encode(state, &encoded_state);
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
678 // does not support a migration while it's already in the middle of a 679 // does not support a migration while it's already in the middle of a
679 // configuration. As a result, any partially synced datatype can stall the 680 // configuration. As a result, any partially synced datatype can stall the
680 // DTM, waiting for the configuration to complete, which it never will due 681 // DTM, waiting for the configuration to complete, which it never will due
681 // to the migration error. In addition, a partially synced nigori will 682 // to the migration error. In addition, a partially synced nigori will
682 // trigger the migration logic before the backend is initialized, resulting 683 // trigger the migration logic before the backend is initialized, resulting
683 // in crashes. We therefore detect and purge any partially synced types as 684 // in crashes. We therefore detect and purge any partially synced types as
684 // part of initialization. 685 // part of initialization.
685 if (!PurgePartiallySyncedTypes()) 686 if (!PurgePartiallySyncedTypes())
686 return false; 687 return false;
687 688
688 connection_manager_->set_client_id(directory()->cache_guid());
689 return true; 689 return true;
690 } 690 }
691 691
692 bool SyncManagerImpl::PurgePartiallySyncedTypes() { 692 bool SyncManagerImpl::PurgePartiallySyncedTypes() {
693 ModelTypeSet partially_synced_types = ModelTypeSet::All(); 693 ModelTypeSet partially_synced_types = ModelTypeSet::All();
694 partially_synced_types.RemoveAll(InitialSyncEndedTypes()); 694 partially_synced_types.RemoveAll(InitialSyncEndedTypes());
695 partially_synced_types.RemoveAll(GetTypesWithEmptyProgressMarkerToken( 695 partially_synced_types.RemoveAll(GetTypesWithEmptyProgressMarkerToken(
696 ModelTypeSet::All())); 696 ModelTypeSet::All()));
697 697
698 UMA_HISTOGRAM_COUNTS("Sync.PartiallySyncedTypes", 698 UMA_HISTOGRAM_COUNTS("Sync.PartiallySyncedTypes",
(...skipping 1174 matching lines...) Expand 10 before | Expand all | Expand 10 after
1873 int SyncManagerImpl::GetDefaultNudgeDelay() { 1873 int SyncManagerImpl::GetDefaultNudgeDelay() {
1874 return kDefaultNudgeDelayMilliseconds; 1874 return kDefaultNudgeDelayMilliseconds;
1875 } 1875 }
1876 1876
1877 // static. 1877 // static.
1878 int SyncManagerImpl::GetPreferencesNudgeDelay() { 1878 int SyncManagerImpl::GetPreferencesNudgeDelay() {
1879 return kPreferencesNudgeDelayMilliseconds; 1879 return kPreferencesNudgeDelayMilliseconds;
1880 } 1880 }
1881 1881
1882 } // namespace syncer 1882 } // namespace syncer
OLDNEW
« no previous file with comments | « sync/internal_api/public/test/test_internal_components_factory.h ('k') | sync/internal_api/syncapi_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698