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 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 virtual void OnEncryptionComplete() OVERRIDE; | 125 virtual void OnEncryptionComplete() OVERRIDE; |
126 virtual void OnCryptographerStateChanged( | 126 virtual void OnCryptographerStateChanged( |
127 syncer::Cryptographer* cryptographer) OVERRIDE; | 127 syncer::Cryptographer* cryptographer) OVERRIDE; |
128 virtual void OnPassphraseTypeChanged(syncer::PassphraseType type, | 128 virtual void OnPassphraseTypeChanged(syncer::PassphraseType type, |
129 base::Time passphrase_time) OVERRIDE; | 129 base::Time passphrase_time) OVERRIDE; |
130 | 130 |
131 // syncer::InvalidationHandler implementation. | 131 // syncer::InvalidationHandler implementation. |
132 virtual void OnInvalidatorStateChange( | 132 virtual void OnInvalidatorStateChange( |
133 syncer::InvalidatorState state) OVERRIDE; | 133 syncer::InvalidatorState state) OVERRIDE; |
134 virtual void OnIncomingInvalidation( | 134 virtual void OnIncomingInvalidation( |
135 const syncer::ObjectIdInvalidationMap& invalidation_map, | 135 const syncer::ObjectIdInvalidationMap& invalidation_map) OVERRIDE; |
136 syncer::IncomingInvalidationSource source) OVERRIDE; | |
137 | 136 |
138 // Note: | 137 // Note: |
139 // | 138 // |
140 // The Do* methods are the various entry points from our | 139 // The Do* methods are the various entry points from our |
141 // SyncBackendHost. They are all called on the sync thread to | 140 // SyncBackendHost. They are all called on the sync thread to |
142 // actually perform synchronous (and potentially blocking) syncapi | 141 // actually perform synchronous (and potentially blocking) syncapi |
143 // operations. | 142 // operations. |
144 // | 143 // |
145 // Called to perform initialization of the syncapi on behalf of | 144 // Called to perform initialization of the syncapi on behalf of |
146 // SyncBackendHost::Initialize. | 145 // SyncBackendHost::Initialize. |
(...skipping 979 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1126 syncer::InvalidatorState state) { | 1125 syncer::InvalidatorState state) { |
1127 if (!sync_loop_) | 1126 if (!sync_loop_) |
1128 return; | 1127 return; |
1129 DCHECK_EQ(MessageLoop::current(), sync_loop_); | 1128 DCHECK_EQ(MessageLoop::current(), sync_loop_); |
1130 host_.Call(FROM_HERE, | 1129 host_.Call(FROM_HERE, |
1131 &SyncBackendHost::HandleInvalidatorStateChangeOnFrontendLoop, | 1130 &SyncBackendHost::HandleInvalidatorStateChangeOnFrontendLoop, |
1132 state); | 1131 state); |
1133 } | 1132 } |
1134 | 1133 |
1135 void SyncBackendHost::Core::OnIncomingInvalidation( | 1134 void SyncBackendHost::Core::OnIncomingInvalidation( |
1136 const syncer::ObjectIdInvalidationMap& invalidation_map, | 1135 const syncer::ObjectIdInvalidationMap& invalidation_map) { |
1137 syncer::IncomingInvalidationSource source) { | |
1138 if (!sync_loop_) | 1136 if (!sync_loop_) |
1139 return; | 1137 return; |
1140 DCHECK_EQ(MessageLoop::current(), sync_loop_); | 1138 DCHECK_EQ(MessageLoop::current(), sync_loop_); |
1141 host_.Call(FROM_HERE, | 1139 host_.Call(FROM_HERE, |
1142 &SyncBackendHost::HandleIncomingInvalidationOnFrontendLoop, | 1140 &SyncBackendHost::HandleIncomingInvalidationOnFrontendLoop, |
1143 invalidation_map, source); | 1141 invalidation_map); |
1144 } | 1142 } |
1145 | 1143 |
1146 void SyncBackendHost::Core::DoInitialize(const DoInitializeOptions& options) { | 1144 void SyncBackendHost::Core::DoInitialize(const DoInitializeOptions& options) { |
1147 DCHECK(!sync_loop_); | 1145 DCHECK(!sync_loop_); |
1148 sync_loop_ = options.sync_loop; | 1146 sync_loop_ = options.sync_loop; |
1149 DCHECK(sync_loop_); | 1147 DCHECK(sync_loop_); |
1150 | 1148 |
1151 // Blow away the partial or corrupt sync data folder before doing any more | 1149 // Blow away the partial or corrupt sync data folder before doing any more |
1152 // initialization, if necessary. | 1150 // initialization, if necessary. |
1153 if (options.delete_sync_data_folder) { | 1151 if (options.delete_sync_data_folder) { |
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1527 | 1525 |
1528 void SyncBackendHost::HandleInvalidatorStateChangeOnFrontendLoop( | 1526 void SyncBackendHost::HandleInvalidatorStateChangeOnFrontendLoop( |
1529 syncer::InvalidatorState state) { | 1527 syncer::InvalidatorState state) { |
1530 if (!frontend_) | 1528 if (!frontend_) |
1531 return; | 1529 return; |
1532 DCHECK_EQ(MessageLoop::current(), frontend_loop_); | 1530 DCHECK_EQ(MessageLoop::current(), frontend_loop_); |
1533 frontend_->OnInvalidatorStateChange(state); | 1531 frontend_->OnInvalidatorStateChange(state); |
1534 } | 1532 } |
1535 | 1533 |
1536 void SyncBackendHost::HandleIncomingInvalidationOnFrontendLoop( | 1534 void SyncBackendHost::HandleIncomingInvalidationOnFrontendLoop( |
1537 const syncer::ObjectIdInvalidationMap& invalidation_map, | 1535 const syncer::ObjectIdInvalidationMap& invalidation_map) { |
1538 syncer::IncomingInvalidationSource source) { | |
1539 if (!frontend_) | 1536 if (!frontend_) |
1540 return; | 1537 return; |
1541 DCHECK_EQ(MessageLoop::current(), frontend_loop_); | 1538 DCHECK_EQ(MessageLoop::current(), frontend_loop_); |
1542 frontend_->OnIncomingInvalidation(invalidation_map, source); | 1539 frontend_->OnIncomingInvalidation(invalidation_map); |
1543 } | 1540 } |
1544 | 1541 |
1545 bool SyncBackendHost::CheckPassphraseAgainstCachedPendingKeys( | 1542 bool SyncBackendHost::CheckPassphraseAgainstCachedPendingKeys( |
1546 const std::string& passphrase) const { | 1543 const std::string& passphrase) const { |
1547 DCHECK(cached_pending_keys_.has_blob()); | 1544 DCHECK(cached_pending_keys_.has_blob()); |
1548 DCHECK(!passphrase.empty()); | 1545 DCHECK(!passphrase.empty()); |
1549 syncer::Nigori nigori; | 1546 syncer::Nigori nigori; |
1550 nigori.InitByDerivation("localhost", "dummy", passphrase); | 1547 nigori.InitByDerivation("localhost", "dummy", passphrase); |
1551 std::string plaintext; | 1548 std::string plaintext; |
1552 bool result = nigori.Decrypt(cached_pending_keys_.blob(), &plaintext); | 1549 bool result = nigori.Decrypt(cached_pending_keys_.blob(), &plaintext); |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1633 DVLOG(1) << "Connection status changed: " | 1630 DVLOG(1) << "Connection status changed: " |
1634 << syncer::ConnectionStatusToString(status); | 1631 << syncer::ConnectionStatusToString(status); |
1635 frontend_->OnConnectionStatusChange(status); | 1632 frontend_->OnConnectionStatusChange(status); |
1636 } | 1633 } |
1637 | 1634 |
1638 #undef SDVLOG | 1635 #undef SDVLOG |
1639 | 1636 |
1640 #undef SLOG | 1637 #undef SLOG |
1641 | 1638 |
1642 } // namespace browser_sync | 1639 } // namespace browser_sync |
OLD | NEW |