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 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 bool encrypt_everything) OVERRIDE; | 109 bool encrypt_everything) OVERRIDE; |
110 virtual void OnEncryptionComplete() OVERRIDE; | 110 virtual void OnEncryptionComplete() OVERRIDE; |
111 virtual void OnActionableError( | 111 virtual void OnActionableError( |
112 const syncer::SyncProtocolError& sync_error) OVERRIDE; | 112 const syncer::SyncProtocolError& sync_error) OVERRIDE; |
113 | 113 |
114 // syncer::SyncNotifierObserver implementation. | 114 // syncer::SyncNotifierObserver implementation. |
115 virtual void OnNotificationsEnabled() OVERRIDE; | 115 virtual void OnNotificationsEnabled() OVERRIDE; |
116 virtual void OnNotificationsDisabled( | 116 virtual void OnNotificationsDisabled( |
117 syncer::NotificationsDisabledReason reason) OVERRIDE; | 117 syncer::NotificationsDisabledReason reason) OVERRIDE; |
118 virtual void OnIncomingNotification( | 118 virtual void OnIncomingNotification( |
119 const syncer::ObjectIdPayloadMap& id_payloads, | 119 const syncer::ObjectIdStateMap& id_state_map, |
120 syncer::IncomingNotificationSource source) OVERRIDE; | 120 syncer::IncomingNotificationSource source) OVERRIDE; |
121 | 121 |
122 // Note: | 122 // Note: |
123 // | 123 // |
124 // The Do* methods are the various entry points from our | 124 // The Do* methods are the various entry points from our |
125 // SyncBackendHost. They are all called on the sync thread to | 125 // SyncBackendHost. They are all called on the sync thread to |
126 // actually perform synchronous (and potentially blocking) syncapi | 126 // actually perform synchronous (and potentially blocking) syncapi |
127 // operations. | 127 // operations. |
128 // | 128 // |
129 // Called to perform initialization of the syncapi on behalf of | 129 // Called to perform initialization of the syncapi on behalf of |
(...skipping 900 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1030 syncer::NotificationsDisabledReason reason) { | 1030 syncer::NotificationsDisabledReason reason) { |
1031 if (!sync_loop_) | 1031 if (!sync_loop_) |
1032 return; | 1032 return; |
1033 DCHECK_EQ(MessageLoop::current(), sync_loop_); | 1033 DCHECK_EQ(MessageLoop::current(), sync_loop_); |
1034 host_.Call(FROM_HERE, | 1034 host_.Call(FROM_HERE, |
1035 &SyncBackendHost::HandleNotificationsDisabledOnFrontendLoop, | 1035 &SyncBackendHost::HandleNotificationsDisabledOnFrontendLoop, |
1036 reason); | 1036 reason); |
1037 } | 1037 } |
1038 | 1038 |
1039 void SyncBackendHost::Core::OnIncomingNotification( | 1039 void SyncBackendHost::Core::OnIncomingNotification( |
1040 const syncer::ObjectIdPayloadMap& id_payloads, | 1040 const syncer::ObjectIdStateMap& id_state_map, |
1041 syncer::IncomingNotificationSource source) { | 1041 syncer::IncomingNotificationSource source) { |
1042 if (!sync_loop_) | 1042 if (!sync_loop_) |
1043 return; | 1043 return; |
1044 DCHECK_EQ(MessageLoop::current(), sync_loop_); | 1044 DCHECK_EQ(MessageLoop::current(), sync_loop_); |
1045 host_.Call(FROM_HERE, | 1045 host_.Call(FROM_HERE, |
1046 &SyncBackendHost::HandleIncomingNotificationOnFrontendLoop, | 1046 &SyncBackendHost::HandleIncomingNotificationOnFrontendLoop, |
1047 id_payloads, source); | 1047 id_state_map, source); |
1048 } | 1048 } |
1049 | 1049 |
1050 void SyncBackendHost::Core::DoInitialize(const DoInitializeOptions& options) { | 1050 void SyncBackendHost::Core::DoInitialize(const DoInitializeOptions& options) { |
1051 DCHECK(!sync_loop_); | 1051 DCHECK(!sync_loop_); |
1052 sync_loop_ = options.sync_loop; | 1052 sync_loop_ = options.sync_loop; |
1053 DCHECK(sync_loop_); | 1053 DCHECK(sync_loop_); |
1054 | 1054 |
1055 // Blow away the partial or corrupt sync data folder before doing any more | 1055 // Blow away the partial or corrupt sync data folder before doing any more |
1056 // initialization, if necessary. | 1056 // initialization, if necessary. |
1057 if (options.delete_sync_data_folder) { | 1057 if (options.delete_sync_data_folder) { |
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1420 | 1420 |
1421 void SyncBackendHost::HandleNotificationsDisabledOnFrontendLoop( | 1421 void SyncBackendHost::HandleNotificationsDisabledOnFrontendLoop( |
1422 syncer::NotificationsDisabledReason reason) { | 1422 syncer::NotificationsDisabledReason reason) { |
1423 if (!frontend_) | 1423 if (!frontend_) |
1424 return; | 1424 return; |
1425 DCHECK_EQ(MessageLoop::current(), frontend_loop_); | 1425 DCHECK_EQ(MessageLoop::current(), frontend_loop_); |
1426 frontend_->OnNotificationsDisabled(reason); | 1426 frontend_->OnNotificationsDisabled(reason); |
1427 } | 1427 } |
1428 | 1428 |
1429 void SyncBackendHost::HandleIncomingNotificationOnFrontendLoop( | 1429 void SyncBackendHost::HandleIncomingNotificationOnFrontendLoop( |
1430 const syncer::ObjectIdPayloadMap& id_payloads, | 1430 const syncer::ObjectIdStateMap& id_state_map, |
1431 syncer::IncomingNotificationSource source) { | 1431 syncer::IncomingNotificationSource source) { |
1432 if (!frontend_) | 1432 if (!frontend_) |
1433 return; | 1433 return; |
1434 DCHECK_EQ(MessageLoop::current(), frontend_loop_); | 1434 DCHECK_EQ(MessageLoop::current(), frontend_loop_); |
1435 frontend_->OnIncomingNotification(id_payloads, source); | 1435 frontend_->OnIncomingNotification(id_state_map, source); |
1436 } | 1436 } |
1437 | 1437 |
1438 bool SyncBackendHost::CheckPassphraseAgainstCachedPendingKeys( | 1438 bool SyncBackendHost::CheckPassphraseAgainstCachedPendingKeys( |
1439 const std::string& passphrase) const { | 1439 const std::string& passphrase) const { |
1440 DCHECK(cached_pending_keys_.has_blob()); | 1440 DCHECK(cached_pending_keys_.has_blob()); |
1441 DCHECK(!passphrase.empty()); | 1441 DCHECK(!passphrase.empty()); |
1442 syncer::Nigori nigori; | 1442 syncer::Nigori nigori; |
1443 nigori.InitByDerivation("localhost", "dummy", passphrase); | 1443 nigori.InitByDerivation("localhost", "dummy", passphrase); |
1444 std::string plaintext; | 1444 std::string plaintext; |
1445 bool result = nigori.Decrypt(cached_pending_keys_.blob(), &plaintext); | 1445 bool result = nigori.Decrypt(cached_pending_keys_.blob(), &plaintext); |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1542 FROM_HERE, | 1542 FROM_HERE, |
1543 base::Bind(&SyncBackendHost::Core::DoRefreshNigori, | 1543 base::Bind(&SyncBackendHost::Core::DoRefreshNigori, |
1544 core_.get(), sync_thread_done_callback)); | 1544 core_.get(), sync_thread_done_callback)); |
1545 } | 1545 } |
1546 | 1546 |
1547 #undef SDVLOG | 1547 #undef SDVLOG |
1548 | 1548 |
1549 #undef SLOG | 1549 #undef SLOG |
1550 | 1550 |
1551 } // namespace browser_sync | 1551 } // namespace browser_sync |
OLD | NEW |