OLD | NEW |
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 Loading... |
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) { | 805 if (signed_in || setup_for_test_mode_) { |
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 Loading... |
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); |
897 if (!share_opened) { | 898 if (!share_opened) { |
898 LOG(ERROR) << "Could not open share for:" << username_for_share(); | 899 LOG(ERROR) << "Could not open share for:" << username_for_share(); |
899 return false; | 900 return false; |
900 } | 901 } |
901 | 902 |
902 // Database has to be initialized for the guid to be available. | 903 // Database has to be initialized for the guid to be available. |
903 syncable::ScopedDirLookup lookup(dir_manager(), username_for_share()); | 904 syncable::ScopedDirLookup lookup(dir_manager(), username_for_share()); |
904 if (!lookup.good()) { | 905 if (!lookup.good()) { |
905 NOTREACHED(); | 906 NOTREACHED(); |
906 return false; | 907 return false; |
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1283 sync_notifier_.reset(); | 1284 sync_notifier_.reset(); |
1284 | 1285 |
1285 if (connection_manager_.get()) { | 1286 if (connection_manager_.get()) { |
1286 connection_manager_->RemoveListener(this); | 1287 connection_manager_->RemoveListener(this); |
1287 } | 1288 } |
1288 connection_manager_.reset(); | 1289 connection_manager_.reset(); |
1289 | 1290 |
1290 net::NetworkChangeNotifier::RemoveIPAddressObserver(this); | 1291 net::NetworkChangeNotifier::RemoveIPAddressObserver(this); |
1291 observing_ip_address_changes_ = false; | 1292 observing_ip_address_changes_ = false; |
1292 | 1293 |
1293 if (initialized_ && dir_manager()) { | 1294 if (dir_manager()) { |
1294 { | 1295 { |
1295 // Cryptographer should only be accessed while holding a | 1296 // Cryptographer should only be accessed while holding a |
1296 // transaction. | 1297 // transaction. |
1297 ReadTransaction trans(FROM_HERE, GetUserShare()); | 1298 ReadTransaction trans(FROM_HERE, GetUserShare()); |
1298 trans.GetCryptographer()->RemoveObserver(this); | 1299 trans.GetCryptographer()->RemoveObserver(this); |
1299 trans.GetLookup()-> | 1300 trans.GetLookup()-> |
1300 RemoveTransactionObserver(&js_mutation_event_observer_); | 1301 RemoveTransactionObserver(&js_mutation_event_observer_); |
1301 RemoveChangeObserver(&js_mutation_event_observer_); | 1302 RemoveChangeObserver(&js_mutation_event_observer_); |
1302 } | 1303 } |
1303 dir_manager()->FinalSaveChangesForAll(); | 1304 dir_manager()->FinalSaveChangesForAll(); |
(...skipping 804 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2108 lookup->GetDownloadProgress(*i, &marker); | 2109 lookup->GetDownloadProgress(*i, &marker); |
2109 | 2110 |
2110 if (marker.token().empty()) | 2111 if (marker.token().empty()) |
2111 result.insert(*i); | 2112 result.insert(*i); |
2112 | 2113 |
2113 } | 2114 } |
2114 return result; | 2115 return result; |
2115 } | 2116 } |
2116 | 2117 |
2117 } // namespace sync_api | 2118 } // namespace sync_api |
OLD | NEW |