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

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

Issue 10837231: sync: add InternalComponentsFactory::Switches to simplify passing switches to internal components. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: pass switches in test_profile_sync_service.cc Created 8 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) 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 397 matching lines...) Expand 10 before | Expand all | Expand 10 after
408 DCHECK(frontend); 408 DCHECK(frontend);
409 409
410 registrar_.reset(new SyncBackendRegistrar(name_, 410 registrar_.reset(new SyncBackendRegistrar(name_,
411 profile_, 411 profile_,
412 sync_thread_.message_loop())); 412 sync_thread_.message_loop()));
413 syncer::ModelSafeRoutingInfo routing_info; 413 syncer::ModelSafeRoutingInfo routing_info;
414 std::vector<syncer::ModelSafeWorker*> workers; 414 std::vector<syncer::ModelSafeWorker*> workers;
415 registrar_->GetModelSafeRoutingInfo(&routing_info); 415 registrar_->GetModelSafeRoutingInfo(&routing_info);
416 registrar_->GetWorkers(&workers); 416 registrar_->GetWorkers(&workers);
417 417
418 InternalComponentsFactory::Switches factory_switches = {
419 InternalComponentsFactory::ENCRYPTION_LEGACY,
420 InternalComponentsFactory::BACKOFF_NORMAL
421 };
422
423 CommandLine* cl = CommandLine::ForCurrentProcess();
424 if (cl->HasSwitch(switches::kSyncKeystoreEncryption)) {
rlarocque 2012/08/14 19:54:07 nit: I think this would be more readable if this w
tim (not reviewing) 2012/08/14 20:20:51 The reason I did it this way is because it is most
rlarocque 2012/08/14 21:13:04 I'd rather not hide the processing inside a functi
425 factory_switches.encryption_method =
426 InternalComponentsFactoryImpl::ENCRYPTION_KEYSTORE;
427 }
428 if (cl->HasSwitch(switches::kSyncShortInitialRetryOverride)) {
rlarocque 2012/08/14 19:54:07 same nit here.
429 factory_switches.backoff_override =
430 InternalComponentsFactoryImpl::BACKOFF_SHORT_INITIAL_RETRY_OVERRIDE;
431 }
432
418 initialization_state_ = CREATING_SYNC_MANAGER; 433 initialization_state_ = CREATING_SYNC_MANAGER;
419 InitCore(DoInitializeOptions( 434 InitCore(DoInitializeOptions(
420 sync_thread_.message_loop(), 435 sync_thread_.message_loop(),
421 registrar_.get(), 436 registrar_.get(),
422 routing_info, 437 routing_info,
423 workers, 438 workers,
424 &extensions_activity_monitor_, 439 &extensions_activity_monitor_,
425 event_handler, 440 event_handler,
426 sync_service_url, 441 sync_service_url,
427 base::Bind(&MakeHttpBridgeFactory, 442 base::Bind(&MakeHttpBridgeFactory,
428 make_scoped_refptr(profile_->GetRequestContext())), 443 make_scoped_refptr(profile_->GetRequestContext())),
429 credentials, 444 credentials,
430 chrome_sync_notification_bridge_.get(), 445 chrome_sync_notification_bridge_.get(),
431 &sync_notifier_factory_, 446 &sync_notifier_factory_,
432 sync_manager_factory, 447 sync_manager_factory,
433 delete_sync_data_folder, 448 delete_sync_data_folder,
434 sync_prefs_->GetEncryptionBootstrapToken(), 449 sync_prefs_->GetEncryptionBootstrapToken(),
435 sync_prefs_->GetKeystoreEncryptionBootstrapToken(), 450 sync_prefs_->GetKeystoreEncryptionBootstrapToken(),
436 new InternalComponentsFactoryImpl(), 451 new InternalComponentsFactoryImpl(factory_switches),
437 unrecoverable_error_handler, 452 unrecoverable_error_handler,
438 report_unrecoverable_error_function)); 453 report_unrecoverable_error_function));
439 } 454 }
440 455
441 void SyncBackendHost::UpdateCredentials(const SyncCredentials& credentials) { 456 void SyncBackendHost::UpdateCredentials(const SyncCredentials& credentials) {
442 sync_thread_.message_loop()->PostTask(FROM_HERE, 457 sync_thread_.message_loop()->PostTask(FROM_HERE,
443 base::Bind(&SyncBackendHost::Core::DoUpdateCredentials, core_.get(), 458 base::Bind(&SyncBackendHost::Core::DoUpdateCredentials, core_.get(),
444 credentials)); 459 credentials));
445 } 460 }
446 461
(...skipping 637 matching lines...) Expand 10 before | Expand all | Expand 10 after
1084 options.make_http_bridge_factory_fn.Run().Pass(), 1099 options.make_http_bridge_factory_fn.Run().Pass(),
1085 options.workers, 1100 options.workers,
1086 options.extensions_activity_monitor, 1101 options.extensions_activity_monitor,
1087 options.registrar /* as SyncManager::ChangeDelegate */, 1102 options.registrar /* as SyncManager::ChangeDelegate */,
1088 options.credentials, 1103 options.credentials,
1089 scoped_ptr<syncer::SyncNotifier>(new BridgedSyncNotifier( 1104 scoped_ptr<syncer::SyncNotifier>(new BridgedSyncNotifier(
1090 options.chrome_sync_notification_bridge, 1105 options.chrome_sync_notification_bridge,
1091 options.sync_notifier_factory->CreateSyncNotifier())), 1106 options.sync_notifier_factory->CreateSyncNotifier())),
1092 options.restored_key_for_bootstrapping, 1107 options.restored_key_for_bootstrapping,
1093 options.restored_keystore_key_for_bootstrapping, 1108 options.restored_keystore_key_for_bootstrapping,
1094 CommandLine::ForCurrentProcess()->HasSwitch(
1095 switches::kSyncKeystoreEncryption),
1096 scoped_ptr<InternalComponentsFactory>( 1109 scoped_ptr<InternalComponentsFactory>(
1097 options.internal_components_factory), 1110 options.internal_components_factory),
1098 &encryptor_, 1111 &encryptor_,
1099 options.unrecoverable_error_handler, 1112 options.unrecoverable_error_handler,
1100 options.report_unrecoverable_error_function); 1113 options.report_unrecoverable_error_function);
1101 1114
1102 // |sync_manager_| may end up being NULL here in tests (in 1115 // |sync_manager_| may end up being NULL here in tests (in
1103 // synchronous initialization mode). 1116 // synchronous initialization mode).
1104 // 1117 //
1105 // TODO(akalin): Fix this behavior (see http://crbug.com/140354). 1118 // TODO(akalin): Fix this behavior (see http://crbug.com/140354).
(...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after
1542 FROM_HERE, 1555 FROM_HERE,
1543 base::Bind(&SyncBackendHost::Core::DoRefreshNigori, 1556 base::Bind(&SyncBackendHost::Core::DoRefreshNigori,
1544 core_.get(), sync_thread_done_callback)); 1557 core_.get(), sync_thread_done_callback));
1545 } 1558 }
1546 1559
1547 #undef SDVLOG 1560 #undef SDVLOG
1548 1561
1549 #undef SLOG 1562 #undef SLOG
1550 1563
1551 } // namespace browser_sync 1564 } // namespace browser_sync
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698