OLD | NEW |
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 801 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
812 | 812 |
813 SVLOG(1) << "Got snapshot " << snapshot->ToString(); | 813 SVLOG(1) << "Got snapshot " << snapshot->ToString(); |
814 | 814 |
815 const syncable::ModelTypeSet& to_migrate = | 815 const syncable::ModelTypeSet& to_migrate = |
816 snapshot->syncer_status.types_needing_local_migration; | 816 snapshot->syncer_status.types_needing_local_migration; |
817 if (!to_migrate.empty()) | 817 if (!to_migrate.empty()) |
818 host_->frontend_->OnMigrationNeededForTypes(to_migrate); | 818 host_->frontend_->OnMigrationNeededForTypes(to_migrate); |
819 | 819 |
820 // Process any changes to the datatypes we're syncing. | 820 // Process any changes to the datatypes we're syncing. |
821 // TODO(sync): add support for removing types. | 821 // TODO(sync): add support for removing types. |
822 syncable::ModelTypeSet to_add; | 822 if (host_->initialized()) |
823 if (host_->initialized() && | 823 host_->AddExperimentalTypes(); |
824 sync_manager()->ReceivedExperimentalTypes(&to_add)) { | |
825 host_->frontend_->OnDataTypesChanged(to_add); | |
826 } | |
827 | 824 |
828 // If we are waiting for a configuration change, check here to see | 825 // If we are waiting for a configuration change, check here to see |
829 // if this sync cycle has initialized all of the types we've been | 826 // if this sync cycle has initialized all of the types we've been |
830 // waiting for. | 827 // waiting for. |
831 if (host_->pending_download_state_.get()) { | 828 if (host_->pending_download_state_.get()) { |
832 scoped_ptr<PendingConfigureDataTypesState> state( | 829 scoped_ptr<PendingConfigureDataTypesState> state( |
833 host_->pending_download_state_.release()); | 830 host_->pending_download_state_.release()); |
834 DCHECK( | 831 DCHECK( |
835 std::includes(state->types_to_add.begin(), state->types_to_add.end(), | 832 std::includes(state->types_to_add.begin(), state->types_to_add.end(), |
836 state->added_types.begin(), state->added_types.end())); | 833 state->added_types.begin(), state->added_types.end())); |
(...skipping 30 matching lines...) Expand all Loading... |
867 void SyncBackendHost::Core::HandleClearServerDataFailedOnFrontendLoop() { | 864 void SyncBackendHost::Core::HandleClearServerDataFailedOnFrontendLoop() { |
868 if (!host_ || !host_->frontend_) | 865 if (!host_ || !host_->frontend_) |
869 return; | 866 return; |
870 host_->frontend_->OnClearServerDataFailed(); | 867 host_->frontend_->OnClearServerDataFailed(); |
871 } | 868 } |
872 | 869 |
873 void SyncBackendHost::Core::FinishConfigureDataTypesOnFrontendLoop() { | 870 void SyncBackendHost::Core::FinishConfigureDataTypesOnFrontendLoop() { |
874 host_->FinishConfigureDataTypesOnFrontendLoop(); | 871 host_->FinishConfigureDataTypesOnFrontendLoop(); |
875 } | 872 } |
876 | 873 |
| 874 void SyncBackendHost::AddExperimentalTypes() { |
| 875 CHECK(initialized()); |
| 876 syncable::ModelTypeSet to_add; |
| 877 if (core_->sync_manager()->ReceivedExperimentalTypes(&to_add)) |
| 878 frontend_->OnDataTypesChanged(to_add); |
| 879 } |
| 880 |
877 void SyncBackendHost::HandleInitializationCompletedOnFrontendLoop( | 881 void SyncBackendHost::HandleInitializationCompletedOnFrontendLoop( |
878 const WeakHandle<JsBackend>& js_backend, bool success) { | 882 const WeakHandle<JsBackend>& js_backend, bool success) { |
879 DCHECK_NE(NOT_ATTEMPTED, initialization_state_); | 883 DCHECK_NE(NOT_ATTEMPTED, initialization_state_); |
880 if (!frontend_) | 884 if (!frontend_) |
881 return; | 885 return; |
882 | 886 |
883 // We've at least created the sync manager at this point, but if that is all | 887 // We've at least created the sync manager at this point, but if that is all |
884 // we've done we're just beginning the initialization process. | 888 // we've done we're just beginning the initialization process. |
885 if (initialization_state_ == CREATING_SYNC_MANAGER) | 889 if (initialization_state_ == CREATING_SYNC_MANAGER) |
886 initialization_state_ = NOT_INITIALIZED; | 890 initialization_state_ = NOT_INITIALIZED; |
(...skipping 30 matching lines...) Expand all Loading... |
917 case DOWNLOADING_NIGORI: | 921 case DOWNLOADING_NIGORI: |
918 initialization_state_ = REFRESHING_ENCRYPTION; | 922 initialization_state_ = REFRESHING_ENCRYPTION; |
919 RefreshEncryption( | 923 RefreshEncryption( |
920 base::Bind( | 924 base::Bind( |
921 &SyncBackendHost::Core:: | 925 &SyncBackendHost::Core:: |
922 HandleInitializationCompletedOnFrontendLoop, | 926 HandleInitializationCompletedOnFrontendLoop, |
923 core_.get(), js_backend, true)); | 927 core_.get(), js_backend, true)); |
924 break; | 928 break; |
925 case REFRESHING_ENCRYPTION: | 929 case REFRESHING_ENCRYPTION: |
926 initialization_state_ = INITIALIZED; | 930 initialization_state_ = INITIALIZED; |
| 931 // 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 |
| 933 // the frontend to ensure they're visible in the customize screen. |
| 934 AddExperimentalTypes(); |
927 frontend_->OnBackendInitialized(js_backend, true); | 935 frontend_->OnBackendInitialized(js_backend, true); |
928 // Now that we're fully initialized, kick off a server | 936 // Now that we're fully initialized, kick off a server |
929 // reachability check. | 937 // reachability check. |
930 sync_thread_.message_loop()->PostTask( | 938 sync_thread_.message_loop()->PostTask( |
931 FROM_HERE, | 939 FROM_HERE, |
932 NewRunnableMethod( | 940 NewRunnableMethod( |
933 core_.get(), | 941 core_.get(), |
934 &SyncBackendHost::Core::DoCheckServerReachable)); | 942 &SyncBackendHost::Core::DoCheckServerReachable)); |
935 break; | 943 break; |
936 default: | 944 default: |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1036 FROM_HERE, | 1044 FROM_HERE, |
1037 base::Bind(&SyncBackendHost::Core::DoRefreshEncryption, | 1045 base::Bind(&SyncBackendHost::Core::DoRefreshEncryption, |
1038 core_.get(), sync_thread_done_callback)); | 1046 core_.get(), sync_thread_done_callback)); |
1039 } | 1047 } |
1040 | 1048 |
1041 #undef SVLOG | 1049 #undef SVLOG |
1042 | 1050 |
1043 #undef SLOG | 1051 #undef SLOG |
1044 | 1052 |
1045 } // namespace browser_sync | 1053 } // namespace browser_sync |
OLD | NEW |