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 25 matching lines...) Expand all Loading... |
36 #include "chrome/common/net/gaia/gaia_constants.h" | 36 #include "chrome/common/net/gaia/gaia_constants.h" |
37 #include "content/public/browser/browser_thread.h" | 37 #include "content/public/browser/browser_thread.h" |
38 #include "content/public/browser/notification_service.h" | 38 #include "content/public/browser/notification_service.h" |
39 #include "content/public/common/content_client.h" | 39 #include "content/public/common/content_client.h" |
40 #include "jingle/notifier/base/notification_method.h" | 40 #include "jingle/notifier/base/notification_method.h" |
41 #include "jingle/notifier/base/notifier_options.h" | 41 #include "jingle/notifier/base/notifier_options.h" |
42 #include "net/base/host_port_pair.h" | 42 #include "net/base/host_port_pair.h" |
43 #include "net/url_request/url_request_context_getter.h" | 43 #include "net/url_request/url_request_context_getter.h" |
44 #include "sync/internal_api/public/base_transaction.h" | 44 #include "sync/internal_api/public/base_transaction.h" |
45 #include "sync/internal_api/public/engine/model_safe_worker.h" | 45 #include "sync/internal_api/public/engine/model_safe_worker.h" |
| 46 #include "sync/internal_api/public/http_bridge.h" |
46 #include "sync/internal_api/public/internal_components_factory_impl.h" | 47 #include "sync/internal_api/public/internal_components_factory_impl.h" |
47 #include "sync/internal_api/public/http_bridge.h" | |
48 #include "sync/internal_api/public/read_transaction.h" | 48 #include "sync/internal_api/public/read_transaction.h" |
49 #include "sync/internal_api/public/sync_manager_factory.h" | 49 #include "sync/internal_api/public/sync_manager_factory.h" |
50 #include "sync/internal_api/public/util/experiments.h" | 50 #include "sync/internal_api/public/util/experiments.h" |
51 #include "sync/notifier/sync_notifier.h" | 51 #include "sync/notifier/sync_notifier.h" |
52 #include "sync/protocol/encryption.pb.h" | 52 #include "sync/protocol/encryption.pb.h" |
53 #include "sync/protocol/sync.pb.h" | 53 #include "sync/protocol/sync.pb.h" |
54 #include "sync/util/nigori.h" | 54 #include "sync/util/nigori.h" |
55 | 55 |
56 static const int kSaveChangesIntervalSeconds = 10; | 56 static const int kSaveChangesIntervalSeconds = 10; |
57 static const FilePath::CharType kSyncDataFolderName[] = | 57 static const FilePath::CharType kSyncDataFolderName[] = |
(...skipping 13 matching lines...) Expand all Loading... |
71 | 71 |
72 // Helper macros to log with the syncer thread name; useful when there | 72 // Helper macros to log with the syncer thread name; useful when there |
73 // are multiple syncers involved. | 73 // are multiple syncers involved. |
74 | 74 |
75 #define SLOG(severity) LOG(severity) << name_ << ": " | 75 #define SLOG(severity) LOG(severity) << name_ << ": " |
76 | 76 |
77 #define SDVLOG(verbose_level) DVLOG(verbose_level) << name_ << ": " | 77 #define SDVLOG(verbose_level) DVLOG(verbose_level) << name_ << ": " |
78 | 78 |
79 class SyncBackendHost::Core | 79 class SyncBackendHost::Core |
80 : public base::RefCountedThreadSafe<SyncBackendHost::Core>, | 80 : public base::RefCountedThreadSafe<SyncBackendHost::Core>, |
81 public syncer::SyncManager::Observer { | 81 public syncer::SyncManager::Observer, |
| 82 public syncer::SyncNotifierObserver { |
82 public: | 83 public: |
83 Core(const std::string& name, | 84 Core(const std::string& name, |
84 const FilePath& sync_data_folder_path, | 85 const FilePath& sync_data_folder_path, |
85 const base::WeakPtr<SyncBackendHost>& backend); | 86 const base::WeakPtr<SyncBackendHost>& backend); |
86 | 87 |
87 // SyncManager::Observer implementation. The Core just acts like an air | 88 // SyncManager::Observer implementation. The Core just acts like an air |
88 // traffic controller here, forwarding incoming messages to appropriate | 89 // traffic controller here, forwarding incoming messages to appropriate |
89 // landing threads. | 90 // landing threads. |
90 virtual void OnSyncCycleCompleted( | 91 virtual void OnSyncCycleCompleted( |
91 const syncer::sessions::SyncSessionSnapshot& snapshot) OVERRIDE; | 92 const syncer::sessions::SyncSessionSnapshot& snapshot) OVERRIDE; |
(...skipping 11 matching lines...) Expand all Loading... |
103 const std::string& bootstrap_token) OVERRIDE; | 104 const std::string& bootstrap_token) OVERRIDE; |
104 virtual void OnStopSyncingPermanently() OVERRIDE; | 105 virtual void OnStopSyncingPermanently() OVERRIDE; |
105 virtual void OnUpdatedToken(const std::string& token) OVERRIDE; | 106 virtual void OnUpdatedToken(const std::string& token) OVERRIDE; |
106 virtual void OnEncryptedTypesChanged( | 107 virtual void OnEncryptedTypesChanged( |
107 syncer::ModelTypeSet encrypted_types, | 108 syncer::ModelTypeSet encrypted_types, |
108 bool encrypt_everything) OVERRIDE; | 109 bool encrypt_everything) OVERRIDE; |
109 virtual void OnEncryptionComplete() OVERRIDE; | 110 virtual void OnEncryptionComplete() OVERRIDE; |
110 virtual void OnActionableError( | 111 virtual void OnActionableError( |
111 const syncer::SyncProtocolError& sync_error) OVERRIDE; | 112 const syncer::SyncProtocolError& sync_error) OVERRIDE; |
112 | 113 |
| 114 // syncer::SyncNotifierObserver implementation. |
| 115 virtual void OnNotificationsEnabled() OVERRIDE; |
| 116 virtual void OnNotificationsDisabled( |
| 117 syncer::NotificationsDisabledReason reason) OVERRIDE; |
| 118 virtual void OnIncomingNotification( |
| 119 const syncer::ObjectIdPayloadMap& id_payloads, |
| 120 syncer::IncomingNotificationSource source) OVERRIDE; |
| 121 |
113 // Note: | 122 // Note: |
114 // | 123 // |
115 // The Do* methods are the various entry points from our | 124 // The Do* methods are the various entry points from our |
116 // SyncBackendHost. They are all called on the sync thread to | 125 // SyncBackendHost. They are all called on the sync thread to |
117 // actually perform synchronous (and potentially blocking) syncapi | 126 // actually perform synchronous (and potentially blocking) syncapi |
118 // operations. | 127 // operations. |
119 // | 128 // |
120 // Called to perform initialization of the syncapi on behalf of | 129 // Called to perform initialization of the syncapi on behalf of |
121 // SyncBackendHost::Initialize. | 130 // SyncBackendHost::Initialize. |
122 void DoInitialize(const DoInitializeOptions& options); | 131 void DoInitialize(const DoInitializeOptions& options); |
123 | 132 |
124 // Called to perform credential update on behalf of | 133 // Called to perform credential update on behalf of |
125 // SyncBackendHost::UpdateCredentials | 134 // SyncBackendHost::UpdateCredentials. |
126 void DoUpdateCredentials(const syncer::SyncCredentials& credentials); | 135 void DoUpdateCredentials(const syncer::SyncCredentials& credentials); |
127 | 136 |
| 137 // Called to update the given registered ids on behalf of |
| 138 // SyncBackendHost::UpdateRegisteredInvalidationIds. |
| 139 void DoUpdateRegisteredInvalidationIds(const syncer::ObjectIdSet& ids); |
| 140 |
128 // Called to tell the syncapi to start syncing (generally after | 141 // Called to tell the syncapi to start syncing (generally after |
129 // initialization and authentication). | 142 // initialization and authentication). |
130 void DoStartSyncing(const syncer::ModelSafeRoutingInfo& routing_info); | 143 void DoStartSyncing(const syncer::ModelSafeRoutingInfo& routing_info); |
131 | 144 |
132 // Called to set the passphrase for encryption. | 145 // Called to set the passphrase for encryption. |
133 void DoSetEncryptionPassphrase(const std::string& passphrase, | 146 void DoSetEncryptionPassphrase(const std::string& passphrase, |
134 bool is_explicit); | 147 bool is_explicit); |
135 | 148 |
136 // Called to decrypt the pending keys. | 149 // Called to decrypt the pending keys. |
137 void DoSetDecryptionPassphrase(const std::string& passphrase); | 150 void DoSetDecryptionPassphrase(const std::string& passphrase); |
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
416 unrecoverable_error_handler, | 429 unrecoverable_error_handler, |
417 report_unrecoverable_error_function)); | 430 report_unrecoverable_error_function)); |
418 } | 431 } |
419 | 432 |
420 void SyncBackendHost::UpdateCredentials(const SyncCredentials& credentials) { | 433 void SyncBackendHost::UpdateCredentials(const SyncCredentials& credentials) { |
421 sync_thread_.message_loop()->PostTask(FROM_HERE, | 434 sync_thread_.message_loop()->PostTask(FROM_HERE, |
422 base::Bind(&SyncBackendHost::Core::DoUpdateCredentials, core_.get(), | 435 base::Bind(&SyncBackendHost::Core::DoUpdateCredentials, core_.get(), |
423 credentials)); | 436 credentials)); |
424 } | 437 } |
425 | 438 |
| 439 void SyncBackendHost::UpdateRegisteredInvalidationIds( |
| 440 const syncer::ObjectIdSet& ids) { |
| 441 DCHECK_EQ(MessageLoop::current(), frontend_loop_); |
| 442 DCHECK(sync_thread_.IsRunning()); |
| 443 sync_thread_.message_loop()->PostTask(FROM_HERE, |
| 444 base::Bind(&SyncBackendHost::Core::DoUpdateRegisteredInvalidationIds, |
| 445 core_.get(), ids)); |
| 446 } |
| 447 |
426 void SyncBackendHost::StartSyncingWithServer() { | 448 void SyncBackendHost::StartSyncingWithServer() { |
427 SDVLOG(1) << "SyncBackendHost::StartSyncingWithServer called."; | 449 SDVLOG(1) << "SyncBackendHost::StartSyncingWithServer called."; |
428 | 450 |
429 syncer::ModelSafeRoutingInfo routing_info; | 451 syncer::ModelSafeRoutingInfo routing_info; |
430 registrar_->GetModelSafeRoutingInfo(&routing_info); | 452 registrar_->GetModelSafeRoutingInfo(&routing_info); |
431 | 453 |
432 sync_thread_.message_loop()->PostTask(FROM_HERE, | 454 sync_thread_.message_loop()->PostTask(FROM_HERE, |
433 base::Bind(&SyncBackendHost::Core::DoStartSyncing, | 455 base::Bind(&SyncBackendHost::Core::DoStartSyncing, |
434 core_.get(), routing_info)); | 456 core_.get(), routing_info)); |
435 } | 457 } |
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
864 | 886 |
865 | 887 |
866 void SyncBackendHost::Core::OnInitializationComplete( | 888 void SyncBackendHost::Core::OnInitializationComplete( |
867 const syncer::WeakHandle<syncer::JsBackend>& js_backend, | 889 const syncer::WeakHandle<syncer::JsBackend>& js_backend, |
868 bool success, | 890 bool success, |
869 const syncer::ModelTypeSet restored_types) { | 891 const syncer::ModelTypeSet restored_types) { |
870 DCHECK_EQ(MessageLoop::current(), sync_loop_); | 892 DCHECK_EQ(MessageLoop::current(), sync_loop_); |
871 | 893 |
872 if (!success) { | 894 if (!success) { |
873 sync_manager_->RemoveObserver(this); | 895 sync_manager_->RemoveObserver(this); |
| 896 sync_manager_->UpdateRegisteredInvalidationIds( |
| 897 this, syncer::ObjectIdSet()); |
874 sync_manager_->ShutdownOnSyncThread(); | 898 sync_manager_->ShutdownOnSyncThread(); |
875 sync_manager_.reset(); | 899 sync_manager_.reset(); |
876 } | 900 } |
877 | 901 |
878 host_.Call( | 902 host_.Call( |
879 FROM_HERE, | 903 FROM_HERE, |
880 &SyncBackendHost::HandleSyncManagerInitializationOnFrontendLoop, | 904 &SyncBackendHost::HandleSyncManagerInitializationOnFrontendLoop, |
881 js_backend, success, restored_types); | 905 js_backend, success, restored_types); |
882 | 906 |
883 if (success) { | 907 if (success) { |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
973 const syncer::SyncProtocolError& sync_error) { | 997 const syncer::SyncProtocolError& sync_error) { |
974 if (!sync_loop_) | 998 if (!sync_loop_) |
975 return; | 999 return; |
976 DCHECK_EQ(MessageLoop::current(), sync_loop_); | 1000 DCHECK_EQ(MessageLoop::current(), sync_loop_); |
977 host_.Call( | 1001 host_.Call( |
978 FROM_HERE, | 1002 FROM_HERE, |
979 &SyncBackendHost::HandleActionableErrorEventOnFrontendLoop, | 1003 &SyncBackendHost::HandleActionableErrorEventOnFrontendLoop, |
980 sync_error); | 1004 sync_error); |
981 } | 1005 } |
982 | 1006 |
| 1007 void SyncBackendHost::Core::OnNotificationsEnabled() { |
| 1008 if (!sync_loop_) |
| 1009 return; |
| 1010 DCHECK_EQ(MessageLoop::current(), sync_loop_); |
| 1011 host_.Call(FROM_HERE, |
| 1012 &SyncBackendHost::HandleNotificationsEnabledOnFrontendLoop); |
| 1013 } |
| 1014 |
| 1015 void SyncBackendHost::Core::OnNotificationsDisabled( |
| 1016 syncer::NotificationsDisabledReason reason) { |
| 1017 if (!sync_loop_) |
| 1018 return; |
| 1019 DCHECK_EQ(MessageLoop::current(), sync_loop_); |
| 1020 host_.Call(FROM_HERE, |
| 1021 &SyncBackendHost::HandleNotificationsDisabledOnFrontendLoop, |
| 1022 reason); |
| 1023 } |
| 1024 |
| 1025 void SyncBackendHost::Core::OnIncomingNotification( |
| 1026 const syncer::ObjectIdPayloadMap& id_payloads, |
| 1027 syncer::IncomingNotificationSource source) { |
| 1028 if (!sync_loop_) |
| 1029 return; |
| 1030 DCHECK_EQ(MessageLoop::current(), sync_loop_); |
| 1031 host_.Call(FROM_HERE, |
| 1032 &SyncBackendHost::HandleIncomingNotificationOnFrontendLoop, |
| 1033 id_payloads, source); |
| 1034 } |
| 1035 |
983 void SyncBackendHost::Core::DoInitialize(const DoInitializeOptions& options) { | 1036 void SyncBackendHost::Core::DoInitialize(const DoInitializeOptions& options) { |
984 DCHECK(!sync_loop_); | 1037 DCHECK(!sync_loop_); |
985 sync_loop_ = options.sync_loop; | 1038 sync_loop_ = options.sync_loop; |
986 DCHECK(sync_loop_); | 1039 DCHECK(sync_loop_); |
987 | 1040 |
988 // Blow away the partial or corrupt sync data folder before doing any more | 1041 // Blow away the partial or corrupt sync data folder before doing any more |
989 // initialization, if necessary. | 1042 // initialization, if necessary. |
990 if (options.delete_sync_data_folder) { | 1043 if (options.delete_sync_data_folder) { |
991 DeleteSyncDataFolder(); | 1044 DeleteSyncDataFolder(); |
992 } | 1045 } |
(...skipping 30 matching lines...) Expand all Loading... |
1023 options.sync_notifier_factory->CreateSyncNotifier())), | 1076 options.sync_notifier_factory->CreateSyncNotifier())), |
1024 options.restored_key_for_bootstrapping, | 1077 options.restored_key_for_bootstrapping, |
1025 options.restored_keystore_key_for_bootstrapping, | 1078 options.restored_keystore_key_for_bootstrapping, |
1026 CommandLine::ForCurrentProcess()->HasSwitch( | 1079 CommandLine::ForCurrentProcess()->HasSwitch( |
1027 switches::kSyncKeystoreEncryption), | 1080 switches::kSyncKeystoreEncryption), |
1028 scoped_ptr<InternalComponentsFactory>( | 1081 scoped_ptr<InternalComponentsFactory>( |
1029 options.internal_components_factory), | 1082 options.internal_components_factory), |
1030 &encryptor_, | 1083 &encryptor_, |
1031 options.unrecoverable_error_handler, | 1084 options.unrecoverable_error_handler, |
1032 options.report_unrecoverable_error_function); | 1085 options.report_unrecoverable_error_function); |
1033 LOG_IF(ERROR, !success) << "Syncapi initialization failed!"; | 1086 LOG_IF(ERROR, !success) << "Sync manager initialization failed!"; |
1034 | 1087 |
1035 // Now check the command line to see if we need to simulate an | 1088 // Now check the command line to see if we need to simulate an |
1036 // unrecoverable error for testing purpose. Note the error is thrown | 1089 // unrecoverable error for testing purpose. Note the error is thrown |
1037 // only if the initialization succeeded. Also it makes sense to use this | 1090 // only if the initialization succeeded. Also it makes sense to use this |
1038 // flag only when restarting the browser with an account already setup. If | 1091 // flag only when restarting the browser with an account already setup. If |
1039 // you use this before setting up the setup would not succeed as an error | 1092 // you use this before setting up the setup would not succeed as an error |
1040 // would be encountered. | 1093 // would be encountered. |
1041 if (CommandLine::ForCurrentProcess()->HasSwitch( | 1094 if (CommandLine::ForCurrentProcess()->HasSwitch( |
1042 switches::kSyncThrowUnrecoverableError)) { | 1095 switches::kSyncThrowUnrecoverableError)) { |
1043 sync_manager_->ThrowUnrecoverableError(); | 1096 sync_manager_->ThrowUnrecoverableError(); |
1044 } | 1097 } |
1045 } | 1098 } |
1046 | 1099 |
1047 void SyncBackendHost::Core::DoUpdateCredentials( | 1100 void SyncBackendHost::Core::DoUpdateCredentials( |
1048 const SyncCredentials& credentials) { | 1101 const SyncCredentials& credentials) { |
1049 DCHECK_EQ(MessageLoop::current(), sync_loop_); | 1102 DCHECK_EQ(MessageLoop::current(), sync_loop_); |
1050 sync_manager_->UpdateCredentials(credentials); | 1103 sync_manager_->UpdateCredentials(credentials); |
1051 } | 1104 } |
1052 | 1105 |
| 1106 void SyncBackendHost::Core::DoUpdateRegisteredInvalidationIds( |
| 1107 const syncer::ObjectIdSet& ids) { |
| 1108 DCHECK_EQ(MessageLoop::current(), sync_loop_); |
| 1109 // |sync_manager_| may end up being NULL here in tests (in |
| 1110 // synchronous initialization mode) since this is called during |
| 1111 // shutdown. |
| 1112 // |
| 1113 // TODO(akalin): Fix this behavior. |
| 1114 if (sync_manager_.get()) { |
| 1115 sync_manager_->UpdateRegisteredInvalidationIds(this, ids); |
| 1116 } |
| 1117 } |
| 1118 |
1053 void SyncBackendHost::Core::DoStartSyncing( | 1119 void SyncBackendHost::Core::DoStartSyncing( |
1054 const syncer::ModelSafeRoutingInfo& routing_info) { | 1120 const syncer::ModelSafeRoutingInfo& routing_info) { |
1055 DCHECK_EQ(MessageLoop::current(), sync_loop_); | 1121 DCHECK_EQ(MessageLoop::current(), sync_loop_); |
1056 sync_manager_->StartSyncingNormally(routing_info); | 1122 sync_manager_->StartSyncingNormally(routing_info); |
1057 } | 1123 } |
1058 | 1124 |
1059 void SyncBackendHost::Core::DoSetEncryptionPassphrase( | 1125 void SyncBackendHost::Core::DoSetEncryptionPassphrase( |
1060 const std::string& passphrase, | 1126 const std::string& passphrase, |
1061 bool is_explicit) { | 1127 bool is_explicit) { |
1062 DCHECK_EQ(MessageLoop::current(), sync_loop_); | 1128 DCHECK_EQ(MessageLoop::current(), sync_loop_); |
(...skipping 25 matching lines...) Expand all Loading... |
1088 sync_manager_->StopSyncingForShutdown(closure); | 1154 sync_manager_->StopSyncingForShutdown(closure); |
1089 } else { | 1155 } else { |
1090 sync_loop_->PostTask(FROM_HERE, closure); | 1156 sync_loop_->PostTask(FROM_HERE, closure); |
1091 } | 1157 } |
1092 } | 1158 } |
1093 | 1159 |
1094 void SyncBackendHost::Core::DoShutdown(bool sync_disabled) { | 1160 void SyncBackendHost::Core::DoShutdown(bool sync_disabled) { |
1095 DCHECK_EQ(MessageLoop::current(), sync_loop_); | 1161 DCHECK_EQ(MessageLoop::current(), sync_loop_); |
1096 if (sync_manager_.get()) { | 1162 if (sync_manager_.get()) { |
1097 save_changes_timer_.reset(); | 1163 save_changes_timer_.reset(); |
| 1164 sync_manager_->UpdateRegisteredInvalidationIds( |
| 1165 this, syncer::ObjectIdSet()); |
1098 sync_manager_->ShutdownOnSyncThread(); | 1166 sync_manager_->ShutdownOnSyncThread(); |
1099 sync_manager_->RemoveObserver(this); | 1167 sync_manager_->RemoveObserver(this); |
1100 sync_manager_.reset(); | 1168 sync_manager_.reset(); |
1101 } | 1169 } |
1102 | 1170 |
1103 chrome_sync_notification_bridge_ = NULL; | 1171 chrome_sync_notification_bridge_ = NULL; |
1104 registrar_ = NULL; | 1172 registrar_ = NULL; |
1105 | 1173 |
1106 if (sync_disabled) | 1174 if (sync_disabled) |
1107 DeleteSyncDataFolder(); | 1175 DeleteSyncDataFolder(); |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1306 } | 1374 } |
1307 | 1375 |
1308 void SyncBackendHost::HandleActionableErrorEventOnFrontendLoop( | 1376 void SyncBackendHost::HandleActionableErrorEventOnFrontendLoop( |
1309 const syncer::SyncProtocolError& sync_error) { | 1377 const syncer::SyncProtocolError& sync_error) { |
1310 if (!frontend_) | 1378 if (!frontend_) |
1311 return; | 1379 return; |
1312 DCHECK_EQ(MessageLoop::current(), frontend_loop_); | 1380 DCHECK_EQ(MessageLoop::current(), frontend_loop_); |
1313 frontend_->OnActionableError(sync_error); | 1381 frontend_->OnActionableError(sync_error); |
1314 } | 1382 } |
1315 | 1383 |
| 1384 void SyncBackendHost::HandleNotificationsEnabledOnFrontendLoop() { |
| 1385 if (!frontend_) |
| 1386 return; |
| 1387 DCHECK_EQ(MessageLoop::current(), frontend_loop_); |
| 1388 frontend_->OnNotificationsEnabled(); |
| 1389 } |
| 1390 |
| 1391 void SyncBackendHost::HandleNotificationsDisabledOnFrontendLoop( |
| 1392 syncer::NotificationsDisabledReason reason) { |
| 1393 if (!frontend_) |
| 1394 return; |
| 1395 DCHECK_EQ(MessageLoop::current(), frontend_loop_); |
| 1396 frontend_->OnNotificationsDisabled(reason); |
| 1397 } |
| 1398 |
| 1399 void SyncBackendHost::HandleIncomingNotificationOnFrontendLoop( |
| 1400 const syncer::ObjectIdPayloadMap& id_payloads, |
| 1401 syncer::IncomingNotificationSource source) { |
| 1402 if (!frontend_) |
| 1403 return; |
| 1404 DCHECK_EQ(MessageLoop::current(), frontend_loop_); |
| 1405 frontend_->OnIncomingNotification(id_payloads, source); |
| 1406 } |
| 1407 |
1316 bool SyncBackendHost::CheckPassphraseAgainstCachedPendingKeys( | 1408 bool SyncBackendHost::CheckPassphraseAgainstCachedPendingKeys( |
1317 const std::string& passphrase) const { | 1409 const std::string& passphrase) const { |
1318 DCHECK(cached_pending_keys_.has_blob()); | 1410 DCHECK(cached_pending_keys_.has_blob()); |
1319 DCHECK(!passphrase.empty()); | 1411 DCHECK(!passphrase.empty()); |
1320 syncer::Nigori nigori; | 1412 syncer::Nigori nigori; |
1321 nigori.InitByDerivation("localhost", "dummy", passphrase); | 1413 nigori.InitByDerivation("localhost", "dummy", passphrase); |
1322 std::string plaintext; | 1414 std::string plaintext; |
1323 bool result = nigori.Decrypt(cached_pending_keys_.blob(), &plaintext); | 1415 bool result = nigori.Decrypt(cached_pending_keys_.blob(), &plaintext); |
1324 return result; | 1416 return result; |
1325 } | 1417 } |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1420 FROM_HERE, | 1512 FROM_HERE, |
1421 base::Bind(&SyncBackendHost::Core::DoRefreshNigori, | 1513 base::Bind(&SyncBackendHost::Core::DoRefreshNigori, |
1422 core_.get(), sync_thread_done_callback)); | 1514 core_.get(), sync_thread_done_callback)); |
1423 } | 1515 } |
1424 | 1516 |
1425 #undef SDVLOG | 1517 #undef SDVLOG |
1426 | 1518 |
1427 #undef SLOG | 1519 #undef SLOG |
1428 | 1520 |
1429 } // namespace browser_sync | 1521 } // namespace browser_sync |
OLD | NEW |