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

Side by Side Diff: chrome/browser/sync/internal_api/sync_manager.cc

Issue 8496002: Sync: Improve handling of database load failures (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix memory access bugs Created 9 years, 1 month 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/internal_api/sync_manager.h" 5 #include "chrome/browser/sync/internal_api/sync_manager.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/base64.h" 9 #include "base/base64.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 784 matching lines...) Expand 10 before | Expand all | Expand 10 after
795 model_safe_worker_registrar, 795 model_safe_worker_registrar,
796 listeners, 796 listeners,
797 &debug_info_event_listener_); 797 &debug_info_event_listener_);
798 context->set_account_name(credentials.email); 798 context->set_account_name(credentials.email);
799 // The SyncScheduler takes ownership of |context|. 799 // The SyncScheduler takes ownership of |context|.
800 scheduler_.reset(new SyncScheduler(name_, context, new Syncer())); 800 scheduler_.reset(new SyncScheduler(name_, context, new Syncer()));
801 } 801 }
802 802
803 bool signed_in = SignIn(credentials); 803 bool signed_in = SignIn(credentials);
804 804
805 if (signed_in || setup_for_test_mode_) { 805 if (signed_in) {
806 if (scheduler()) { 806 if (scheduler()) {
807 scheduler()->Start( 807 scheduler()->Start(
808 browser_sync::SyncScheduler::CONFIGURATION_MODE, base::Closure()); 808 browser_sync::SyncScheduler::CONFIGURATION_MODE, base::Closure());
809 } 809 }
810 810
811 initialized_ = true; 811 initialized_ = true;
812 812
813 // Cryptographer should only be accessed while holding a 813 // Cryptographer should only be accessed while holding a
814 // transaction. Grabbing the user share for the transaction 814 // transaction. Grabbing the user share for the transaction
815 // checks the initialization state, so this must come after 815 // checks the initialization state, so this must come after
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
887 // syncing until at least the DirectoryManager broadcasts the OPENED 887 // syncing until at least the DirectoryManager broadcasts the OPENED
888 // event, and a valid server connection is detected. 888 // event, and a valid server connection is detected.
889 if (scheduler()) // NULL during certain unittests. 889 if (scheduler()) // NULL during certain unittests.
890 scheduler()->Start(SyncScheduler::NORMAL_MODE, base::Closure()); 890 scheduler()->Start(SyncScheduler::NORMAL_MODE, base::Closure());
891 } 891 }
892 892
893 bool SyncManager::SyncInternal::OpenDirectory() { 893 bool SyncManager::SyncInternal::OpenDirectory() {
894 DCHECK(!initialized_) << "Should only happen once"; 894 DCHECK(!initialized_) << "Should only happen once";
895 895
896 bool share_opened = dir_manager()->Open(username_for_share(), this); 896 bool share_opened = dir_manager()->Open(username_for_share(), this);
897 DCHECK(share_opened);
898 if (!share_opened) { 897 if (!share_opened) {
899 LOG(ERROR) << "Could not open share for:" << username_for_share(); 898 LOG(ERROR) << "Could not open share for:" << username_for_share();
900 return false; 899 return false;
901 } 900 }
902 901
903 // Database has to be initialized for the guid to be available. 902 // Database has to be initialized for the guid to be available.
904 syncable::ScopedDirLookup lookup(dir_manager(), username_for_share()); 903 syncable::ScopedDirLookup lookup(dir_manager(), username_for_share());
905 if (!lookup.good()) { 904 if (!lookup.good()) {
906 NOTREACHED(); 905 NOTREACHED();
907 return false; 906 return false;
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after
1284 sync_notifier_.reset(); 1283 sync_notifier_.reset();
1285 1284
1286 if (connection_manager_.get()) { 1285 if (connection_manager_.get()) {
1287 connection_manager_->RemoveListener(this); 1286 connection_manager_->RemoveListener(this);
1288 } 1287 }
1289 connection_manager_.reset(); 1288 connection_manager_.reset();
1290 1289
1291 net::NetworkChangeNotifier::RemoveIPAddressObserver(this); 1290 net::NetworkChangeNotifier::RemoveIPAddressObserver(this);
1292 observing_ip_address_changes_ = false; 1291 observing_ip_address_changes_ = false;
1293 1292
1294 if (dir_manager()) { 1293 if (initialized_ && dir_manager()) {
1295 { 1294 {
1296 // Cryptographer should only be accessed while holding a 1295 // Cryptographer should only be accessed while holding a
1297 // transaction. 1296 // transaction.
1298 ReadTransaction trans(FROM_HERE, GetUserShare()); 1297 ReadTransaction trans(FROM_HERE, GetUserShare());
1299 trans.GetCryptographer()->RemoveObserver(this); 1298 trans.GetCryptographer()->RemoveObserver(this);
1300 trans.GetLookup()-> 1299 trans.GetLookup()->
1301 RemoveTransactionObserver(&js_mutation_event_observer_); 1300 RemoveTransactionObserver(&js_mutation_event_observer_);
1302 RemoveChangeObserver(&js_mutation_event_observer_); 1301 RemoveChangeObserver(&js_mutation_event_observer_);
1303 } 1302 }
1304 dir_manager()->FinalSaveChangesForAll(); 1303 dir_manager()->FinalSaveChangesForAll();
(...skipping 804 matching lines...) Expand 10 before | Expand all | Expand 10 after
2109 lookup->GetDownloadProgress(*i, &marker); 2108 lookup->GetDownloadProgress(*i, &marker);
2110 2109
2111 if (marker.token().empty()) 2110 if (marker.token().empty())
2112 result.insert(*i); 2111 result.insert(*i);
2113 2112
2114 } 2113 }
2115 return result; 2114 return result;
2116 } 2115 }
2117 2116
2118 } // namespace sync_api 2117 } // namespace sync_api
OLDNEW
« no previous file with comments | « chrome/browser/sync/glue/sync_backend_host.cc ('k') | chrome/browser/sync/profile_sync_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698