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

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: test 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/util/experiments.h" 48 #include "sync/internal_api/public/util/experiments.h"
48 #include "sync/notifier/sync_notifier.h" 49 #include "sync/notifier/sync_notifier.h"
49 #include "sync/protocol/encryption.pb.h" 50 #include "sync/protocol/encryption.pb.h"
50 #include "sync/protocol/sync.pb.h" 51 #include "sync/protocol/sync.pb.h"
51 #include "sync/util/nigori.h" 52 #include "sync/util/nigori.h"
52 53
53 static const int kSaveChangesIntervalSeconds = 10; 54 static const int kSaveChangesIntervalSeconds = 10;
54 static const FilePath::CharType kSyncDataFolderName[] = 55 static const FilePath::CharType kSyncDataFolderName[] =
55 FILE_PATH_LITERAL("Sync Data"); 56 FILE_PATH_LITERAL("Sync Data");
56 57
57 typedef TokenService::TokenAvailableDetails TokenAvailableDetails; 58 typedef TokenService::TokenAvailableDetails TokenAvailableDetails;
58 59
59 typedef GoogleServiceAuthError AuthError; 60 typedef GoogleServiceAuthError AuthError;
60 61
61 namespace browser_sync { 62 namespace browser_sync {
62 63
63 using content::BrowserThread; 64 using content::BrowserThread;
65 using syncer::InternalComponentsFactory;
66 using syncer::InternalComponentsFactoryImpl;
64 using syncer::sessions::SyncSessionSnapshot; 67 using syncer::sessions::SyncSessionSnapshot;
65 using syncer::SyncCredentials; 68 using syncer::SyncCredentials;
66 69
67 // Helper macros to log with the syncer thread name; useful when there 70 // Helper macros to log with the syncer thread name; useful when there
68 // are multiple syncers involved. 71 // are multiple syncers involved.
69 72
70 #define SLOG(severity) LOG(severity) << name_ << ": " 73 #define SLOG(severity) LOG(severity) << name_ << ": "
71 74
72 #define SDVLOG(verbose_level) DVLOG(verbose_level) << name_ << ": " 75 #define SDVLOG(verbose_level) DVLOG(verbose_level) << name_ << ": "
73 76
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 &extensions_activity_monitor_, 402 &extensions_activity_monitor_,
400 event_handler, 403 event_handler,
401 sync_service_url, 404 sync_service_url,
402 base::Bind(&MakeHttpBridgeFactory, 405 base::Bind(&MakeHttpBridgeFactory,
403 make_scoped_refptr(profile_->GetRequestContext())), 406 make_scoped_refptr(profile_->GetRequestContext())),
404 credentials, 407 credentials,
405 &chrome_sync_notification_bridge_, 408 &chrome_sync_notification_bridge_,
406 &sync_notifier_factory_, 409 &sync_notifier_factory_,
407 delete_sync_data_folder, 410 delete_sync_data_folder,
408 sync_prefs_->GetEncryptionBootstrapToken(), 411 sync_prefs_->GetEncryptionBootstrapToken(),
409 syncer::SyncManager::NON_TEST, 412 new InternalComponentsFactoryImpl(),
Nicolas Zea 2012/07/18 21:10:12 does it make more sense to have an internal compon
tim (not reviewing) 2012/07/18 21:57:47 I don't think so, because this is only needed for
410 unrecoverable_error_handler, 413 unrecoverable_error_handler,
411 report_unrecoverable_error_function)); 414 report_unrecoverable_error_function));
412 } 415 }
413 416
414 void SyncBackendHost::UpdateCredentials(const SyncCredentials& credentials) { 417 void SyncBackendHost::UpdateCredentials(const SyncCredentials& credentials) {
415 sync_thread_.message_loop()->PostTask(FROM_HERE, 418 sync_thread_.message_loop()->PostTask(FROM_HERE,
416 base::Bind(&SyncBackendHost::Core::DoUpdateCredentials, core_.get(), 419 base::Bind(&SyncBackendHost::Core::DoUpdateCredentials, core_.get(),
417 credentials)); 420 credentials));
418 } 421 }
419 422
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after
767 const std::vector<syncer::ModelSafeWorker*>& workers, 770 const std::vector<syncer::ModelSafeWorker*>& workers,
768 syncer::ExtensionsActivityMonitor* extensions_activity_monitor, 771 syncer::ExtensionsActivityMonitor* extensions_activity_monitor,
769 const syncer::WeakHandle<syncer::JsEventHandler>& event_handler, 772 const syncer::WeakHandle<syncer::JsEventHandler>& event_handler,
770 const GURL& service_url, 773 const GURL& service_url,
771 MakeHttpBridgeFactoryFn make_http_bridge_factory_fn, 774 MakeHttpBridgeFactoryFn make_http_bridge_factory_fn,
772 const syncer::SyncCredentials& credentials, 775 const syncer::SyncCredentials& credentials,
773 ChromeSyncNotificationBridge* chrome_sync_notification_bridge, 776 ChromeSyncNotificationBridge* chrome_sync_notification_bridge,
774 syncer::SyncNotifierFactory* sync_notifier_factory, 777 syncer::SyncNotifierFactory* sync_notifier_factory,
775 bool delete_sync_data_folder, 778 bool delete_sync_data_folder,
776 const std::string& restored_key_for_bootstrapping, 779 const std::string& restored_key_for_bootstrapping,
777 syncer::SyncManager::TestingMode testing_mode, 780 InternalComponentsFactory* internal_components_factory,
778 syncer::UnrecoverableErrorHandler* unrecoverable_error_handler, 781 syncer::UnrecoverableErrorHandler* unrecoverable_error_handler,
779 syncer::ReportUnrecoverableErrorFunction 782 syncer::ReportUnrecoverableErrorFunction
780 report_unrecoverable_error_function) 783 report_unrecoverable_error_function)
781 : sync_loop(sync_loop), 784 : sync_loop(sync_loop),
782 registrar(registrar), 785 registrar(registrar),
783 routing_info(routing_info), 786 routing_info(routing_info),
784 workers(workers), 787 workers(workers),
785 extensions_activity_monitor(extensions_activity_monitor), 788 extensions_activity_monitor(extensions_activity_monitor),
786 event_handler(event_handler), 789 event_handler(event_handler),
787 service_url(service_url), 790 service_url(service_url),
788 make_http_bridge_factory_fn(make_http_bridge_factory_fn), 791 make_http_bridge_factory_fn(make_http_bridge_factory_fn),
789 credentials(credentials), 792 credentials(credentials),
790 chrome_sync_notification_bridge(chrome_sync_notification_bridge), 793 chrome_sync_notification_bridge(chrome_sync_notification_bridge),
791 sync_notifier_factory(sync_notifier_factory), 794 sync_notifier_factory(sync_notifier_factory),
792 delete_sync_data_folder(delete_sync_data_folder), 795 delete_sync_data_folder(delete_sync_data_folder),
793 restored_key_for_bootstrapping(restored_key_for_bootstrapping), 796 restored_key_for_bootstrapping(restored_key_for_bootstrapping),
794 testing_mode(testing_mode), 797 internal_components_factory(internal_components_factory),
795 unrecoverable_error_handler(unrecoverable_error_handler), 798 unrecoverable_error_handler(unrecoverable_error_handler),
796 report_unrecoverable_error_function( 799 report_unrecoverable_error_function(
797 report_unrecoverable_error_function) { 800 report_unrecoverable_error_function) {
798 } 801 }
799 802
800 SyncBackendHost::DoInitializeOptions::~DoInitializeOptions() {} 803 SyncBackendHost::DoInitializeOptions::~DoInitializeOptions() {}
801 804
802 SyncBackendHost::Core::Core(const std::string& name, 805 SyncBackendHost::Core::Core(const std::string& name,
803 const FilePath& sync_data_folder_path, 806 const FilePath& sync_data_folder_path,
804 const base::WeakPtr<SyncBackendHost>& backend) 807 const base::WeakPtr<SyncBackendHost>& backend)
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
967 options.make_http_bridge_factory_fn.Run(), 970 options.make_http_bridge_factory_fn.Run(),
968 options.routing_info, 971 options.routing_info,
969 options.workers, 972 options.workers,
970 options.extensions_activity_monitor, 973 options.extensions_activity_monitor,
971 options.registrar /* as SyncManager::ChangeDelegate */, 974 options.registrar /* as SyncManager::ChangeDelegate */,
972 options.credentials, 975 options.credentials,
973 new BridgedSyncNotifier( 976 new BridgedSyncNotifier(
974 options.chrome_sync_notification_bridge, 977 options.chrome_sync_notification_bridge,
975 options.sync_notifier_factory->CreateSyncNotifier()), 978 options.sync_notifier_factory->CreateSyncNotifier()),
976 options.restored_key_for_bootstrapping, 979 options.restored_key_for_bootstrapping,
977 options.testing_mode, 980 scoped_ptr<InternalComponentsFactory>(
981 options.internal_components_factory),
978 &encryptor_, 982 &encryptor_,
979 options.unrecoverable_error_handler, 983 options.unrecoverable_error_handler,
980 options.report_unrecoverable_error_function); 984 options.report_unrecoverable_error_function);
981 LOG_IF(ERROR, !success) << "Syncapi initialization failed!"; 985 LOG_IF(ERROR, !success) << "Syncapi initialization failed!";
982 986
983 // Now check the command line to see if we need to simulate an 987 // Now check the command line to see if we need to simulate an
984 // unrecoverable error for testing purpose. Note the error is thrown 988 // unrecoverable error for testing purpose. Note the error is thrown
985 // only if the initialization succeeded. Also it makes sense to use this 989 // only if the initialization succeeded. Also it makes sense to use this
986 // flag only when restarting the browser with an account already setup. If 990 // flag only when restarting the browser with an account already setup. If
987 // you use this before setting up the setup would not succeed as an error 991 // 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
1361 FROM_HERE, 1365 FROM_HERE,
1362 base::Bind(&SyncBackendHost::Core::DoRefreshNigori, 1366 base::Bind(&SyncBackendHost::Core::DoRefreshNigori,
1363 core_.get(), sync_thread_done_callback)); 1367 core_.get(), sync_thread_done_callback));
1364 } 1368 }
1365 1369
1366 #undef SDVLOG 1370 #undef SDVLOG
1367 1371
1368 #undef SLOG 1372 #undef SLOG
1369 1373
1370 } // namespace browser_sync 1374 } // namespace browser_sync
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698