| OLD | NEW |
| 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 "build/build_config.h" | 5 #include "build/build_config.h" |
| 6 | 6 |
| 7 #include "chrome/browser/sync/glue/sync_backend_host.h" | 7 #include "chrome/browser/sync/glue/sync_backend_host.h" |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <map> | 10 #include <map> |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 bool encrypt_everything) OVERRIDE; | 118 bool encrypt_everything) OVERRIDE; |
| 119 virtual void OnEncryptionComplete() OVERRIDE; | 119 virtual void OnEncryptionComplete() OVERRIDE; |
| 120 virtual void OnCryptographerStateChanged( | 120 virtual void OnCryptographerStateChanged( |
| 121 syncer::Cryptographer* cryptographer) OVERRIDE; | 121 syncer::Cryptographer* cryptographer) OVERRIDE; |
| 122 virtual void OnPassphraseTypeChanged(syncer::PassphraseType type) OVERRIDE; | 122 virtual void OnPassphraseTypeChanged(syncer::PassphraseType type) OVERRIDE; |
| 123 | 123 |
| 124 // syncer::InvalidationHandler implementation. | 124 // syncer::InvalidationHandler implementation. |
| 125 virtual void OnInvalidatorStateChange( | 125 virtual void OnInvalidatorStateChange( |
| 126 syncer::InvalidatorState state) OVERRIDE; | 126 syncer::InvalidatorState state) OVERRIDE; |
| 127 virtual void OnIncomingInvalidation( | 127 virtual void OnIncomingInvalidation( |
| 128 const syncer::ObjectIdStateMap& id_state_map, | 128 const syncer::ObjectIdInvalidationMap& invalidation_map, |
| 129 syncer::IncomingInvalidationSource source) OVERRIDE; | 129 syncer::IncomingInvalidationSource source) OVERRIDE; |
| 130 | 130 |
| 131 // Note: | 131 // Note: |
| 132 // | 132 // |
| 133 // The Do* methods are the various entry points from our | 133 // The Do* methods are the various entry points from our |
| 134 // SyncBackendHost. They are all called on the sync thread to | 134 // SyncBackendHost. They are all called on the sync thread to |
| 135 // actually perform synchronous (and potentially blocking) syncapi | 135 // actually perform synchronous (and potentially blocking) syncapi |
| 136 // operations. | 136 // operations. |
| 137 // | 137 // |
| 138 // Called to perform initialization of the syncapi on behalf of | 138 // Called to perform initialization of the syncapi on behalf of |
| (...skipping 906 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1045 syncer::InvalidatorState state) { | 1045 syncer::InvalidatorState state) { |
| 1046 if (!sync_loop_) | 1046 if (!sync_loop_) |
| 1047 return; | 1047 return; |
| 1048 DCHECK_EQ(MessageLoop::current(), sync_loop_); | 1048 DCHECK_EQ(MessageLoop::current(), sync_loop_); |
| 1049 host_.Call(FROM_HERE, | 1049 host_.Call(FROM_HERE, |
| 1050 &SyncBackendHost::HandleInvalidatorStateChangeOnFrontendLoop, | 1050 &SyncBackendHost::HandleInvalidatorStateChangeOnFrontendLoop, |
| 1051 state); | 1051 state); |
| 1052 } | 1052 } |
| 1053 | 1053 |
| 1054 void SyncBackendHost::Core::OnIncomingInvalidation( | 1054 void SyncBackendHost::Core::OnIncomingInvalidation( |
| 1055 const syncer::ObjectIdStateMap& id_state_map, | 1055 const syncer::ObjectIdInvalidationMap& invalidation_map, |
| 1056 syncer::IncomingInvalidationSource source) { | 1056 syncer::IncomingInvalidationSource source) { |
| 1057 if (!sync_loop_) | 1057 if (!sync_loop_) |
| 1058 return; | 1058 return; |
| 1059 DCHECK_EQ(MessageLoop::current(), sync_loop_); | 1059 DCHECK_EQ(MessageLoop::current(), sync_loop_); |
| 1060 host_.Call(FROM_HERE, | 1060 host_.Call(FROM_HERE, |
| 1061 &SyncBackendHost::HandleIncomingInvalidationOnFrontendLoop, | 1061 &SyncBackendHost::HandleIncomingInvalidationOnFrontendLoop, |
| 1062 id_state_map, source); | 1062 invalidation_map, source); |
| 1063 } | 1063 } |
| 1064 | 1064 |
| 1065 void SyncBackendHost::Core::DoInitialize(const DoInitializeOptions& options) { | 1065 void SyncBackendHost::Core::DoInitialize(const DoInitializeOptions& options) { |
| 1066 DCHECK(!sync_loop_); | 1066 DCHECK(!sync_loop_); |
| 1067 sync_loop_ = options.sync_loop; | 1067 sync_loop_ = options.sync_loop; |
| 1068 DCHECK(sync_loop_); | 1068 DCHECK(sync_loop_); |
| 1069 | 1069 |
| 1070 // Blow away the partial or corrupt sync data folder before doing any more | 1070 // Blow away the partial or corrupt sync data folder before doing any more |
| 1071 // initialization, if necessary. | 1071 // initialization, if necessary. |
| 1072 if (options.delete_sync_data_folder) { | 1072 if (options.delete_sync_data_folder) { |
| (...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1437 | 1437 |
| 1438 void SyncBackendHost::HandleInvalidatorStateChangeOnFrontendLoop( | 1438 void SyncBackendHost::HandleInvalidatorStateChangeOnFrontendLoop( |
| 1439 syncer::InvalidatorState state) { | 1439 syncer::InvalidatorState state) { |
| 1440 if (!frontend_) | 1440 if (!frontend_) |
| 1441 return; | 1441 return; |
| 1442 DCHECK_EQ(MessageLoop::current(), frontend_loop_); | 1442 DCHECK_EQ(MessageLoop::current(), frontend_loop_); |
| 1443 frontend_->OnInvalidatorStateChange(state); | 1443 frontend_->OnInvalidatorStateChange(state); |
| 1444 } | 1444 } |
| 1445 | 1445 |
| 1446 void SyncBackendHost::HandleIncomingInvalidationOnFrontendLoop( | 1446 void SyncBackendHost::HandleIncomingInvalidationOnFrontendLoop( |
| 1447 const syncer::ObjectIdStateMap& id_state_map, | 1447 const syncer::ObjectIdInvalidationMap& invalidation_map, |
| 1448 syncer::IncomingInvalidationSource source) { | 1448 syncer::IncomingInvalidationSource source) { |
| 1449 if (!frontend_) | 1449 if (!frontend_) |
| 1450 return; | 1450 return; |
| 1451 DCHECK_EQ(MessageLoop::current(), frontend_loop_); | 1451 DCHECK_EQ(MessageLoop::current(), frontend_loop_); |
| 1452 frontend_->OnIncomingInvalidation(id_state_map, source); | 1452 frontend_->OnIncomingInvalidation(invalidation_map, source); |
| 1453 } | 1453 } |
| 1454 | 1454 |
| 1455 bool SyncBackendHost::CheckPassphraseAgainstCachedPendingKeys( | 1455 bool SyncBackendHost::CheckPassphraseAgainstCachedPendingKeys( |
| 1456 const std::string& passphrase) const { | 1456 const std::string& passphrase) const { |
| 1457 DCHECK(cached_pending_keys_.has_blob()); | 1457 DCHECK(cached_pending_keys_.has_blob()); |
| 1458 DCHECK(!passphrase.empty()); | 1458 DCHECK(!passphrase.empty()); |
| 1459 syncer::Nigori nigori; | 1459 syncer::Nigori nigori; |
| 1460 nigori.InitByDerivation("localhost", "dummy", passphrase); | 1460 nigori.InitByDerivation("localhost", "dummy", passphrase); |
| 1461 std::string plaintext; | 1461 std::string plaintext; |
| 1462 bool result = nigori.Decrypt(cached_pending_keys_.blob(), &plaintext); | 1462 bool result = nigori.Decrypt(cached_pending_keys_.blob(), &plaintext); |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1545 const syncer::ModelTypeSet failed_configuration_types) { | 1545 const syncer::ModelTypeSet failed_configuration_types) { |
| 1546 HandleInitializationCompletedOnFrontendLoop( | 1546 HandleInitializationCompletedOnFrontendLoop( |
| 1547 failed_configuration_types.Empty()); | 1547 failed_configuration_types.Empty()); |
| 1548 } | 1548 } |
| 1549 | 1549 |
| 1550 #undef SDVLOG | 1550 #undef SDVLOG |
| 1551 | 1551 |
| 1552 #undef SLOG | 1552 #undef SLOG |
| 1553 | 1553 |
| 1554 } // namespace browser_sync | 1554 } // namespace browser_sync |
| OLD | NEW |