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 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 bool encrypt_everything) OVERRIDE; | 114 bool encrypt_everything) OVERRIDE; |
115 virtual void OnEncryptionComplete() OVERRIDE; | 115 virtual void OnEncryptionComplete() OVERRIDE; |
116 virtual void OnCryptographerStateChanged( | 116 virtual void OnCryptographerStateChanged( |
117 syncer::Cryptographer* cryptographer) OVERRIDE; | 117 syncer::Cryptographer* cryptographer) OVERRIDE; |
118 | 118 |
119 // syncer::SyncNotifierObserver implementation. | 119 // syncer::SyncNotifierObserver implementation. |
120 virtual void OnNotificationsEnabled() OVERRIDE; | 120 virtual void OnNotificationsEnabled() OVERRIDE; |
121 virtual void OnNotificationsDisabled( | 121 virtual void OnNotificationsDisabled( |
122 syncer::NotificationsDisabledReason reason) OVERRIDE; | 122 syncer::NotificationsDisabledReason reason) OVERRIDE; |
123 virtual void OnIncomingNotification( | 123 virtual void OnIncomingNotification( |
124 const syncer::ObjectIdPayloadMap& id_payloads, | 124 const syncer::ObjectIdStateMap& id_state_map, |
125 syncer::IncomingNotificationSource source) OVERRIDE; | 125 syncer::IncomingNotificationSource source) OVERRIDE; |
126 | 126 |
127 // Note: | 127 // Note: |
128 // | 128 // |
129 // The Do* methods are the various entry points from our | 129 // The Do* methods are the various entry points from our |
130 // SyncBackendHost. They are all called on the sync thread to | 130 // SyncBackendHost. They are all called on the sync thread to |
131 // actually perform synchronous (and potentially blocking) syncapi | 131 // actually perform synchronous (and potentially blocking) syncapi |
132 // operations. | 132 // operations. |
133 // | 133 // |
134 // Called to perform initialization of the syncapi on behalf of | 134 // Called to perform initialization of the syncapi on behalf of |
(...skipping 913 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1048 syncer::NotificationsDisabledReason reason) { | 1048 syncer::NotificationsDisabledReason reason) { |
1049 if (!sync_loop_) | 1049 if (!sync_loop_) |
1050 return; | 1050 return; |
1051 DCHECK_EQ(MessageLoop::current(), sync_loop_); | 1051 DCHECK_EQ(MessageLoop::current(), sync_loop_); |
1052 host_.Call(FROM_HERE, | 1052 host_.Call(FROM_HERE, |
1053 &SyncBackendHost::HandleNotificationsDisabledOnFrontendLoop, | 1053 &SyncBackendHost::HandleNotificationsDisabledOnFrontendLoop, |
1054 reason); | 1054 reason); |
1055 } | 1055 } |
1056 | 1056 |
1057 void SyncBackendHost::Core::OnIncomingNotification( | 1057 void SyncBackendHost::Core::OnIncomingNotification( |
1058 const syncer::ObjectIdPayloadMap& id_payloads, | 1058 const syncer::ObjectIdStateMap& id_state_map, |
1059 syncer::IncomingNotificationSource source) { | 1059 syncer::IncomingNotificationSource source) { |
1060 if (!sync_loop_) | 1060 if (!sync_loop_) |
1061 return; | 1061 return; |
1062 DCHECK_EQ(MessageLoop::current(), sync_loop_); | 1062 DCHECK_EQ(MessageLoop::current(), sync_loop_); |
1063 host_.Call(FROM_HERE, | 1063 host_.Call(FROM_HERE, |
1064 &SyncBackendHost::HandleIncomingNotificationOnFrontendLoop, | 1064 &SyncBackendHost::HandleIncomingNotificationOnFrontendLoop, |
1065 id_payloads, source); | 1065 id_state_map, source); |
1066 } | 1066 } |
1067 | 1067 |
1068 void SyncBackendHost::Core::DoInitialize(const DoInitializeOptions& options) { | 1068 void SyncBackendHost::Core::DoInitialize(const DoInitializeOptions& options) { |
1069 DCHECK(!sync_loop_); | 1069 DCHECK(!sync_loop_); |
1070 sync_loop_ = options.sync_loop; | 1070 sync_loop_ = options.sync_loop; |
1071 DCHECK(sync_loop_); | 1071 DCHECK(sync_loop_); |
1072 | 1072 |
1073 // Blow away the partial or corrupt sync data folder before doing any more | 1073 // Blow away the partial or corrupt sync data folder before doing any more |
1074 // initialization, if necessary. | 1074 // initialization, if necessary. |
1075 if (options.delete_sync_data_folder) { | 1075 if (options.delete_sync_data_folder) { |
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1439 | 1439 |
1440 void SyncBackendHost::HandleNotificationsDisabledOnFrontendLoop( | 1440 void SyncBackendHost::HandleNotificationsDisabledOnFrontendLoop( |
1441 syncer::NotificationsDisabledReason reason) { | 1441 syncer::NotificationsDisabledReason reason) { |
1442 if (!frontend_) | 1442 if (!frontend_) |
1443 return; | 1443 return; |
1444 DCHECK_EQ(MessageLoop::current(), frontend_loop_); | 1444 DCHECK_EQ(MessageLoop::current(), frontend_loop_); |
1445 frontend_->OnNotificationsDisabled(reason); | 1445 frontend_->OnNotificationsDisabled(reason); |
1446 } | 1446 } |
1447 | 1447 |
1448 void SyncBackendHost::HandleIncomingNotificationOnFrontendLoop( | 1448 void SyncBackendHost::HandleIncomingNotificationOnFrontendLoop( |
1449 const syncer::ObjectIdPayloadMap& id_payloads, | 1449 const syncer::ObjectIdStateMap& id_state_map, |
1450 syncer::IncomingNotificationSource source) { | 1450 syncer::IncomingNotificationSource source) { |
1451 if (!frontend_) | 1451 if (!frontend_) |
1452 return; | 1452 return; |
1453 DCHECK_EQ(MessageLoop::current(), frontend_loop_); | 1453 DCHECK_EQ(MessageLoop::current(), frontend_loop_); |
1454 frontend_->OnIncomingNotification(id_payloads, source); | 1454 frontend_->OnIncomingNotification(id_state_map, source); |
1455 } | 1455 } |
1456 | 1456 |
1457 bool SyncBackendHost::CheckPassphraseAgainstCachedPendingKeys( | 1457 bool SyncBackendHost::CheckPassphraseAgainstCachedPendingKeys( |
1458 const std::string& passphrase) const { | 1458 const std::string& passphrase) const { |
1459 DCHECK(cached_pending_keys_.has_blob()); | 1459 DCHECK(cached_pending_keys_.has_blob()); |
1460 DCHECK(!passphrase.empty()); | 1460 DCHECK(!passphrase.empty()); |
1461 syncer::Nigori nigori; | 1461 syncer::Nigori nigori; |
1462 nigori.InitByDerivation("localhost", "dummy", passphrase); | 1462 nigori.InitByDerivation("localhost", "dummy", passphrase); |
1463 std::string plaintext; | 1463 std::string plaintext; |
1464 bool result = nigori.Decrypt(cached_pending_keys_.blob(), &plaintext); | 1464 bool result = nigori.Decrypt(cached_pending_keys_.blob(), &plaintext); |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1539 const syncer::ModelTypeSet failed_configuration_types) { | 1539 const syncer::ModelTypeSet failed_configuration_types) { |
1540 HandleInitializationCompletedOnFrontendLoop( | 1540 HandleInitializationCompletedOnFrontendLoop( |
1541 failed_configuration_types.Empty()); | 1541 failed_configuration_types.Empty()); |
1542 } | 1542 } |
1543 | 1543 |
1544 #undef SDVLOG | 1544 #undef SDVLOG |
1545 | 1545 |
1546 #undef SLOG | 1546 #undef SLOG |
1547 | 1547 |
1548 } // namespace browser_sync | 1548 } // namespace browser_sync |
OLD | NEW |