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

Side by Side Diff: components/browser_sync/profile_sync_service.cc

Issue 2401083003: [Sync] Adding integration tests for USS encryption and fixing a worker bug. (Closed)
Patch Set: Updated for rkaplow@'s comments. Created 4 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
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 "components/browser_sync/profile_sync_service.h" 5 #include "components/browser_sync/profile_sync_service.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <cstddef> 9 #include <cstddef>
10 #include <map> 10 #include <map>
(...skipping 1117 matching lines...) Expand 10 before | Expand all | Expand 10 after
1128 if (HasUnrecoverableError()) { 1128 if (HasUnrecoverableError()) {
1129 // When unrecoverable error is detected we post a task to shutdown the 1129 // When unrecoverable error is detected we post a task to shutdown the
1130 // backend. The task might not have executed yet. 1130 // backend. The task might not have executed yet.
1131 return; 1131 return;
1132 } 1132 }
1133 1133
1134 DVLOG(1) << "Passphrase required with reason: " 1134 DVLOG(1) << "Passphrase required with reason: "
1135 << syncer::PassphraseRequiredReasonToString(reason); 1135 << syncer::PassphraseRequiredReasonToString(reason);
1136 passphrase_required_reason_ = reason; 1136 passphrase_required_reason_ = reason;
1137 1137
1138 // TODO(stanisc): http://crbug.com/351005: Does this support USS types?
1139 const syncer::ModelTypeSet types = GetPreferredDataTypes(); 1138 const syncer::ModelTypeSet types = GetPreferredDataTypes();
1140 if (data_type_manager_) { 1139 if (data_type_manager_) {
1141 // Reconfigure without the encrypted types (excluded implicitly via the 1140 // Reconfigure without the encrypted types (excluded implicitly via the
1142 // failed datatypes handler). 1141 // failed datatypes handler).
1143 data_type_manager_->Configure(types, syncer::CONFIGURE_REASON_CRYPTO); 1142 data_type_manager_->Configure(types, syncer::CONFIGURE_REASON_CRYPTO);
1144 } 1143 }
1145 1144
1146 // Notify observers that the passphrase status may have changed. 1145 // Notify observers that the passphrase status may have changed.
1147 NotifyObservers(); 1146 NotifyObservers();
1148 } 1147 }
1149 1148
1150 void ProfileSyncService::OnPassphraseAccepted() { 1149 void ProfileSyncService::OnPassphraseAccepted() {
1151 DVLOG(1) << "Received OnPassphraseAccepted."; 1150 DVLOG(1) << "Received OnPassphraseAccepted.";
1152 1151
1153 // If the pending keys were resolved via keystore, it's possible we never 1152 // If the pending keys were resolved via keystore, it's possible we never
1154 // consumed our cached passphrase. Clear it now. 1153 // consumed our cached passphrase. Clear it now.
1155 if (!cached_passphrase_.empty()) 1154 if (!cached_passphrase_.empty())
1156 cached_passphrase_.clear(); 1155 cached_passphrase_.clear();
1157 1156
1158 // Reset passphrase_required_reason_ since we know we no longer require the 1157 // Reset passphrase_required_reason_ since we know we no longer require the
1159 // passphrase. We do this here rather than down in ResolvePassphraseRequired() 1158 // passphrase. We do this here rather than down in ResolvePassphraseRequired()
1160 // because that can be called by OnPassphraseRequired() if no encrypted data 1159 // because that can be called by OnPassphraseRequired() if no encrypted data
1161 // types are enabled, and we don't want to clobber the true passphrase error. 1160 // types are enabled, and we don't want to clobber the true passphrase error.
1162 passphrase_required_reason_ = syncer::REASON_PASSPHRASE_NOT_REQUIRED; 1161 passphrase_required_reason_ = syncer::REASON_PASSPHRASE_NOT_REQUIRED;
1163 1162
1164 // Make sure the data types that depend on the passphrase are started at 1163 // Make sure the data types that depend on the passphrase are started at
1165 // this time. 1164 // this time.
1166 // TODO(stanisc): http://crbug.com/351005: Does this support USS types?
1167 const syncer::ModelTypeSet types = GetPreferredDataTypes(); 1165 const syncer::ModelTypeSet types = GetPreferredDataTypes();
1168 if (data_type_manager_) { 1166 if (data_type_manager_) {
1169 // Re-enable any encrypted types if necessary. 1167 // Re-enable any encrypted types if necessary.
1170 data_type_manager_->Configure(types, syncer::CONFIGURE_REASON_CRYPTO); 1168 data_type_manager_->Configure(types, syncer::CONFIGURE_REASON_CRYPTO);
1171 } 1169 }
1172 1170
1173 NotifyObservers(); 1171 NotifyObservers();
1174 } 1172 }
1175 1173
1176 void ProfileSyncService::OnEncryptedTypesChanged( 1174 void ProfileSyncService::OnEncryptedTypesChanged(
(...skipping 1040 matching lines...) Expand 10 before | Expand all | Expand 10 after
2217 if (awaiting_types_.Empty()) { 2215 if (awaiting_types_.Empty()) {
2218 callback_.Run(std::move(result_accumulator_)); 2216 callback_.Run(std::move(result_accumulator_));
2219 callback_.Reset(); 2217 callback_.Reset();
2220 } 2218 }
2221 } 2219 }
2222 2220
2223 } // namespace 2221 } // namespace
2224 2222
2225 void ProfileSyncService::GetAllNodes( 2223 void ProfileSyncService::GetAllNodes(
2226 const base::Callback<void(std::unique_ptr<base::ListValue>)>& callback) { 2224 const base::Callback<void(std::unique_ptr<base::ListValue>)>& callback) {
2227 // TODO(stanisc): crbug.com/328606: Make this work for USS datatypes.
2228 ModelTypeSet all_types = GetActiveDataTypes(); 2225 ModelTypeSet all_types = GetActiveDataTypes();
2229 all_types.PutAll(syncer::ControlTypes()); 2226 all_types.PutAll(syncer::ControlTypes());
2230 scoped_refptr<GetAllNodesRequestHelper> helper = 2227 scoped_refptr<GetAllNodesRequestHelper> helper =
2231 new GetAllNodesRequestHelper(all_types, callback); 2228 new GetAllNodesRequestHelper(all_types, callback);
2232 2229
2233 if (!backend_initialized_) { 2230 if (!backend_initialized_) {
2234 // If there's no backend available to fulfill the request, handle it here. 2231 // If there's no backend available to fulfill the request, handle it here.
2235 for (ModelTypeSet::Iterator it = all_types.First(); it.Good(); it.Inc()) { 2232 for (ModelTypeSet::Iterator it = all_types.First(); it.Good(); it.Inc()) {
2236 helper->OnReceivedNodesForType(it.Get(), 2233 helper->OnReceivedNodesForType(it.Get(),
2237 base::MakeUnique<base::ListValue>()); 2234 base::MakeUnique<base::ListValue>());
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
2499 2496
2500 DCHECK(startup_controller_->IsSetupInProgress()); 2497 DCHECK(startup_controller_->IsSetupInProgress());
2501 startup_controller_->SetSetupInProgress(false); 2498 startup_controller_->SetSetupInProgress(false);
2502 2499
2503 if (IsBackendInitialized()) 2500 if (IsBackendInitialized())
2504 ReconfigureDatatypeManager(); 2501 ReconfigureDatatypeManager();
2505 NotifyObservers(); 2502 NotifyObservers();
2506 } 2503 }
2507 2504
2508 } // namespace browser_sync 2505 } // namespace browser_sync
OLDNEW
« no previous file with comments | « chrome/browser/sync/test/integration/two_client_uss_sync_test.cc ('k') | components/sync/engine/sync_encryption_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698