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

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

Issue 10701046: sync: Remove SyncManager::TestingMode in favour of InternalComponentsFactory. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: now with more scope Created 8 years, 5 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 24 matching lines...) Expand all
35 #include "chrome/common/net/gaia/gaia_constants.h" 35 #include "chrome/common/net/gaia/gaia_constants.h"
36 #include "content/public/browser/browser_thread.h" 36 #include "content/public/browser/browser_thread.h"
37 #include "content/public/browser/notification_service.h" 37 #include "content/public/browser/notification_service.h"
38 #include "content/public/common/content_client.h" 38 #include "content/public/common/content_client.h"
39 #include "jingle/notifier/base/notification_method.h" 39 #include "jingle/notifier/base/notification_method.h"
40 #include "jingle/notifier/base/notifier_options.h" 40 #include "jingle/notifier/base/notifier_options.h"
41 #include "net/base/host_port_pair.h" 41 #include "net/base/host_port_pair.h"
42 #include "net/url_request/url_request_context_getter.h" 42 #include "net/url_request/url_request_context_getter.h"
43 #include "sync/internal_api/public/base_transaction.h" 43 #include "sync/internal_api/public/base_transaction.h"
44 #include "sync/internal_api/public/engine/model_safe_worker.h" 44 #include "sync/internal_api/public/engine/model_safe_worker.h"
45 #include "sync/internal_api/public/internal_components_factory_impl.h"
45 #include "sync/internal_api/public/http_bridge.h" 46 #include "sync/internal_api/public/http_bridge.h"
46 #include "sync/internal_api/public/read_transaction.h" 47 #include "sync/internal_api/public/read_transaction.h"
47 #include "sync/internal_api/public/sync_manager_factory.h" 48 #include "sync/internal_api/public/sync_manager_factory.h"
48 #include "sync/internal_api/public/util/experiments.h" 49 #include "sync/internal_api/public/util/experiments.h"
49 #include "sync/notifier/sync_notifier.h" 50 #include "sync/notifier/sync_notifier.h"
50 #include "sync/protocol/encryption.pb.h" 51 #include "sync/protocol/encryption.pb.h"
51 #include "sync/protocol/sync.pb.h" 52 #include "sync/protocol/sync.pb.h"
52 #include "sync/util/nigori.h" 53 #include "sync/util/nigori.h"
53 54
54 static const int kSaveChangesIntervalSeconds = 10; 55 static const int kSaveChangesIntervalSeconds = 10;
55 static const FilePath::CharType kSyncDataFolderName[] = 56 static const FilePath::CharType kSyncDataFolderName[] =
56 FILE_PATH_LITERAL("Sync Data"); 57 FILE_PATH_LITERAL("Sync Data");
57 58
58 typedef TokenService::TokenAvailableDetails TokenAvailableDetails; 59 typedef TokenService::TokenAvailableDetails TokenAvailableDetails;
59 60
60 typedef GoogleServiceAuthError AuthError; 61 typedef GoogleServiceAuthError AuthError;
61 62
62 namespace browser_sync { 63 namespace browser_sync {
63 64
64 using content::BrowserThread; 65 using content::BrowserThread;
66 using syncer::InternalComponentsFactory;
67 using syncer::InternalComponentsFactoryImpl;
65 using syncer::sessions::SyncSessionSnapshot; 68 using syncer::sessions::SyncSessionSnapshot;
66 using syncer::SyncCredentials; 69 using syncer::SyncCredentials;
67 70
68 // Helper macros to log with the syncer thread name; useful when there 71 // Helper macros to log with the syncer thread name; useful when there
69 // are multiple syncers involved. 72 // are multiple syncers involved.
70 73
71 #define SLOG(severity) LOG(severity) << name_ << ": " 74 #define SLOG(severity) LOG(severity) << name_ << ": "
72 75
73 #define SDVLOG(verbose_level) DVLOG(verbose_level) << name_ << ": " 76 #define SDVLOG(verbose_level) DVLOG(verbose_level) << name_ << ": "
74 77
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 event_handler, 406 event_handler,
404 sync_service_url, 407 sync_service_url,
405 base::Bind(&MakeHttpBridgeFactory, 408 base::Bind(&MakeHttpBridgeFactory,
406 make_scoped_refptr(profile_->GetRequestContext())), 409 make_scoped_refptr(profile_->GetRequestContext())),
407 credentials, 410 credentials,
408 &chrome_sync_notification_bridge_, 411 &chrome_sync_notification_bridge_,
409 &sync_notifier_factory_, 412 &sync_notifier_factory_,
410 sync_manager_factory, 413 sync_manager_factory,
411 delete_sync_data_folder, 414 delete_sync_data_folder,
412 sync_prefs_->GetEncryptionBootstrapToken(), 415 sync_prefs_->GetEncryptionBootstrapToken(),
413 syncer::SyncManager::NON_TEST, 416 new InternalComponentsFactoryImpl(),
414 unrecoverable_error_handler, 417 unrecoverable_error_handler,
415 report_unrecoverable_error_function)); 418 report_unrecoverable_error_function));
416 } 419 }
417 420
418 void SyncBackendHost::UpdateCredentials(const SyncCredentials& credentials) { 421 void SyncBackendHost::UpdateCredentials(const SyncCredentials& credentials) {
419 sync_thread_.message_loop()->PostTask(FROM_HERE, 422 sync_thread_.message_loop()->PostTask(FROM_HERE,
420 base::Bind(&SyncBackendHost::Core::DoUpdateCredentials, core_.get(), 423 base::Bind(&SyncBackendHost::Core::DoUpdateCredentials, core_.get(),
421 credentials)); 424 credentials));
422 } 425 }
423 426
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after
772 syncer::ExtensionsActivityMonitor* extensions_activity_monitor, 775 syncer::ExtensionsActivityMonitor* extensions_activity_monitor,
773 const syncer::WeakHandle<syncer::JsEventHandler>& event_handler, 776 const syncer::WeakHandle<syncer::JsEventHandler>& event_handler,
774 const GURL& service_url, 777 const GURL& service_url,
775 MakeHttpBridgeFactoryFn make_http_bridge_factory_fn, 778 MakeHttpBridgeFactoryFn make_http_bridge_factory_fn,
776 const syncer::SyncCredentials& credentials, 779 const syncer::SyncCredentials& credentials,
777 ChromeSyncNotificationBridge* chrome_sync_notification_bridge, 780 ChromeSyncNotificationBridge* chrome_sync_notification_bridge,
778 syncer::SyncNotifierFactory* sync_notifier_factory, 781 syncer::SyncNotifierFactory* sync_notifier_factory,
779 syncer::SyncManagerFactory* sync_manager_factory, 782 syncer::SyncManagerFactory* sync_manager_factory,
780 bool delete_sync_data_folder, 783 bool delete_sync_data_folder,
781 const std::string& restored_key_for_bootstrapping, 784 const std::string& restored_key_for_bootstrapping,
782 syncer::SyncManager::TestingMode testing_mode, 785 InternalComponentsFactory* internal_components_factory,
783 syncer::UnrecoverableErrorHandler* unrecoverable_error_handler, 786 syncer::UnrecoverableErrorHandler* unrecoverable_error_handler,
784 syncer::ReportUnrecoverableErrorFunction 787 syncer::ReportUnrecoverableErrorFunction
785 report_unrecoverable_error_function) 788 report_unrecoverable_error_function)
786 : sync_loop(sync_loop), 789 : sync_loop(sync_loop),
787 registrar(registrar), 790 registrar(registrar),
788 routing_info(routing_info), 791 routing_info(routing_info),
789 workers(workers), 792 workers(workers),
790 extensions_activity_monitor(extensions_activity_monitor), 793 extensions_activity_monitor(extensions_activity_monitor),
791 event_handler(event_handler), 794 event_handler(event_handler),
792 service_url(service_url), 795 service_url(service_url),
793 make_http_bridge_factory_fn(make_http_bridge_factory_fn), 796 make_http_bridge_factory_fn(make_http_bridge_factory_fn),
794 credentials(credentials), 797 credentials(credentials),
795 chrome_sync_notification_bridge(chrome_sync_notification_bridge), 798 chrome_sync_notification_bridge(chrome_sync_notification_bridge),
796 sync_notifier_factory(sync_notifier_factory), 799 sync_notifier_factory(sync_notifier_factory),
797 sync_manager_factory(sync_manager_factory), 800 sync_manager_factory(sync_manager_factory),
798 delete_sync_data_folder(delete_sync_data_folder), 801 delete_sync_data_folder(delete_sync_data_folder),
799 restored_key_for_bootstrapping(restored_key_for_bootstrapping), 802 restored_key_for_bootstrapping(restored_key_for_bootstrapping),
800 testing_mode(testing_mode), 803 internal_components_factory(internal_components_factory),
801 unrecoverable_error_handler(unrecoverable_error_handler), 804 unrecoverable_error_handler(unrecoverable_error_handler),
802 report_unrecoverable_error_function( 805 report_unrecoverable_error_function(
803 report_unrecoverable_error_function) { 806 report_unrecoverable_error_function) {
804 } 807 }
805 808
806 SyncBackendHost::DoInitializeOptions::~DoInitializeOptions() {} 809 SyncBackendHost::DoInitializeOptions::~DoInitializeOptions() {}
807 810
808 SyncBackendHost::Core::Core(const std::string& name, 811 SyncBackendHost::Core::Core(const std::string& name,
809 const FilePath& sync_data_folder_path, 812 const FilePath& sync_data_folder_path,
810 const base::WeakPtr<SyncBackendHost>& backend) 813 const base::WeakPtr<SyncBackendHost>& backend)
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
973 options.make_http_bridge_factory_fn.Run().Pass(), 976 options.make_http_bridge_factory_fn.Run().Pass(),
974 options.routing_info, 977 options.routing_info,
975 options.workers, 978 options.workers,
976 options.extensions_activity_monitor, 979 options.extensions_activity_monitor,
977 options.registrar /* as SyncManager::ChangeDelegate */, 980 options.registrar /* as SyncManager::ChangeDelegate */,
978 options.credentials, 981 options.credentials,
979 scoped_ptr<syncer::SyncNotifier>(new BridgedSyncNotifier( 982 scoped_ptr<syncer::SyncNotifier>(new BridgedSyncNotifier(
980 options.chrome_sync_notification_bridge, 983 options.chrome_sync_notification_bridge,
981 options.sync_notifier_factory->CreateSyncNotifier())), 984 options.sync_notifier_factory->CreateSyncNotifier())),
982 options.restored_key_for_bootstrapping, 985 options.restored_key_for_bootstrapping,
983 options.testing_mode, 986 scoped_ptr<InternalComponentsFactory>(
987 options.internal_components_factory),
984 &encryptor_, 988 &encryptor_,
985 options.unrecoverable_error_handler, 989 options.unrecoverable_error_handler,
986 options.report_unrecoverable_error_function); 990 options.report_unrecoverable_error_function);
987 LOG_IF(ERROR, !success) << "Syncapi initialization failed!"; 991 LOG_IF(ERROR, !success) << "Syncapi initialization failed!";
988 992
989 // Now check the command line to see if we need to simulate an 993 // Now check the command line to see if we need to simulate an
990 // unrecoverable error for testing purpose. Note the error is thrown 994 // unrecoverable error for testing purpose. Note the error is thrown
991 // only if the initialization succeeded. Also it makes sense to use this 995 // only if the initialization succeeded. Also it makes sense to use this
992 // flag only when restarting the browser with an account already setup. If 996 // flag only when restarting the browser with an account already setup. If
993 // you use this before setting up the setup would not succeed as an error 997 // you use this before setting up the setup would not succeed as an error
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after
1367 FROM_HERE, 1371 FROM_HERE,
1368 base::Bind(&SyncBackendHost::Core::DoRefreshNigori, 1372 base::Bind(&SyncBackendHost::Core::DoRefreshNigori,
1369 core_.get(), sync_thread_done_callback)); 1373 core_.get(), sync_thread_done_callback));
1370 } 1374 }
1371 1375
1372 #undef SDVLOG 1376 #undef SDVLOG
1373 1377
1374 #undef SLOG 1378 #undef SLOG
1375 1379
1376 } // namespace browser_sync 1380 } // namespace browser_sync
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698