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

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

Issue 8356026: [Sync] Cache encrypted types info in ProfileSyncService (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Revert to synchronous notifications Created 9 years, 2 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 sync_thread_.message_loop()->PostTask(FROM_HERE, NewRunnableMethod( 298 sync_thread_.message_loop()->PostTask(FROM_HERE, NewRunnableMethod(
299 core_.get(), &SyncBackendHost::Core::DoStartConfiguration, callback)); 299 core_.get(), &SyncBackendHost::Core::DoStartConfiguration, callback));
300 } 300 }
301 301
302 void SyncBackendHost::EnableEncryptEverything() { 302 void SyncBackendHost::EnableEncryptEverything() {
303 sync_thread_.message_loop()->PostTask(FROM_HERE, 303 sync_thread_.message_loop()->PostTask(FROM_HERE,
304 NewRunnableMethod(core_.get(), 304 NewRunnableMethod(core_.get(),
305 &SyncBackendHost::Core::DoEnableEncryptEverything)); 305 &SyncBackendHost::Core::DoEnableEncryptEverything));
306 } 306 }
307 307
308 bool SyncBackendHost::EncryptEverythingEnabled() const {
309 if (initialization_state_ <= NOT_INITIALIZED) {
310 NOTREACHED() << "Cannot check encryption status without first "
311 << "initializing backend.";
312 return false;
313 }
314 return core_->sync_manager()->EncryptEverythingEnabled();
315 }
316
317 syncable::ModelTypeSet SyncBackendHost::GetEncryptedDataTypes() const {
318 DCHECK_GT(initialization_state_, NOT_INITIALIZED);
319 return core_->sync_manager()->GetEncryptedDataTypes();
320 }
321
322 void SyncBackendHost::ActivateDataType( 308 void SyncBackendHost::ActivateDataType(
323 syncable::ModelType type, ModelSafeGroup group, 309 syncable::ModelType type, ModelSafeGroup group,
324 ChangeProcessor* change_processor) { 310 ChangeProcessor* change_processor) {
325 registrar_->ActivateDataType(type, group, change_processor, GetUserShare()); 311 registrar_->ActivateDataType(type, group, change_processor, GetUserShare());
326 } 312 }
327 313
328 void SyncBackendHost::DeactivateDataType(syncable::ModelType type) { 314 void SyncBackendHost::DeactivateDataType(syncable::ModelType type) {
329 registrar_->DeactivateDataType(type); 315 registrar_->DeactivateDataType(type);
330 } 316 }
331 317
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
496 } 482 }
497 483
498 void SyncBackendHost::Core::OnClearServerDataSucceeded() { 484 void SyncBackendHost::Core::OnClearServerDataSucceeded() {
499 if (!sync_loop_) 485 if (!sync_loop_)
500 return; 486 return;
501 DCHECK_EQ(MessageLoop::current(), sync_loop_); 487 DCHECK_EQ(MessageLoop::current(), sync_loop_);
502 host_->frontend_loop_->PostTask(FROM_HERE, NewRunnableMethod(this, 488 host_->frontend_loop_->PostTask(FROM_HERE, NewRunnableMethod(this,
503 &Core::HandleClearServerDataSucceededOnFrontendLoop)); 489 &Core::HandleClearServerDataSucceededOnFrontendLoop));
504 } 490 }
505 491
506 void SyncBackendHost::Core::OnEncryptionComplete( 492 void SyncBackendHost::Core::OnEncryptedTypesChanged(
507 const syncable::ModelTypeSet& encrypted_types) { 493 const syncable::ModelTypeSet& encrypted_types,
494 bool encrypt_everything) {
508 if (!sync_loop_) 495 if (!sync_loop_)
509 return; 496 return;
510 DCHECK_EQ(MessageLoop::current(), sync_loop_); 497 DCHECK_EQ(MessageLoop::current(), sync_loop_);
498 // NOTE: We're in a transaction.
511 host_->frontend_loop_->PostTask( 499 host_->frontend_loop_->PostTask(
512 FROM_HERE, 500 FROM_HERE,
513 NewRunnableMethod(this, &Core::NotifyEncryptionComplete, 501 NewRunnableMethod(this, &Core::NotifyEncryptedTypesChanged,
Nicolas Zea 2011/10/21 14:29:07 base::bind
akalin 2011/10/22 03:28:38 Done.
514 encrypted_types)); 502 encrypted_types, encrypt_everything));
503 }
504
505 void SyncBackendHost::Core::OnEncryptionComplete() {
506 if (!sync_loop_)
507 return;
508 DCHECK_EQ(MessageLoop::current(), sync_loop_);
509 // NOTE: We're in a transaction.
510 host_->frontend_loop_->PostTask(
511 FROM_HERE,
512 NewRunnableMethod(this, &Core::NotifyEncryptionComplete));
515 } 513 }
516 514
517 void SyncBackendHost::Core::OnActionableError( 515 void SyncBackendHost::Core::OnActionableError(
518 const browser_sync::SyncProtocolError& sync_error) { 516 const browser_sync::SyncProtocolError& sync_error) {
519 if (!sync_loop_) 517 if (!sync_loop_)
520 return; 518 return;
521 DCHECK_EQ(MessageLoop::current(), sync_loop_); 519 DCHECK_EQ(MessageLoop::current(), sync_loop_);
522 host_->frontend_loop_->PostTask( 520 host_->frontend_loop_->PostTask(
523 FROM_HERE, 521 FROM_HERE,
524 NewRunnableMethod(this, &Core::HandleActionableErrorEventOnFrontendLoop, 522 NewRunnableMethod(this, &Core::HandleActionableErrorEventOnFrontendLoop,
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
787 if (!host_) 785 if (!host_)
788 return; 786 return;
789 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 787 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
790 TokenAvailableDetails details(GaiaConstants::kSyncService, token); 788 TokenAvailableDetails details(GaiaConstants::kSyncService, token);
791 content::NotificationService::current()->Notify( 789 content::NotificationService::current()->Notify(
792 chrome::NOTIFICATION_TOKEN_UPDATED, 790 chrome::NOTIFICATION_TOKEN_UPDATED,
793 content::Source<Profile>(host_->profile_), 791 content::Source<Profile>(host_->profile_),
794 content::Details<const TokenAvailableDetails>(&details)); 792 content::Details<const TokenAvailableDetails>(&details));
795 } 793 }
796 794
797 void SyncBackendHost::Core::NotifyEncryptionComplete( 795 void SyncBackendHost::Core::NotifyEncryptedTypesChanged(
798 const syncable::ModelTypeSet& encrypted_types) { 796 const syncable::ModelTypeSet& encrypted_types,
797 bool encrypt_everything) {
799 if (!host_) 798 if (!host_)
800 return; 799 return;
801 DCHECK_EQ(MessageLoop::current(), host_->frontend_loop_); 800 DCHECK_EQ(MessageLoop::current(), host_->frontend_loop_);
802 host_->frontend_->OnEncryptionComplete(encrypted_types); 801 host_->frontend_->OnEncryptedTypesChanged(
802 encrypted_types, encrypt_everything);
803 }
804
805 void SyncBackendHost::Core::NotifyEncryptionComplete() {
806 if (!host_)
807 return;
808 DCHECK_EQ(MessageLoop::current(), host_->frontend_loop_);
809 host_->frontend_->OnEncryptionComplete();
803 } 810 }
804 811
805 void SyncBackendHost::Core::HandleSyncCycleCompletedOnFrontendLoop( 812 void SyncBackendHost::Core::HandleSyncCycleCompletedOnFrontendLoop(
806 SyncSessionSnapshot* snapshot) { 813 SyncSessionSnapshot* snapshot) {
807 if (!host_ || !host_->frontend_) 814 if (!host_ || !host_->frontend_)
808 return; 815 return;
809 DCHECK_EQ(MessageLoop::current(), host_->frontend_loop_); 816 DCHECK_EQ(MessageLoop::current(), host_->frontend_loop_);
810 817
811 host_->last_snapshot_.reset(snapshot); 818 host_->last_snapshot_.reset(snapshot);
812 819
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
913 syncable::ModelTypeSet(), 920 syncable::ModelTypeSet(),
914 sync_api::CONFIGURE_REASON_NEW_CLIENT, 921 sync_api::CONFIGURE_REASON_NEW_CLIENT,
915 base::Bind( 922 base::Bind(
916 &SyncBackendHost::Core:: 923 &SyncBackendHost::Core::
917 HandleInitializationCompletedOnFrontendLoop, 924 HandleInitializationCompletedOnFrontendLoop,
918 core_.get(), js_backend), 925 core_.get(), js_backend),
919 true); 926 true);
920 break; 927 break;
921 case DOWNLOADING_NIGORI: 928 case DOWNLOADING_NIGORI:
922 initialization_state_ = REFRESHING_ENCRYPTION; 929 initialization_state_ = REFRESHING_ENCRYPTION;
930 // Should trigger an OnEncryptedTypesChanged() notification.
923 RefreshEncryption( 931 RefreshEncryption(
924 base::Bind( 932 base::Bind(
925 &SyncBackendHost::Core:: 933 &SyncBackendHost::Core::
926 HandleInitializationCompletedOnFrontendLoop, 934 HandleInitializationCompletedOnFrontendLoop,
927 core_.get(), js_backend, true)); 935 core_.get(), js_backend, true));
928 break; 936 break;
929 case REFRESHING_ENCRYPTION: 937 case REFRESHING_ENCRYPTION:
930 initialization_state_ = INITIALIZED; 938 initialization_state_ = INITIALIZED;
931 // Now that we've downloaded the nigori node, we can see if there are any 939 // Now that we've downloaded the nigori node, we can see if there are any
932 // experimental types to enable. This should be done before we inform 940 // experimental types to enable. This should be done before we inform
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
1044 FROM_HERE, 1052 FROM_HERE,
1045 base::Bind(&SyncBackendHost::Core::DoRefreshEncryption, 1053 base::Bind(&SyncBackendHost::Core::DoRefreshEncryption,
1046 core_.get(), sync_thread_done_callback)); 1054 core_.get(), sync_thread_done_callback));
1047 } 1055 }
1048 1056
1049 #undef SVLOG 1057 #undef SVLOG
1050 1058
1051 #undef SLOG 1059 #undef SLOG
1052 1060
1053 } // namespace browser_sync 1061 } // namespace browser_sync
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698