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 867 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
878 // syncing until at least the DirectoryManager broadcasts the OPENED | 878 // syncing until at least the DirectoryManager broadcasts the OPENED |
879 // event, and a valid server connection is detected. | 879 // event, and a valid server connection is detected. |
880 if (scheduler()) // NULL during certain unittests. | 880 if (scheduler()) // NULL during certain unittests. |
881 scheduler()->Start(SyncScheduler::NORMAL_MODE, base::Closure()); | 881 scheduler()->Start(SyncScheduler::NORMAL_MODE, base::Closure()); |
882 } | 882 } |
883 | 883 |
884 bool SyncManager::SyncInternal::OpenDirectory() { | 884 bool SyncManager::SyncInternal::OpenDirectory() { |
885 DCHECK(!initialized_) << "Should only happen once"; | 885 DCHECK(!initialized_) << "Should only happen once"; |
886 | 886 |
887 bool share_opened = dir_manager()->Open(username_for_share(), this); | 887 bool share_opened = dir_manager()->Open(username_for_share(), this); |
888 DCHECK(share_opened); | |
889 if (!share_opened) { | 888 if (!share_opened) { |
890 LOG(ERROR) << "Could not open share for:" << username_for_share(); | 889 LOG(ERROR) << "Could not open share for:" << username_for_share(); |
891 return false; | 890 return false; |
892 } | 891 } |
893 | 892 |
894 // Database has to be initialized for the guid to be available. | 893 // Database has to be initialized for the guid to be available. |
895 syncable::ScopedDirLookup lookup(dir_manager(), username_for_share()); | 894 syncable::ScopedDirLookup lookup(dir_manager(), username_for_share()); |
896 if (!lookup.good()) { | 895 if (!lookup.good()) { |
897 NOTREACHED(); | 896 NOTREACHED(); |
898 return false; | 897 return false; |
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1275 sync_notifier_.reset(); | 1274 sync_notifier_.reset(); |
1276 | 1275 |
1277 if (connection_manager_.get()) { | 1276 if (connection_manager_.get()) { |
1278 connection_manager_->RemoveListener(this); | 1277 connection_manager_->RemoveListener(this); |
1279 } | 1278 } |
1280 connection_manager_.reset(); | 1279 connection_manager_.reset(); |
1281 | 1280 |
1282 net::NetworkChangeNotifier::RemoveIPAddressObserver(this); | 1281 net::NetworkChangeNotifier::RemoveIPAddressObserver(this); |
1283 observing_ip_address_changes_ = false; | 1282 observing_ip_address_changes_ = false; |
1284 | 1283 |
1285 if (dir_manager()) { | 1284 if (initialized_ && dir_manager()) { |
1286 { | 1285 { |
1287 // Cryptographer should only be accessed while holding a | 1286 // Cryptographer should only be accessed while holding a |
1288 // transaction. | 1287 // transaction. |
1289 ReadTransaction trans(FROM_HERE, GetUserShare()); | 1288 ReadTransaction trans(FROM_HERE, GetUserShare()); |
1290 trans.GetCryptographer()->RemoveObserver(this); | 1289 trans.GetCryptographer()->RemoveObserver(this); |
1291 trans.GetLookup()-> | 1290 trans.GetLookup()-> |
1292 RemoveTransactionObserver(&js_mutation_event_observer_); | 1291 RemoveTransactionObserver(&js_mutation_event_observer_); |
1293 RemoveChangeObserver(&js_mutation_event_observer_); | 1292 RemoveChangeObserver(&js_mutation_event_observer_); |
1294 } | 1293 } |
1295 dir_manager()->FinalSaveChangesForAll(); | 1294 dir_manager()->FinalSaveChangesForAll(); |
Nicolas Zea
2011/11/08 22:12:18
Perhaps just condition these two statements? We sh
rlarocque
2011/11/11 22:24:56
The transaction won't work. The Directory ends up
| |
1296 dir_manager()->Close(username_for_share()); | 1295 dir_manager()->Close(username_for_share()); |
1297 } | 1296 } |
1298 | 1297 |
1299 // Reset the DirectoryManager and UserSettings so they relinquish sqlite | 1298 // Reset the DirectoryManager and UserSettings so they relinquish sqlite |
1300 // handles to backing files. | 1299 // handles to backing files. |
1301 share_.dir_manager.reset(); | 1300 share_.dir_manager.reset(); |
1302 | 1301 |
1303 setup_for_test_mode_ = false; | 1302 setup_for_test_mode_ = false; |
1304 change_delegate_ = NULL; | 1303 change_delegate_ = NULL; |
1305 registrar_ = NULL; | 1304 registrar_ = NULL; |
(...skipping 770 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2076 | 2075 |
2077 for (syncable::ModelTypeSet::const_iterator i = types.begin(); | 2076 for (syncable::ModelTypeSet::const_iterator i = types.begin(); |
2078 i != types.end(); ++i) { | 2077 i != types.end(); ++i) { |
2079 if (!lookup->initial_sync_ended_for_type(*i)) | 2078 if (!lookup->initial_sync_ended_for_type(*i)) |
2080 return false; | 2079 return false; |
2081 } | 2080 } |
2082 return true; | 2081 return true; |
2083 } | 2082 } |
2084 | 2083 |
2085 } // namespace sync_api | 2084 } // namespace sync_api |
OLD | NEW |