Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(34)

Side by Side Diff: chrome/browser/sync/glue/sync_backend_host.cc

Issue 10878015: [Sync] Move keystore key handling to SyncEncryptionHandlerImpl (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 virtual void OnUpdatedToken(const std::string& token) OVERRIDE; 102 virtual void OnUpdatedToken(const std::string& token) OVERRIDE;
103 virtual void OnActionableError( 103 virtual void OnActionableError(
104 const syncer::SyncProtocolError& sync_error) OVERRIDE; 104 const syncer::SyncProtocolError& sync_error) OVERRIDE;
105 105
106 // SyncEncryptionHandler::Observer implementation. 106 // SyncEncryptionHandler::Observer implementation.
107 virtual void OnPassphraseRequired( 107 virtual void OnPassphraseRequired(
108 syncer::PassphraseRequiredReason reason, 108 syncer::PassphraseRequiredReason reason,
109 const sync_pb::EncryptedData& pending_keys) OVERRIDE; 109 const sync_pb::EncryptedData& pending_keys) OVERRIDE;
110 virtual void OnPassphraseAccepted() OVERRIDE; 110 virtual void OnPassphraseAccepted() OVERRIDE;
111 virtual void OnBootstrapTokenUpdated( 111 virtual void OnBootstrapTokenUpdated(
112 const std::string& bootstrap_token) OVERRIDE; 112 const std::string& bootstrap_token,
113 syncer::BootstrapTokenType type) OVERRIDE;
113 virtual void OnEncryptedTypesChanged( 114 virtual void OnEncryptedTypesChanged(
114 syncer::ModelTypeSet encrypted_types, 115 syncer::ModelTypeSet encrypted_types,
115 bool encrypt_everything) OVERRIDE; 116 bool encrypt_everything) OVERRIDE;
116 virtual void OnEncryptionComplete() OVERRIDE; 117 virtual void OnEncryptionComplete() OVERRIDE;
117 virtual void OnCryptographerStateChanged( 118 virtual void OnCryptographerStateChanged(
118 syncer::Cryptographer* cryptographer) OVERRIDE; 119 syncer::Cryptographer* cryptographer) OVERRIDE;
119 virtual void OnPassphraseStateChanged(syncer::PassphraseState state) OVERRIDE; 120 virtual void OnPassphraseStateChanged(syncer::PassphraseState state) OVERRIDE;
120 121
121 // syncer::SyncNotifierObserver implementation. 122 // syncer::SyncNotifierObserver implementation.
122 virtual void OnNotificationsEnabled() OVERRIDE; 123 virtual void OnNotificationsEnabled() OVERRIDE;
(...skipping 766 matching lines...) Expand 10 before | Expand all | Expand 10 after
889 DCHECK(!sync_manager_.get()); 890 DCHECK(!sync_manager_.get());
890 DCHECK(!sync_loop_); 891 DCHECK(!sync_loop_);
891 } 892 }
892 893
893 void SyncBackendHost::Core::OnSyncCycleCompleted( 894 void SyncBackendHost::Core::OnSyncCycleCompleted(
894 const SyncSessionSnapshot& snapshot) { 895 const SyncSessionSnapshot& snapshot) {
895 if (!sync_loop_) 896 if (!sync_loop_)
896 return; 897 return;
897 DCHECK_EQ(MessageLoop::current(), sync_loop_); 898 DCHECK_EQ(MessageLoop::current(), sync_loop_);
898 899
899 if (snapshot.model_neutral_state().last_get_key_result ==
900 syncer::SYNCER_OK) {
901 // If we just received a new keystore key, get it and make sure we update
902 // the bootstrap token with it.
903 std::string keystore_token;
904 sync_manager_->GetKeystoreKeyBootstrapToken(&keystore_token);
905 if (!keystore_token.empty()) {
906 DVLOG(1) << "Persisting keystore encryption bootstrap token.";
907 host_.Call(FROM_HERE,
908 &SyncBackendHost::PersistEncryptionBootstrapToken,
909 keystore_token,
910 KEYSTORE_BOOTSTRAP_TOKEN);
911 } else {
912 NOTREACHED();
913 }
914 }
915
916 host_.Call( 900 host_.Call(
917 FROM_HERE, 901 FROM_HERE,
918 &SyncBackendHost::HandleSyncCycleCompletedOnFrontendLoop, 902 &SyncBackendHost::HandleSyncCycleCompletedOnFrontendLoop,
919 snapshot); 903 snapshot);
920 } 904 }
921 905
922 906
923 void SyncBackendHost::Core::OnInitializationComplete( 907 void SyncBackendHost::Core::OnInitializationComplete(
924 const syncer::WeakHandle<syncer::JsBackend>& js_backend, 908 const syncer::WeakHandle<syncer::JsBackend>& js_backend,
925 bool success, 909 bool success,
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
966 void SyncBackendHost::Core::OnPassphraseAccepted() { 950 void SyncBackendHost::Core::OnPassphraseAccepted() {
967 if (!sync_loop_) 951 if (!sync_loop_)
968 return; 952 return;
969 DCHECK_EQ(MessageLoop::current(), sync_loop_); 953 DCHECK_EQ(MessageLoop::current(), sync_loop_);
970 host_.Call( 954 host_.Call(
971 FROM_HERE, 955 FROM_HERE,
972 &SyncBackendHost::NotifyPassphraseAccepted); 956 &SyncBackendHost::NotifyPassphraseAccepted);
973 } 957 }
974 958
975 void SyncBackendHost::Core::OnBootstrapTokenUpdated( 959 void SyncBackendHost::Core::OnBootstrapTokenUpdated(
976 const std::string& bootstrap_token) { 960 const std::string& bootstrap_token,
961 syncer::BootstrapTokenType type) {
977 if (!sync_loop_) 962 if (!sync_loop_)
978 return; 963 return;
979 DCHECK_EQ(MessageLoop::current(), sync_loop_); 964 DCHECK_EQ(MessageLoop::current(), sync_loop_);
980 host_.Call(FROM_HERE, 965 host_.Call(FROM_HERE,
981 &SyncBackendHost::PersistEncryptionBootstrapToken, 966 &SyncBackendHost::PersistEncryptionBootstrapToken,
982 bootstrap_token, 967 bootstrap_token,
983 PASSPHRASE_BOOTSTRAP_TOKEN); 968 type);
984 } 969 }
985 970
986 void SyncBackendHost::Core::OnStopSyncingPermanently() { 971 void SyncBackendHost::Core::OnStopSyncingPermanently() {
987 if (!sync_loop_) 972 if (!sync_loop_)
988 return; 973 return;
989 DCHECK_EQ(MessageLoop::current(), sync_loop_); 974 DCHECK_EQ(MessageLoop::current(), sync_loop_);
990 host_.Call( 975 host_.Call(
991 FROM_HERE, 976 FROM_HERE,
992 &SyncBackendHost::HandleStopSyncingPermanentlyOnFrontendLoop); 977 &SyncBackendHost::HandleStopSyncingPermanentlyOnFrontendLoop);
993 } 978 }
(...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after
1421 } 1406 }
1422 1407
1423 void SyncBackendHost::RetryConfigurationOnFrontendLoop( 1408 void SyncBackendHost::RetryConfigurationOnFrontendLoop(
1424 const base::Closure& retry_callback) { 1409 const base::Closure& retry_callback) {
1425 SDVLOG(1) << "Failed to complete configuration, informing of retry."; 1410 SDVLOG(1) << "Failed to complete configuration, informing of retry.";
1426 retry_callback.Run(); 1411 retry_callback.Run();
1427 } 1412 }
1428 1413
1429 void SyncBackendHost::PersistEncryptionBootstrapToken( 1414 void SyncBackendHost::PersistEncryptionBootstrapToken(
1430 const std::string& token, 1415 const std::string& token,
1431 BootstrapTokenType token_type) { 1416 syncer::BootstrapTokenType token_type) {
1432 CHECK(sync_prefs_.get()); 1417 CHECK(sync_prefs_.get());
1433 DCHECK(!token.empty()); 1418 DCHECK(!token.empty());
1434 if (token_type == PASSPHRASE_BOOTSTRAP_TOKEN) 1419 if (token_type == syncer::PASSPHRASE_BOOTSTRAP_TOKEN)
1435 sync_prefs_->SetEncryptionBootstrapToken(token); 1420 sync_prefs_->SetEncryptionBootstrapToken(token);
1436 else 1421 else
1437 sync_prefs_->SetKeystoreEncryptionBootstrapToken(token); 1422 sync_prefs_->SetKeystoreEncryptionBootstrapToken(token);
1438 } 1423 }
1439 1424
1440 void SyncBackendHost::HandleActionableErrorEventOnFrontendLoop( 1425 void SyncBackendHost::HandleActionableErrorEventOnFrontendLoop(
1441 const syncer::SyncProtocolError& sync_error) { 1426 const syncer::SyncProtocolError& sync_error) {
1442 if (!frontend_) 1427 if (!frontend_)
1443 return; 1428 return;
1444 DCHECK_EQ(MessageLoop::current(), frontend_loop_); 1429 DCHECK_EQ(MessageLoop::current(), frontend_loop_);
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
1562 const syncer::ModelTypeSet failed_configuration_types) { 1547 const syncer::ModelTypeSet failed_configuration_types) {
1563 HandleInitializationCompletedOnFrontendLoop( 1548 HandleInitializationCompletedOnFrontendLoop(
1564 failed_configuration_types.Empty()); 1549 failed_configuration_types.Empty());
1565 } 1550 }
1566 1551
1567 #undef SDVLOG 1552 #undef SDVLOG
1568 1553
1569 #undef SLOG 1554 #undef SLOG
1570 1555
1571 } // namespace browser_sync 1556 } // namespace browser_sync
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698