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

Side by Side Diff: chrome/browser/sync/profile_sync_service.cc

Issue 7511004: [Sync] Refactor data type configuration/activation/deactivation (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix tests, address comments Created 9 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) 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 "chrome/browser/sync/profile_sync_service.h" 5 #include "chrome/browser/sync/profile_sync_service.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <map> 8 #include <map>
9 #include <ostream> 9 #include <ostream>
10 #include <set> 10 #include <set>
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 GaiaConstants::kSyncService); 342 GaiaConstants::kSyncService);
343 return credentials; 343 return credentials;
344 } 344 }
345 345
346 void ProfileSyncService::InitializeBackend(bool delete_sync_data_folder) { 346 void ProfileSyncService::InitializeBackend(bool delete_sync_data_folder) {
347 if (!backend_.get()) { 347 if (!backend_.get()) {
348 NOTREACHED(); 348 NOTREACHED();
349 return; 349 return;
350 } 350 }
351 351
352 syncable::ModelTypeSet types; 352 syncable::ModelTypeSet initial_types;
353 // If sync setup hasn't finished, we don't want to initialize routing info 353 // If sync setup hasn't finished, we don't want to initialize routing info
354 // for any data types so that we don't download updates for types that the 354 // for any data types so that we don't download updates for types that the
355 // user chooses not to sync on the first DownloadUpdatesCommand. 355 // user chooses not to sync on the first DownloadUpdatesCommand.
356 if (HasSyncSetupCompleted()) { 356 if (HasSyncSetupCompleted()) {
357 GetPreferredDataTypes(&types); 357 GetPreferredDataTypes(&initial_types);
358 } 358 }
359 359
360 SyncCredentials credentials = GetCredentials(); 360 SyncCredentials credentials = GetCredentials();
361 361
362 scoped_refptr<net::URLRequestContextGetter> request_context_getter( 362 scoped_refptr<net::URLRequestContextGetter> request_context_getter(
363 profile_->GetRequestContext()); 363 profile_->GetRequestContext());
364 364
365 backend_->Initialize( 365 backend_->Initialize(
366 this, 366 this,
367 WeakHandle<JsEventHandler>(sync_js_controller_.AsWeakPtr()), 367 WeakHandle<JsEventHandler>(sync_js_controller_.AsWeakPtr()),
368 sync_service_url_, 368 sync_service_url_,
369 types, 369 initial_types,
370 credentials, 370 credentials,
371 delete_sync_data_folder); 371 delete_sync_data_folder);
372 } 372 }
373 373
374 void ProfileSyncService::CreateBackend() { 374 void ProfileSyncService::CreateBackend() {
375 backend_.reset(new SyncBackendHost(profile_)); 375 backend_.reset(new SyncBackendHost(profile_));
376 } 376 }
377 377
378 bool ProfileSyncService::IsEncryptedDatatypeEnabled() const { 378 bool ProfileSyncService::IsEncryptedDatatypeEnabled() const {
379 if (HasPendingEncryptedTypes()) 379 if (HasPendingEncryptedTypes())
(...skipping 792 matching lines...) Expand 10 before | Expand all | Expand 10 after
1172 void ProfileSyncService::GetModelSafeRoutingInfo( 1172 void ProfileSyncService::GetModelSafeRoutingInfo(
1173 browser_sync::ModelSafeRoutingInfo* out) { 1173 browser_sync::ModelSafeRoutingInfo* out) {
1174 if (backend_.get() && backend_initialized_) { 1174 if (backend_.get() && backend_initialized_) {
1175 backend_->GetModelSafeRoutingInfo(out); 1175 backend_->GetModelSafeRoutingInfo(out);
1176 } else { 1176 } else {
1177 NOTREACHED(); 1177 NOTREACHED();
1178 } 1178 }
1179 } 1179 }
1180 1180
1181 void ProfileSyncService::ActivateDataType( 1181 void ProfileSyncService::ActivateDataType(
1182 DataTypeController* data_type_controller, 1182 syncable::ModelType type, browser_sync::ModelSafeGroup group,
1183 ChangeProcessor* change_processor) { 1183 ChangeProcessor* change_processor) {
1184 if (!backend_.get()) { 1184 if (!backend_.get()) {
1185 NOTREACHED(); 1185 NOTREACHED();
1186 return; 1186 return;
1187 } 1187 }
1188 DCHECK(backend_initialized_); 1188 DCHECK(backend_initialized_);
1189 backend_->ActivateDataType(data_type_controller, change_processor); 1189 backend_->ActivateDataType(type, group, change_processor);
1190 } 1190 }
1191 1191
1192 void ProfileSyncService::DeactivateDataType( 1192 void ProfileSyncService::DeactivateDataType(syncable::ModelType type) {
1193 DataTypeController* data_type_controller,
1194 ChangeProcessor* change_processor) {
1195 if (!backend_.get()) 1193 if (!backend_.get())
1196 return; 1194 return;
1197 backend_->DeactivateDataType(data_type_controller, change_processor); 1195 backend_->DeactivateDataType(type);
1198 } 1196 }
1199 1197
1200 void ProfileSyncService::SetPassphrase(const std::string& passphrase, 1198 void ProfileSyncService::SetPassphrase(const std::string& passphrase,
1201 bool is_explicit, 1199 bool is_explicit,
1202 bool is_creation) { 1200 bool is_creation) {
1203 if (ShouldPushChanges() || IsPassphraseRequired()) { 1201 if (ShouldPushChanges() || IsPassphraseRequired()) {
1204 VLOG(1) << "Setting " << (is_explicit ? "explicit" : "implicit") 1202 VLOG(1) << "Setting " << (is_explicit ? "explicit" : "implicit")
1205 << " passphrase" << (is_creation ? " for creation" : ""); 1203 << " passphrase" << (is_creation ? " for creation" : "");
1206 backend_->SetPassphrase(passphrase, is_explicit); 1204 backend_->SetPassphrase(passphrase, is_explicit);
1207 } else { 1205 } else {
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
1403 // is initialized, all enabled data types are consistent with one 1401 // is initialized, all enabled data types are consistent with one
1404 // another, and no unrecoverable error has transpired. 1402 // another, and no unrecoverable error has transpired.
1405 if (unrecoverable_error_detected_) 1403 if (unrecoverable_error_detected_)
1406 return false; 1404 return false;
1407 1405
1408 if (!data_type_manager_.get()) 1406 if (!data_type_manager_.get())
1409 return false; 1407 return false;
1410 1408
1411 return data_type_manager_->state() == DataTypeManager::CONFIGURED; 1409 return data_type_manager_->state() == DataTypeManager::CONFIGURED;
1412 } 1410 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698