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

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

Issue 10916036: [Sync] Implement keystore migration support. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments Created 8 years, 3 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 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 virtual void OnPassphraseAccepted() OVERRIDE; 110 virtual void OnPassphraseAccepted() OVERRIDE;
111 virtual void OnBootstrapTokenUpdated( 111 virtual void OnBootstrapTokenUpdated(
112 const std::string& bootstrap_token, 112 const std::string& bootstrap_token,
113 syncer::BootstrapTokenType type) OVERRIDE; 113 syncer::BootstrapTokenType type) OVERRIDE;
114 virtual void OnEncryptedTypesChanged( 114 virtual void OnEncryptedTypesChanged(
115 syncer::ModelTypeSet encrypted_types, 115 syncer::ModelTypeSet encrypted_types,
116 bool encrypt_everything) OVERRIDE; 116 bool encrypt_everything) OVERRIDE;
117 virtual void OnEncryptionComplete() OVERRIDE; 117 virtual void OnEncryptionComplete() OVERRIDE;
118 virtual void OnCryptographerStateChanged( 118 virtual void OnCryptographerStateChanged(
119 syncer::Cryptographer* cryptographer) OVERRIDE; 119 syncer::Cryptographer* cryptographer) OVERRIDE;
120 virtual void OnPassphraseStateChanged(syncer::PassphraseState state) OVERRIDE; 120 virtual void OnPassphraseTypeChanged(syncer::PassphraseType type) OVERRIDE;
121 121
122 // syncer::InvalidationHandler implementation. 122 // syncer::InvalidationHandler implementation.
123 virtual void OnNotificationsEnabled() OVERRIDE; 123 virtual void OnNotificationsEnabled() OVERRIDE;
124 virtual void OnNotificationsDisabled( 124 virtual void OnNotificationsDisabled(
125 syncer::NotificationsDisabledReason reason) OVERRIDE; 125 syncer::NotificationsDisabledReason reason) OVERRIDE;
126 virtual void OnIncomingNotification( 126 virtual void OnIncomingNotification(
127 const syncer::ObjectIdStateMap& id_state_map, 127 const syncer::ObjectIdStateMap& id_state_map,
128 syncer::IncomingNotificationSource source) OVERRIDE; 128 syncer::IncomingNotificationSource source) OVERRIDE;
129 129
130 // Note: 130 // Note:
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 core_(new Core(name, profile_->GetPath().Append(kSyncDataFolderName), 322 core_(new Core(name, profile_->GetPath().Append(kSyncDataFolderName),
323 weak_ptr_factory_.GetWeakPtr())), 323 weak_ptr_factory_.GetWeakPtr())),
324 initialization_state_(NOT_ATTEMPTED), 324 initialization_state_(NOT_ATTEMPTED),
325 sync_prefs_(sync_prefs), 325 sync_prefs_(sync_prefs),
326 invalidator_factory_( 326 invalidator_factory_(
327 ParseNotifierOptions(*CommandLine::ForCurrentProcess(), 327 ParseNotifierOptions(*CommandLine::ForCurrentProcess(),
328 profile_->GetRequestContext()), 328 profile_->GetRequestContext()),
329 content::GetUserAgent(GURL()), 329 content::GetUserAgent(GURL()),
330 invalidator_storage), 330 invalidator_storage),
331 frontend_(NULL), 331 frontend_(NULL),
332 cached_passphrase_state_(syncer::IMPLICIT_PASSPHRASE) { 332 cached_passphrase_type_(syncer::IMPLICIT_PASSPHRASE) {
333 } 333 }
334 334
335 SyncBackendHost::SyncBackendHost(Profile* profile) 335 SyncBackendHost::SyncBackendHost(Profile* profile)
336 : weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), 336 : weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)),
337 sync_thread_("Chrome_SyncThread"), 337 sync_thread_("Chrome_SyncThread"),
338 frontend_loop_(MessageLoop::current()), 338 frontend_loop_(MessageLoop::current()),
339 profile_(profile), 339 profile_(profile),
340 name_("Unknown"), 340 name_("Unknown"),
341 initialization_state_(NOT_ATTEMPTED), 341 initialization_state_(NOT_ATTEMPTED),
342 invalidator_factory_( 342 invalidator_factory_(
343 ParseNotifierOptions(*CommandLine::ForCurrentProcess(), 343 ParseNotifierOptions(*CommandLine::ForCurrentProcess(),
344 profile_->GetRequestContext()), 344 profile_->GetRequestContext()),
345 content::GetUserAgent(GURL()), 345 content::GetUserAgent(GURL()),
346 base::WeakPtr<syncer::InvalidationStateTracker>()), 346 base::WeakPtr<syncer::InvalidationStateTracker>()),
347 frontend_(NULL), 347 frontend_(NULL),
348 cached_passphrase_state_(syncer::IMPLICIT_PASSPHRASE) { 348 cached_passphrase_type_(syncer::IMPLICIT_PASSPHRASE) {
349 } 349 }
350 350
351 SyncBackendHost::~SyncBackendHost() { 351 SyncBackendHost::~SyncBackendHost() {
352 DCHECK(!core_ && !frontend_) << "Must call Shutdown before destructor."; 352 DCHECK(!core_ && !frontend_) << "Must call Shutdown before destructor.";
353 DCHECK(!chrome_sync_notification_bridge_.get()); 353 DCHECK(!chrome_sync_notification_bridge_.get());
354 DCHECK(!registrar_.get()); 354 DCHECK(!registrar_.get());
355 } 355 }
356 356
357 namespace { 357 namespace {
358 358
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after
763 } 763 }
764 764
765 bool SyncBackendHost::IsUsingExplicitPassphrase() { 765 bool SyncBackendHost::IsUsingExplicitPassphrase() {
766 // This should only be called once the nigori node has been downloaded, as 766 // This should only be called once the nigori node has been downloaded, as
767 // otherwise we have no idea what kind of passphrase we are using. This will 767 // otherwise we have no idea what kind of passphrase we are using. This will
768 // NOTREACH in sync_manager and return false if we fail to load the nigori 768 // NOTREACH in sync_manager and return false if we fail to load the nigori
769 // node. 769 // node.
770 // TODO(zea): expose whether the custom passphrase is a frozen implicit 770 // TODO(zea): expose whether the custom passphrase is a frozen implicit
771 // passphrase or not to provide better messaging. 771 // passphrase or not to provide better messaging.
772 return IsNigoriEnabled() && ( 772 return IsNigoriEnabled() && (
773 cached_passphrase_state_ == syncer::CUSTOM_PASSPHRASE || 773 cached_passphrase_type_ == syncer::CUSTOM_PASSPHRASE ||
774 cached_passphrase_state_ == syncer::FROZEN_IMPLICIT_PASSPHRASE); 774 cached_passphrase_type_ == syncer::FROZEN_IMPLICIT_PASSPHRASE);
775 } 775 }
776 776
777 bool SyncBackendHost::IsCryptographerReady( 777 bool SyncBackendHost::IsCryptographerReady(
778 const syncer::BaseTransaction* trans) const { 778 const syncer::BaseTransaction* trans) const {
779 return initialized() && trans->GetCryptographer()->is_ready(); 779 return initialized() && trans->GetCryptographer()->is_ready();
780 } 780 }
781 781
782 void SyncBackendHost::GetModelSafeRoutingInfo( 782 void SyncBackendHost::GetModelSafeRoutingInfo(
783 syncer::ModelSafeRoutingInfo* out) const { 783 syncer::ModelSafeRoutingInfo* out) const {
784 if (initialized()) { 784 if (initialized()) {
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
1012 host_.Call( 1012 host_.Call(
1013 FROM_HERE, 1013 FROM_HERE,
1014 &SyncBackendHost::NotifyEncryptionComplete); 1014 &SyncBackendHost::NotifyEncryptionComplete);
1015 } 1015 }
1016 1016
1017 void SyncBackendHost::Core::OnCryptographerStateChanged( 1017 void SyncBackendHost::Core::OnCryptographerStateChanged(
1018 syncer::Cryptographer* cryptographer) { 1018 syncer::Cryptographer* cryptographer) {
1019 // Do nothing. 1019 // Do nothing.
1020 } 1020 }
1021 1021
1022 void SyncBackendHost::Core::OnPassphraseStateChanged( 1022 void SyncBackendHost::Core::OnPassphraseTypeChanged(
1023 syncer::PassphraseState state) { 1023 syncer::PassphraseType type) {
1024 host_.Call( 1024 host_.Call(
1025 FROM_HERE, 1025 FROM_HERE,
1026 &SyncBackendHost::HandlePassphraseStateChangedOnFrontendLoop, 1026 &SyncBackendHost::HandlePassphraseTypeChangedOnFrontendLoop,
1027 state); 1027 type);
1028 } 1028 }
1029 1029
1030 void SyncBackendHost::Core::OnActionableError( 1030 void SyncBackendHost::Core::OnActionableError(
1031 const syncer::SyncProtocolError& sync_error) { 1031 const syncer::SyncProtocolError& sync_error) {
1032 if (!sync_loop_) 1032 if (!sync_loop_)
1033 return; 1033 return;
1034 DCHECK_EQ(MessageLoop::current(), sync_loop_); 1034 DCHECK_EQ(MessageLoop::current(), sync_loop_);
1035 host_.Call( 1035 host_.Call(
1036 FROM_HERE, 1036 FROM_HERE,
1037 &SyncBackendHost::HandleActionableErrorEventOnFrontendLoop, 1037 &SyncBackendHost::HandleActionableErrorEventOnFrontendLoop,
(...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after
1513 } 1513 }
1514 1514
1515 void SyncBackendHost::NotifyEncryptionComplete() { 1515 void SyncBackendHost::NotifyEncryptionComplete() {
1516 if (!frontend_) 1516 if (!frontend_)
1517 return; 1517 return;
1518 1518
1519 DCHECK_EQ(MessageLoop::current(), frontend_loop_); 1519 DCHECK_EQ(MessageLoop::current(), frontend_loop_);
1520 frontend_->OnEncryptionComplete(); 1520 frontend_->OnEncryptionComplete();
1521 } 1521 }
1522 1522
1523 void SyncBackendHost::HandlePassphraseStateChangedOnFrontendLoop( 1523 void SyncBackendHost::HandlePassphraseTypeChangedOnFrontendLoop(
1524 syncer::PassphraseState state) { 1524 syncer::PassphraseType type) {
1525 DCHECK_EQ(MessageLoop::current(), frontend_loop_); 1525 DCHECK_EQ(MessageLoop::current(), frontend_loop_);
1526 DVLOG(1) << "Passphrase state changed to " 1526 DVLOG(1) << "Passphrase type changed to "
1527 << syncer::PassphraseStateToString(state); 1527 << syncer::PassphraseTypeToString(type);
1528 cached_passphrase_state_ = state; 1528 cached_passphrase_type_ = type;
1529 } 1529 }
1530 1530
1531 void SyncBackendHost::HandleStopSyncingPermanentlyOnFrontendLoop() { 1531 void SyncBackendHost::HandleStopSyncingPermanentlyOnFrontendLoop() {
1532 if (!frontend_) 1532 if (!frontend_)
1533 return; 1533 return;
1534 frontend_->OnStopSyncingPermanently(); 1534 frontend_->OnStopSyncingPermanently();
1535 } 1535 }
1536 1536
1537 void SyncBackendHost::HandleConnectionStatusChangeOnFrontendLoop( 1537 void SyncBackendHost::HandleConnectionStatusChangeOnFrontendLoop(
1538 syncer::ConnectionStatus status) { 1538 syncer::ConnectionStatus status) {
1539 if (!frontend_) 1539 if (!frontend_)
1540 return; 1540 return;
1541 1541
1542 DCHECK_EQ(MessageLoop::current(), frontend_loop_); 1542 DCHECK_EQ(MessageLoop::current(), frontend_loop_);
1543 1543
1544 frontend_->OnConnectionStatusChange(status); 1544 frontend_->OnConnectionStatusChange(status);
1545 } 1545 }
1546 1546
1547 void SyncBackendHost::HandleNigoriConfigurationCompletedOnFrontendLoop( 1547 void SyncBackendHost::HandleNigoriConfigurationCompletedOnFrontendLoop(
1548 const syncer::ModelTypeSet failed_configuration_types) { 1548 const syncer::ModelTypeSet failed_configuration_types) {
1549 HandleInitializationCompletedOnFrontendLoop( 1549 HandleInitializationCompletedOnFrontendLoop(
1550 failed_configuration_types.Empty()); 1550 failed_configuration_types.Empty());
1551 } 1551 }
1552 1552
1553 #undef SDVLOG 1553 #undef SDVLOG
1554 1554
1555 #undef SLOG 1555 #undef SLOG
1556 1556
1557 } // namespace browser_sync 1557 } // namespace browser_sync
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698