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

Side by Side Diff: sync/internal_api/sync_manager_impl.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 "sync/internal_api/sync_manager_impl.h" 5 #include "sync/internal_api/sync_manager_impl.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/base64.h" 9 #include "base/base64.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 15 matching lines...) Expand all
26 #include "sync/internal_api/change_reorder_buffer.h" 26 #include "sync/internal_api/change_reorder_buffer.h"
27 #include "sync/internal_api/debug_info_event_listener.h" 27 #include "sync/internal_api/debug_info_event_listener.h"
28 #include "sync/internal_api/js_mutation_event_observer.h" 28 #include "sync/internal_api/js_mutation_event_observer.h"
29 #include "sync/internal_api/js_sync_manager_observer.h" 29 #include "sync/internal_api/js_sync_manager_observer.h"
30 #include "sync/internal_api/public/base/model_type.h" 30 #include "sync/internal_api/public/base/model_type.h"
31 #include "sync/internal_api/public/base/model_type_payload_map.h" 31 #include "sync/internal_api/public/base/model_type_payload_map.h"
32 #include "sync/internal_api/public/base_node.h" 32 #include "sync/internal_api/public/base_node.h"
33 #include "sync/internal_api/public/configure_reason.h" 33 #include "sync/internal_api/public/configure_reason.h"
34 #include "sync/internal_api/public/engine/polling_constants.h" 34 #include "sync/internal_api/public/engine/polling_constants.h"
35 #include "sync/internal_api/public/http_post_provider_factory.h" 35 #include "sync/internal_api/public/http_post_provider_factory.h"
36 #include "sync/internal_api/public/internal_components_factory.h"
36 #include "sync/internal_api/public/read_node.h" 37 #include "sync/internal_api/public/read_node.h"
37 #include "sync/internal_api/public/read_transaction.h" 38 #include "sync/internal_api/public/read_transaction.h"
38 #include "sync/internal_api/public/user_share.h" 39 #include "sync/internal_api/public/user_share.h"
39 #include "sync/internal_api/public/util/experiments.h" 40 #include "sync/internal_api/public/util/experiments.h"
40 #include "sync/internal_api/public/write_node.h" 41 #include "sync/internal_api/public/write_node.h"
41 #include "sync/internal_api/public/write_transaction.h" 42 #include "sync/internal_api/public/write_transaction.h"
42 #include "sync/internal_api/syncapi_internal.h" 43 #include "sync/internal_api/syncapi_internal.h"
43 #include "sync/internal_api/syncapi_server_connection_manager.h" 44 #include "sync/internal_api/syncapi_server_connection_manager.h"
44 #include "sync/js/js_arg_list.h" 45 #include "sync/js/js_arg_list.h"
45 #include "sync/js/js_backend.h" 46 #include "sync/js/js_backend.h"
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 return GetUpdatesCallerInfo::RECONFIGURATION; 81 return GetUpdatesCallerInfo::RECONFIGURATION;
81 case syncer::CONFIGURE_REASON_MIGRATION: 82 case syncer::CONFIGURE_REASON_MIGRATION:
82 return GetUpdatesCallerInfo::MIGRATION; 83 return GetUpdatesCallerInfo::MIGRATION;
83 case syncer::CONFIGURE_REASON_NEW_CLIENT: 84 case syncer::CONFIGURE_REASON_NEW_CLIENT:
84 return GetUpdatesCallerInfo::NEW_CLIENT; 85 return GetUpdatesCallerInfo::NEW_CLIENT;
85 case syncer::CONFIGURE_REASON_NEWLY_ENABLED_DATA_TYPE: 86 case syncer::CONFIGURE_REASON_NEWLY_ENABLED_DATA_TYPE:
86 return GetUpdatesCallerInfo::NEWLY_SUPPORTED_DATATYPE; 87 return GetUpdatesCallerInfo::NEWLY_SUPPORTED_DATATYPE;
87 default: 88 default:
88 NOTREACHED(); 89 NOTREACHED();
89 } 90 }
90
91 return GetUpdatesCallerInfo::UNKNOWN; 91 return GetUpdatesCallerInfo::UNKNOWN;
92 } 92 }
93 93
94 // The maximum number of times we will automatically overwrite the nigori node 94 // The maximum number of times we will automatically overwrite the nigori node
95 // because the encryption keys don't match (per chrome instantiation). 95 // because the encryption keys don't match (per chrome instantiation).
96 static const int kNigoriOverwriteLimit = 10; 96 static const int kNigoriOverwriteLimit = 10;
97 97
98 } // namespace 98 } // namespace
99 99
100 namespace syncer { 100 namespace syncer {
(...skipping 15 matching lines...) Expand all
116 public JsBackend, 116 public JsBackend,
117 public SyncEngineEventListener, 117 public SyncEngineEventListener,
118 public ServerConnectionEventListener, 118 public ServerConnectionEventListener,
119 public syncable::DirectoryChangeDelegate { 119 public syncable::DirectoryChangeDelegate {
120 public: 120 public:
121 explicit SyncInternal(const std::string& name) 121 explicit SyncInternal(const std::string& name)
122 : name_(name), 122 : name_(name),
123 weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), 123 weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)),
124 change_delegate_(NULL), 124 change_delegate_(NULL),
125 initialized_(false), 125 initialized_(false),
126 testing_mode_(NON_TEST),
127 observing_ip_address_changes_(false), 126 observing_ip_address_changes_(false),
128 throttled_data_type_tracker_(&allstatus_), 127 throttled_data_type_tracker_(&allstatus_),
129 traffic_recorder_(kMaxMessagesToRecord, kMaxMessageSizeToRecord), 128 traffic_recorder_(kMaxMessagesToRecord, kMaxMessageSizeToRecord),
130 encryptor_(NULL), 129 encryptor_(NULL),
131 unrecoverable_error_handler_(NULL), 130 unrecoverable_error_handler_(NULL),
132 report_unrecoverable_error_function_(NULL), 131 report_unrecoverable_error_function_(NULL),
133 created_on_loop_(MessageLoop::current()),
134 nigori_overwrite_count_(0) { 132 nigori_overwrite_count_(0) {
135 // Pre-fill |notification_info_map_|. 133 // Pre-fill |notification_info_map_|.
136 for (int i = syncer::FIRST_REAL_MODEL_TYPE; 134 for (int i = syncer::FIRST_REAL_MODEL_TYPE;
137 i < syncer::MODEL_TYPE_COUNT; ++i) { 135 i < syncer::MODEL_TYPE_COUNT; ++i) {
138 notification_info_map_.insert( 136 notification_info_map_.insert(
139 std::make_pair(syncer::ModelTypeFromInt(i), NotificationInfo())); 137 std::make_pair(syncer::ModelTypeFromInt(i), NotificationInfo()));
140 } 138 }
141 139
142 // Bind message handlers. 140 // Bind message handlers.
143 BindJsMessageHandler( 141 BindJsMessageHandler(
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 const scoped_refptr<base::TaskRunner>& blocking_task_runner, 176 const scoped_refptr<base::TaskRunner>& blocking_task_runner,
179 scoped_ptr<HttpPostProviderFactory> post_factory, 177 scoped_ptr<HttpPostProviderFactory> post_factory,
180 const syncer::ModelSafeRoutingInfo& model_safe_routing_info, 178 const syncer::ModelSafeRoutingInfo& model_safe_routing_info,
181 const std::vector<syncer::ModelSafeWorker*>& workers, 179 const std::vector<syncer::ModelSafeWorker*>& workers,
182 syncer::ExtensionsActivityMonitor* 180 syncer::ExtensionsActivityMonitor*
183 extensions_activity_monitor, 181 extensions_activity_monitor,
184 SyncManager::ChangeDelegate* change_delegate, 182 SyncManager::ChangeDelegate* change_delegate,
185 const SyncCredentials& credentials, 183 const SyncCredentials& credentials,
186 scoped_ptr<syncer::SyncNotifier> sync_notifier, 184 scoped_ptr<syncer::SyncNotifier> sync_notifier,
187 const std::string& restored_key_for_bootstrapping, 185 const std::string& restored_key_for_bootstrapping,
188 SyncManager::TestingMode testing_mode, 186 scoped_ptr<InternalComponentsFactory> internal_components_factory,
189 Encryptor* encryptor, 187 Encryptor* encryptor,
190 UnrecoverableErrorHandler* unrecoverable_error_handler, 188 UnrecoverableErrorHandler* unrecoverable_error_handler,
191 ReportUnrecoverableErrorFunction 189 ReportUnrecoverableErrorFunction
192 report_unrecoverable_error_function); 190 report_unrecoverable_error_function);
193 191
194 // Sign into sync with given credentials. 192 // Sign into sync with given credentials.
195 // We do not verify the tokens given. After this call, the tokens are set 193 // We do not verify the tokens given. After this call, the tokens are set
196 // and the sync DB is open. True if successful, false if something 194 // and the sync DB is open. True if successful, false if something
197 // went wrong. 195 // went wrong.
198 bool SignIn(const SyncCredentials& credentials); 196 bool SignIn(const SyncCredentials& credentials);
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 virtual void OnServerConnectionEvent( 387 virtual void OnServerConnectionEvent(
390 const ServerConnectionEvent& event) OVERRIDE; 388 const ServerConnectionEvent& event) OVERRIDE;
391 389
392 // JsBackend implementation. 390 // JsBackend implementation.
393 virtual void SetJsEventHandler( 391 virtual void SetJsEventHandler(
394 const WeakHandle<JsEventHandler>& event_handler) OVERRIDE; 392 const WeakHandle<JsEventHandler>& event_handler) OVERRIDE;
395 virtual void ProcessJsMessage( 393 virtual void ProcessJsMessage(
396 const std::string& name, const JsArgList& args, 394 const std::string& name, const JsArgList& args,
397 const WeakHandle<JsReplyHandler>& reply_handler) OVERRIDE; 395 const WeakHandle<JsReplyHandler>& reply_handler) OVERRIDE;
398 396
399 void SetSyncSchedulerForTest(scoped_ptr<SyncScheduler> scheduler);
400
401 private: 397 private:
402 struct NotificationInfo { 398 struct NotificationInfo {
403 int total_count; 399 int total_count;
404 std::string payload; 400 std::string payload;
405 401
406 NotificationInfo() : total_count(0) {} 402 NotificationInfo() : total_count(0) {}
407 403
408 ~NotificationInfo() {} 404 ~NotificationInfo() {}
409 405
410 // Returned pointer owned by the caller. 406 // Returned pointer owned by the caller.
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
581 // forwarded to the observer slightly later, at the TRANSACTION_ENDING 577 // forwarded to the observer slightly later, at the TRANSACTION_ENDING
582 // step by HandleTransactionEndingChangeEvent. The list is cleared in the 578 // step by HandleTransactionEndingChangeEvent. The list is cleared in the
583 // TRANSACTION_COMPLETE step by HandleTransactionCompleteChangeEvent. 579 // TRANSACTION_COMPLETE step by HandleTransactionCompleteChangeEvent.
584 ChangeReorderBuffer change_buffers_[syncer::MODEL_TYPE_COUNT]; 580 ChangeReorderBuffer change_buffers_[syncer::MODEL_TYPE_COUNT];
585 581
586 SyncManager::ChangeDelegate* change_delegate_; 582 SyncManager::ChangeDelegate* change_delegate_;
587 583
588 // Set to true once Init has been called. 584 // Set to true once Init has been called.
589 bool initialized_; 585 bool initialized_;
590 586
591 // Controls the disabling of certain SyncManager features.
592 // Can be used to disable communication with the server and the use of an
593 // on-disk file for maintaining syncer state.
594 // TODO(117836): Clean up implementation of SyncManager unit tests.
595 SyncManager::TestingMode testing_mode_;
596
597 bool observing_ip_address_changes_; 587 bool observing_ip_address_changes_;
598 588
599 // Map used to store the notification info to be displayed in 589 // Map used to store the notification info to be displayed in
600 // about:sync page. 590 // about:sync page.
601 NotificationInfoMap notification_info_map_; 591 NotificationInfoMap notification_info_map_;
602 592
603 // These are for interacting with chrome://sync-internals. 593 // These are for interacting with chrome://sync-internals.
604 JsMessageHandlerMap js_message_handlers_; 594 JsMessageHandlerMap js_message_handlers_;
605 WeakHandle<JsEventHandler> js_event_handler_; 595 WeakHandle<JsEventHandler> js_event_handler_;
606 JsSyncManagerObserver js_sync_manager_observer_; 596 JsSyncManagerObserver js_sync_manager_observer_;
607 JsMutationEventObserver js_mutation_event_observer_; 597 JsMutationEventObserver js_mutation_event_observer_;
608 598
609 syncer::ThrottledDataTypeTracker throttled_data_type_tracker_; 599 syncer::ThrottledDataTypeTracker throttled_data_type_tracker_;
610 600
611 // This is for keeping track of client events to send to the server. 601 // This is for keeping track of client events to send to the server.
612 DebugInfoEventListener debug_info_event_listener_; 602 DebugInfoEventListener debug_info_event_listener_;
613 603
614 syncer::TrafficRecorder traffic_recorder_; 604 syncer::TrafficRecorder traffic_recorder_;
615 605
616 Encryptor* encryptor_; 606 Encryptor* encryptor_;
617 UnrecoverableErrorHandler* unrecoverable_error_handler_; 607 UnrecoverableErrorHandler* unrecoverable_error_handler_;
618 ReportUnrecoverableErrorFunction report_unrecoverable_error_function_; 608 ReportUnrecoverableErrorFunction report_unrecoverable_error_function_;
619 609
620 MessageLoop* const created_on_loop_;
621
622 // The number of times we've automatically (i.e. not via SetPassphrase or 610 // The number of times we've automatically (i.e. not via SetPassphrase or
623 // conflict resolver) updated the nigori's encryption keys in this chrome 611 // conflict resolver) updated the nigori's encryption keys in this chrome
624 // instantiation. 612 // instantiation.
625 int nigori_overwrite_count_; 613 int nigori_overwrite_count_;
626 }; 614 };
627 615
628 // A class to calculate nudge delays for types. 616 // A class to calculate nudge delays for types.
629 class NudgeStrategy { 617 class NudgeStrategy {
630 public: 618 public:
631 static TimeDelta GetNudgeDelayTimeDelta(const ModelType& model_type, 619 static TimeDelta GetNudgeDelayTimeDelta(const ModelType& model_type,
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
679 delay = TimeDelta::FromSeconds( 667 delay = TimeDelta::FromSeconds(
680 syncer::kDefaultShortPollIntervalSeconds); 668 syncer::kDefaultShortPollIntervalSeconds);
681 break; 669 break;
682 case CUSTOM: 670 case CUSTOM:
683 switch (model_type) { 671 switch (model_type) {
684 case syncer::PREFERENCES: 672 case syncer::PREFERENCES:
685 delay = TimeDelta::FromMilliseconds( 673 delay = TimeDelta::FromMilliseconds(
686 kPreferencesNudgeDelayMilliseconds); 674 kPreferencesNudgeDelayMilliseconds);
687 break; 675 break;
688 case syncer::SESSIONS: 676 case syncer::SESSIONS:
689 delay = core->scheduler()->sessions_commit_delay(); 677 delay = core->scheduler()->GetSessionsCommitDelay();
690 break; 678 break;
691 default: 679 default:
692 NOTREACHED(); 680 NOTREACHED();
693 } 681 }
694 break; 682 break;
695 default: 683 default:
696 NOTREACHED(); 684 NOTREACHED();
697 } 685 }
698 return delay; 686 return delay;
699 } 687 }
(...skipping 10 matching lines...) Expand all
710 bool use_ssl, 698 bool use_ssl,
711 const scoped_refptr<base::TaskRunner>& blocking_task_runner, 699 const scoped_refptr<base::TaskRunner>& blocking_task_runner,
712 scoped_ptr<HttpPostProviderFactory> post_factory, 700 scoped_ptr<HttpPostProviderFactory> post_factory,
713 const syncer::ModelSafeRoutingInfo& model_safe_routing_info, 701 const syncer::ModelSafeRoutingInfo& model_safe_routing_info,
714 const std::vector<syncer::ModelSafeWorker*>& workers, 702 const std::vector<syncer::ModelSafeWorker*>& workers,
715 syncer::ExtensionsActivityMonitor* extensions_activity_monitor, 703 syncer::ExtensionsActivityMonitor* extensions_activity_monitor,
716 SyncManager::ChangeDelegate* change_delegate, 704 SyncManager::ChangeDelegate* change_delegate,
717 const SyncCredentials& credentials, 705 const SyncCredentials& credentials,
718 scoped_ptr<syncer::SyncNotifier> sync_notifier, 706 scoped_ptr<syncer::SyncNotifier> sync_notifier,
719 const std::string& restored_key_for_bootstrapping, 707 const std::string& restored_key_for_bootstrapping,
720 SyncManager::TestingMode testing_mode, 708 scoped_ptr<InternalComponentsFactory> internal_components_factory,
721 Encryptor* encryptor, 709 Encryptor* encryptor,
722 UnrecoverableErrorHandler* unrecoverable_error_handler, 710 UnrecoverableErrorHandler* unrecoverable_error_handler,
723 ReportUnrecoverableErrorFunction report_unrecoverable_error_function) { 711 ReportUnrecoverableErrorFunction report_unrecoverable_error_function) {
724 DCHECK(thread_checker_.CalledOnValidThread()); 712 DCHECK(thread_checker_.CalledOnValidThread());
725 DCHECK(post_factory.get()); 713 DCHECK(post_factory.get());
726 DVLOG(1) << "SyncManager starting Init..."; 714 DVLOG(1) << "SyncManager starting Init...";
727 std::string server_string(sync_server_and_path); 715 std::string server_string(sync_server_and_path);
728 return data_->Init(database_location, 716 return data_->Init(database_location,
729 event_handler, 717 event_handler,
730 server_string, 718 server_string,
731 sync_server_port, 719 sync_server_port,
732 use_ssl, 720 use_ssl,
733 blocking_task_runner, 721 blocking_task_runner,
734 post_factory.Pass(), 722 post_factory.Pass(),
735 model_safe_routing_info, 723 model_safe_routing_info,
736 workers, 724 workers,
737 extensions_activity_monitor, 725 extensions_activity_monitor,
738 change_delegate, 726 change_delegate,
739 credentials, 727 credentials,
740 sync_notifier.Pass(), 728 sync_notifier.Pass(),
741 restored_key_for_bootstrapping, 729 restored_key_for_bootstrapping,
742 testing_mode, 730 internal_components_factory.Pass(),
743 encryptor, 731 encryptor,
744 unrecoverable_error_handler, 732 unrecoverable_error_handler,
745 report_unrecoverable_error_function); 733 report_unrecoverable_error_function);
746 } 734 }
747 735
748 void SyncManagerImpl::UpdateCredentials(const SyncCredentials& credentials) { 736 void SyncManagerImpl::UpdateCredentials(const SyncCredentials& credentials) {
749 DCHECK(thread_checker_.CalledOnValidThread()); 737 DCHECK(thread_checker_.CalledOnValidThread());
750 data_->UpdateCredentials(credentials); 738 data_->UpdateCredentials(credentials);
751 } 739 }
752 740
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
862 bool use_ssl, 850 bool use_ssl,
863 const scoped_refptr<base::TaskRunner>& blocking_task_runner, 851 const scoped_refptr<base::TaskRunner>& blocking_task_runner,
864 scoped_ptr<HttpPostProviderFactory> post_factory, 852 scoped_ptr<HttpPostProviderFactory> post_factory,
865 const syncer::ModelSafeRoutingInfo& model_safe_routing_info, 853 const syncer::ModelSafeRoutingInfo& model_safe_routing_info,
866 const std::vector<syncer::ModelSafeWorker*>& workers, 854 const std::vector<syncer::ModelSafeWorker*>& workers,
867 syncer::ExtensionsActivityMonitor* extensions_activity_monitor, 855 syncer::ExtensionsActivityMonitor* extensions_activity_monitor,
868 SyncManager::ChangeDelegate* change_delegate, 856 SyncManager::ChangeDelegate* change_delegate,
869 const SyncCredentials& credentials, 857 const SyncCredentials& credentials,
870 scoped_ptr<syncer::SyncNotifier> sync_notifier, 858 scoped_ptr<syncer::SyncNotifier> sync_notifier,
871 const std::string& restored_key_for_bootstrapping, 859 const std::string& restored_key_for_bootstrapping,
872 SyncManager::TestingMode testing_mode, 860 scoped_ptr<InternalComponentsFactory> internal_components_factory,
873 Encryptor* encryptor, 861 Encryptor* encryptor,
874 UnrecoverableErrorHandler* unrecoverable_error_handler, 862 UnrecoverableErrorHandler* unrecoverable_error_handler,
875 ReportUnrecoverableErrorFunction report_unrecoverable_error_function) { 863 ReportUnrecoverableErrorFunction report_unrecoverable_error_function) {
876 CHECK(!initialized_); 864 CHECK(!initialized_);
877 865
878 DCHECK(thread_checker_.CalledOnValidThread()); 866 DCHECK(thread_checker_.CalledOnValidThread());
879 867
880 DVLOG(1) << "Starting SyncInternal initialization."; 868 DVLOG(1) << "Starting SyncInternal initialization.";
881 869
882 weak_handle_this_ = MakeWeakHandle(weak_ptr_factory_.GetWeakPtr()); 870 weak_handle_this_ = MakeWeakHandle(weak_ptr_factory_.GetWeakPtr());
883 871
884 blocking_task_runner_ = blocking_task_runner; 872 blocking_task_runner_ = blocking_task_runner;
885 873
886 change_delegate_ = change_delegate; 874 change_delegate_ = change_delegate;
887 testing_mode_ = testing_mode;
888 875
889 sync_notifier_ = sync_notifier.Pass(); 876 sync_notifier_ = sync_notifier.Pass();
890 877
891 AddObserver(&js_sync_manager_observer_); 878 AddObserver(&js_sync_manager_observer_);
892 SetJsEventHandler(event_handler); 879 SetJsEventHandler(event_handler);
893 880
894 AddObserver(&debug_info_event_listener_); 881 AddObserver(&debug_info_event_listener_);
895 882
896 database_path_ = database_location.Append( 883 database_path_ = database_location.Append(
897 syncable::Directory::kSyncDatabaseFilename); 884 syncable::Directory::kSyncDatabaseFilename);
898 encryptor_ = encryptor; 885 encryptor_ = encryptor;
899 unrecoverable_error_handler_ = unrecoverable_error_handler; 886 unrecoverable_error_handler_ = unrecoverable_error_handler;
900 report_unrecoverable_error_function_ = report_unrecoverable_error_function; 887 report_unrecoverable_error_function_ = report_unrecoverable_error_function;
901 888
902 syncable::DirectoryBackingStore* backing_store = NULL; 889 FilePath absolute_db_path(database_path_);
903 if (testing_mode_ == TEST_IN_MEMORY) { 890 file_util::AbsolutePath(&absolute_db_path);
904 // TODO(tim): 117836. Use a factory or delegate to create this and don't 891 scoped_ptr<syncable::DirectoryBackingStore> backing_store =
905 // depend on TEST_IN_MEMORY here. 892 internal_components_factory->BuildDirectoryBackingStore(
906 backing_store = 893 credentials.email, absolute_db_path).Pass();
907 new syncable::InMemoryDirectoryBackingStore(credentials.email);
908 } else {
909 FilePath absolute_db_path(database_path_);
910 file_util::AbsolutePath(&absolute_db_path);
911 backing_store = new syncable::OnDiskDirectoryBackingStore(
912 credentials.email, absolute_db_path);
913 }
914 894
915 DCHECK(backing_store); 895 DCHECK(backing_store.get());
916 share_.directory.reset( 896 share_.directory.reset(
917 new syncable::Directory(encryptor_, 897 new syncable::Directory(encryptor_,
918 unrecoverable_error_handler_, 898 unrecoverable_error_handler_,
919 report_unrecoverable_error_function_, 899 report_unrecoverable_error_function_,
920 backing_store)); 900 backing_store.release()));
921 901
922 connection_manager_.reset(new SyncAPIServerConnectionManager( 902 connection_manager_.reset(new SyncAPIServerConnectionManager(
923 sync_server_and_path, port, use_ssl, post_factory.release())); 903 sync_server_and_path, port, use_ssl, post_factory.release()));
924 904
925 net::NetworkChangeNotifier::AddIPAddressObserver(this); 905 net::NetworkChangeNotifier::AddIPAddressObserver(this);
926 observing_ip_address_changes_ = true; 906 observing_ip_address_changes_ = true;
927 907
928 connection_manager()->AddListener(this); 908 connection_manager()->AddListener(this);
929 909
930 // Test mode does not use a syncer context or syncer thread. 910 // Build a SyncSessionContext and store the worker in it.
931 if (testing_mode_ == NON_TEST) { 911 DVLOG(1) << "Sync is bringing up SyncSessionContext.";
932 // Build a SyncSessionContext and store the worker in it. 912 std::vector<SyncEngineEventListener*> listeners;
933 DVLOG(1) << "Sync is bringing up SyncSessionContext."; 913 listeners.push_back(&allstatus_);
934 std::vector<SyncEngineEventListener*> listeners; 914 listeners.push_back(this);
935 listeners.push_back(&allstatus_); 915 session_context_ = internal_components_factory->BuildContext(
936 listeners.push_back(this); 916 connection_manager_.get(),
937 session_context_.reset(new SyncSessionContext( 917 directory(),
938 connection_manager_.get(), 918 model_safe_routing_info,
939 directory(), 919 workers,
940 model_safe_routing_info, 920 extensions_activity_monitor,
941 workers, 921 &throttled_data_type_tracker_,
942 extensions_activity_monitor, 922 listeners,
943 &throttled_data_type_tracker_, 923 &debug_info_event_listener_,
944 listeners, 924 &traffic_recorder_).Pass();
945 &debug_info_event_listener_, 925 session_context()->set_account_name(credentials.email);
946 &traffic_recorder_)); 926 scheduler_ = internal_components_factory->BuildScheduler(
947 session_context()->set_account_name(credentials.email); 927 name_, session_context()).Pass();
948 scheduler_.reset(new SyncScheduler(name_, session_context(), new Syncer()));
949 }
950 928
951 bool success = SignIn(credentials); 929 bool success = SignIn(credentials);
952 930
953 if (success) { 931 if (success) {
954 if (scheduler()) { 932 scheduler()->Start(syncer::SyncScheduler::CONFIGURATION_MODE);
955 scheduler()->Start(syncer::SyncScheduler::CONFIGURATION_MODE);
956 }
957 933
958 initialized_ = true; 934 initialized_ = true;
959 935
960 // Unapplied datatypes (those that do not have initial sync ended set) get 936 // Unapplied datatypes (those that do not have initial sync ended set) get
961 // re-downloaded during any configuration. But, it's possible for a datatype 937 // re-downloaded during any configuration. But, it's possible for a datatype
962 // to have a progress marker but not have initial sync ended yet, making 938 // to have a progress marker but not have initial sync ended yet, making
963 // it a candidate for migration. This is a problem, as the DataTypeManager 939 // it a candidate for migration. This is a problem, as the DataTypeManager
964 // does not support a migration while it's already in the middle of a 940 // does not support a migration while it's already in the middle of a
965 // configuration. As a result, any partially synced datatype can stall the 941 // configuration. As a result, any partially synced datatype can stall the
966 // DTM, waiting for the configuration to complete, which it never will due 942 // DTM, waiting for the configuration to complete, which it never will due
(...skipping 15 matching lines...) Expand all
982 958
983 // Notify that initialization is complete. Note: This should be the last to 959 // Notify that initialization is complete. Note: This should be the last to
984 // execute if |signed_in| is false. Reason being in that case we would 960 // execute if |signed_in| is false. Reason being in that case we would
985 // post a task to shutdown sync. But if this function posts any other tasks 961 // post a task to shutdown sync. But if this function posts any other tasks
986 // on the UI thread and if shutdown wins then that tasks would execute on 962 // on the UI thread and if shutdown wins then that tasks would execute on
987 // a freed pointer. This is because UI thread is not shut down. 963 // a freed pointer. This is because UI thread is not shut down.
988 FOR_EACH_OBSERVER(SyncManager::Observer, observers_, 964 FOR_EACH_OBSERVER(SyncManager::Observer, observers_,
989 OnInitializationComplete( 965 OnInitializationComplete(
990 MakeWeakHandle(weak_ptr_factory_.GetWeakPtr()), 966 MakeWeakHandle(weak_ptr_factory_.GetWeakPtr()),
991 success)); 967 success));
992 968 if (!success)
993 if (!success && testing_mode_ == NON_TEST)
994 return false; 969 return false;
995 970
996 sync_notifier_->AddObserver(this); 971 sync_notifier_->AddObserver(this);
997 972
998 return success; 973 return success;
999 } 974 }
1000 975
1001 void SyncManagerImpl::SyncInternal::UpdateCryptographerAndNigori( 976 void SyncManagerImpl::SyncInternal::UpdateCryptographerAndNigori(
1002 const std::string& chrome_version, 977 const std::string& chrome_version,
1003 const base::Closure& done_callback) { 978 const base::Closure& done_callback) {
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
1065 Cryptographer::UpdateResult result = cryptographer->Update(nigori); 1040 Cryptographer::UpdateResult result = cryptographer->Update(nigori);
1066 if (result == Cryptographer::NEEDS_PASSPHRASE) { 1041 if (result == Cryptographer::NEEDS_PASSPHRASE) {
1067 sync_pb::EncryptedData pending_keys; 1042 sync_pb::EncryptedData pending_keys;
1068 if (cryptographer->has_pending_keys()) 1043 if (cryptographer->has_pending_keys())
1069 pending_keys = cryptographer->GetPendingKeys(); 1044 pending_keys = cryptographer->GetPendingKeys();
1070 FOR_EACH_OBSERVER(SyncManager::Observer, observers_, 1045 FOR_EACH_OBSERVER(SyncManager::Observer, observers_,
1071 OnPassphraseRequired(syncer::REASON_DECRYPTION, 1046 OnPassphraseRequired(syncer::REASON_DECRYPTION,
1072 pending_keys)); 1047 pending_keys));
1073 } 1048 }
1074 1049
1075
1076 // Add or update device information. 1050 // Add or update device information.
1077 bool contains_this_device = false; 1051 bool contains_this_device = false;
1078 for (int i = 0; i < nigori.device_information_size(); ++i) { 1052 for (int i = 0; i < nigori.device_information_size(); ++i) {
1079 const sync_pb::DeviceInformation& device_information = 1053 const sync_pb::DeviceInformation& device_information =
1080 nigori.device_information(i); 1054 nigori.device_information(i);
1081 if (device_information.cache_guid() == directory()->cache_guid()) { 1055 if (device_information.cache_guid() == directory()->cache_guid()) {
1082 // Update the version number in case it changed due to an update. 1056 // Update the version number in case it changed due to an update.
1083 if (device_information.chrome_version() != chrome_version) { 1057 if (device_information.chrome_version() != chrome_version) {
1084 sync_pb::DeviceInformation* mutable_device_information = 1058 sync_pb::DeviceInformation* mutable_device_information =
1085 nigori.mutable_device_information(i); 1059 nigori.mutable_device_information(i);
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
1133 allstatus_.SetCryptographerReady(cryptographer->is_ready()); 1107 allstatus_.SetCryptographerReady(cryptographer->is_ready());
1134 allstatus_.SetCryptoHasPendingKeys(cryptographer->has_pending_keys()); 1108 allstatus_.SetCryptoHasPendingKeys(cryptographer->has_pending_keys());
1135 debug_info_event_listener_.SetCryptographerReady(cryptographer->is_ready()); 1109 debug_info_event_listener_.SetCryptographerReady(cryptographer->is_ready());
1136 debug_info_event_listener_.SetCrytographerHasPendingKeys( 1110 debug_info_event_listener_.SetCrytographerHasPendingKeys(
1137 cryptographer->has_pending_keys()); 1111 cryptographer->has_pending_keys());
1138 } 1112 }
1139 1113
1140 void SyncManagerImpl::SyncInternal::StartSyncingNormally( 1114 void SyncManagerImpl::SyncInternal::StartSyncingNormally(
1141 const syncer::ModelSafeRoutingInfo& routing_info) { 1115 const syncer::ModelSafeRoutingInfo& routing_info) {
1142 // Start the sync scheduler. 1116 // Start the sync scheduler.
1143 if (scheduler()) { // NULL during certain unittests. 1117 // TODO(sync): We always want the newest set of routes when we switch back
1144 // TODO(sync): We always want the newest set of routes when we switch back 1118 // to normal mode. Figure out how to enforce set_routing_info is always
1145 // to normal mode. Figure out how to enforce set_routing_info is always 1119 // appropriately set and that it's only modified when switching to normal
1146 // appropriately set and that it's only modified when switching to normal 1120 // mode.
1147 // mode. 1121 session_context()->set_routing_info(routing_info);
1148 session_context()->set_routing_info(routing_info); 1122 scheduler()->Start(SyncScheduler::NORMAL_MODE);
1149 scheduler()->Start(SyncScheduler::NORMAL_MODE);
1150 }
1151 } 1123 }
1152 1124
1153 bool SyncManagerImpl::SyncInternal::OpenDirectory() { 1125 bool SyncManagerImpl::SyncInternal::OpenDirectory() {
1154 DCHECK(!initialized_) << "Should only happen once"; 1126 DCHECK(!initialized_) << "Should only happen once";
1155 1127
1156 // Set before Open(). 1128 // Set before Open().
1157 change_observer_ = 1129 change_observer_ =
1158 syncer::MakeWeakHandle(js_mutation_event_observer_.AsWeakPtr()); 1130 syncer::MakeWeakHandle(js_mutation_event_observer_.AsWeakPtr());
1159 WeakHandle<syncable::TransactionObserver> transaction_observer( 1131 WeakHandle<syncable::TransactionObserver> transaction_observer(
1160 syncer::MakeWeakHandle(js_mutation_event_observer_.AsWeakPtr())); 1132 syncer::MakeWeakHandle(js_mutation_event_observer_.AsWeakPtr()));
(...skipping 523 matching lines...) Expand 10 before | Expand all | Expand 10 after
1684 data_->RemoveObserver(observer); 1656 data_->RemoveObserver(observer);
1685 } 1657 }
1686 1658
1687 void SyncManagerImpl::StopSyncingForShutdown(const base::Closure& callback) { 1659 void SyncManagerImpl::StopSyncingForShutdown(const base::Closure& callback) {
1688 data_->StopSyncingForShutdown(callback); 1660 data_->StopSyncingForShutdown(callback);
1689 } 1661 }
1690 1662
1691 void SyncManagerImpl::SyncInternal::StopSyncingForShutdown( 1663 void SyncManagerImpl::SyncInternal::StopSyncingForShutdown(
1692 const base::Closure& callback) { 1664 const base::Closure& callback) {
1693 DVLOG(2) << "StopSyncingForShutdown"; 1665 DVLOG(2) << "StopSyncingForShutdown";
1694 if (scheduler()) // May be null in tests. 1666 scheduler()->RequestStop(callback);
1695 scheduler()->RequestStop(callback);
1696 else
1697 created_on_loop_->PostTask(FROM_HERE, callback);
1698
1699 if (connection_manager_.get()) 1667 if (connection_manager_.get())
1700 connection_manager_->TerminateAllIO(); 1668 connection_manager_->TerminateAllIO();
1701 } 1669 }
1702 1670
1703 void SyncManagerImpl::ShutdownOnSyncThread() { 1671 void SyncManagerImpl::ShutdownOnSyncThread() {
1704 DCHECK(thread_checker_.CalledOnValidThread()); 1672 DCHECK(thread_checker_.CalledOnValidThread());
1705 data_->ShutdownOnSyncThread(); 1673 data_->ShutdownOnSyncThread();
1706 } 1674 }
1707 1675
1708 void SyncManagerImpl::SyncInternal::ShutdownOnSyncThread() { 1676 void SyncManagerImpl::SyncInternal::ShutdownOnSyncThread() {
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
1761 if (!observing_ip_address_changes_) { 1729 if (!observing_ip_address_changes_) {
1762 DVLOG(1) << "IP address change dropped."; 1730 DVLOG(1) << "IP address change dropped.";
1763 return; 1731 return;
1764 } 1732 }
1765 1733
1766 OnIPAddressChangedImpl(); 1734 OnIPAddressChangedImpl();
1767 } 1735 }
1768 1736
1769 void SyncManagerImpl::SyncInternal::OnIPAddressChangedImpl() { 1737 void SyncManagerImpl::SyncInternal::OnIPAddressChangedImpl() {
1770 DCHECK(thread_checker_.CalledOnValidThread()); 1738 DCHECK(thread_checker_.CalledOnValidThread());
1771 if (scheduler()) 1739 scheduler()->OnConnectionStatusChange();
1772 scheduler()->OnConnectionStatusChange();
1773 } 1740 }
1774 1741
1775 void SyncManagerImpl::SyncInternal::OnServerConnectionEvent( 1742 void SyncManagerImpl::SyncInternal::OnServerConnectionEvent(
1776 const ServerConnectionEvent& event) { 1743 const ServerConnectionEvent& event) {
1777 DCHECK(thread_checker_.CalledOnValidThread()); 1744 DCHECK(thread_checker_.CalledOnValidThread());
1778 if (event.connection_code == 1745 if (event.connection_code ==
1779 syncer::HttpResponse::SERVER_CONNECTION_OK) { 1746 syncer::HttpResponse::SERVER_CONNECTION_OK) {
1780 FOR_EACH_OBSERVER(SyncManager::Observer, observers_, 1747 FOR_EACH_OBSERVER(SyncManager::Observer, observers_,
1781 OnConnectionStatusChange(CONNECTION_OK)); 1748 OnConnectionStatusChange(CONNECTION_OK));
1782 } 1749 }
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
1972 it->second.original, existed_before, exists_now); 1939 it->second.original, existed_before, exists_now);
1973 } 1940 }
1974 } 1941 }
1975 1942
1976 SyncStatus SyncManagerImpl::SyncInternal::GetStatus() { 1943 SyncStatus SyncManagerImpl::SyncInternal::GetStatus() {
1977 return allstatus_.status(); 1944 return allstatus_.status();
1978 } 1945 }
1979 1946
1980 void SyncManagerImpl::SyncInternal::RequestNudge( 1947 void SyncManagerImpl::SyncInternal::RequestNudge(
1981 const tracked_objects::Location& location) { 1948 const tracked_objects::Location& location) {
1982 if (scheduler()) { 1949 scheduler()->ScheduleNudgeAsync(
1983 scheduler()->ScheduleNudgeAsync( 1950 TimeDelta::FromMilliseconds(0), syncer::NUDGE_SOURCE_LOCAL,
1984 TimeDelta::FromMilliseconds(0), syncer::NUDGE_SOURCE_LOCAL, 1951 ModelTypeSet(), location);
1985 ModelTypeSet(), location);
1986 }
1987 } 1952 }
1988 1953
1989 TimeDelta SyncManagerImpl::SyncInternal::GetNudgeDelayTimeDelta( 1954 TimeDelta SyncManagerImpl::SyncInternal::GetNudgeDelayTimeDelta(
1990 const ModelType& model_type) { 1955 const ModelType& model_type) {
1991 return NudgeStrategy::GetNudgeDelayTimeDelta(model_type, this); 1956 return NudgeStrategy::GetNudgeDelayTimeDelta(model_type, this);
1992 } 1957 }
1993 1958
1994 void SyncManagerImpl::SyncInternal::RequestNudgeForDataTypes( 1959 void SyncManagerImpl::SyncInternal::RequestNudgeForDataTypes(
1995 const tracked_objects::Location& nudge_location, 1960 const tracked_objects::Location& nudge_location,
1996 ModelTypeSet types) { 1961 ModelTypeSet types) {
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after
2304 it != type_payloads.end(); ++it) { 2269 it != type_payloads.end(); ++it) {
2305 NotificationInfo* info = &notification_info_map_[it->first]; 2270 NotificationInfo* info = &notification_info_map_[it->first];
2306 info->total_count++; 2271 info->total_count++;
2307 info->payload = it->second; 2272 info->payload = it->second;
2308 } 2273 }
2309 } 2274 }
2310 2275
2311 void SyncManagerImpl::SyncInternal::OnNotificationsEnabled() { 2276 void SyncManagerImpl::SyncInternal::OnNotificationsEnabled() {
2312 DVLOG(1) << "Notifications enabled"; 2277 DVLOG(1) << "Notifications enabled";
2313 allstatus_.SetNotificationsEnabled(true); 2278 allstatus_.SetNotificationsEnabled(true);
2314 if (scheduler()) { 2279 scheduler()->SetNotificationsEnabled(true);
2315 scheduler()->set_notifications_enabled(true); 2280
2316 }
2317 // TODO(akalin): Separate onNotificationStateChange into 2281 // TODO(akalin): Separate onNotificationStateChange into
2318 // enabled/disabled events. 2282 // enabled/disabled events.
2319 if (js_event_handler_.IsInitialized()) { 2283 if (js_event_handler_.IsInitialized()) {
2320 DictionaryValue details; 2284 DictionaryValue details;
2321 details.Set("enabled", Value::CreateBooleanValue(true)); 2285 details.Set("enabled", Value::CreateBooleanValue(true));
2322 js_event_handler_.Call(FROM_HERE, 2286 js_event_handler_.Call(FROM_HERE,
2323 &JsEventHandler::HandleJsEvent, 2287 &JsEventHandler::HandleJsEvent,
2324 "onNotificationStateChange", 2288 "onNotificationStateChange",
2325 JsEventDetails(&details)); 2289 JsEventDetails(&details));
2326 } 2290 }
2327 } 2291 }
2328 2292
2329 void SyncManagerImpl::SyncInternal::OnNotificationsDisabled( 2293 void SyncManagerImpl::SyncInternal::OnNotificationsDisabled(
2330 syncer::NotificationsDisabledReason reason) { 2294 syncer::NotificationsDisabledReason reason) {
2331 DVLOG(1) << "Notifications disabled with reason " 2295 DVLOG(1) << "Notifications disabled with reason "
2332 << syncer::NotificationsDisabledReasonToString(reason); 2296 << syncer::NotificationsDisabledReasonToString(reason);
2333 allstatus_.SetNotificationsEnabled(false); 2297 allstatus_.SetNotificationsEnabled(false);
2334 if (scheduler()) { 2298 scheduler()->SetNotificationsEnabled(false);
2335 scheduler()->set_notifications_enabled(false);
2336 }
2337 if (js_event_handler_.IsInitialized()) { 2299 if (js_event_handler_.IsInitialized()) {
2338 DictionaryValue details; 2300 DictionaryValue details;
2339 details.Set("enabled", Value::CreateBooleanValue(false)); 2301 details.Set("enabled", Value::CreateBooleanValue(false));
2340 js_event_handler_.Call(FROM_HERE, 2302 js_event_handler_.Call(FROM_HERE,
2341 &JsEventHandler::HandleJsEvent, 2303 &JsEventHandler::HandleJsEvent,
2342 "onNotificationStateChange", 2304 "onNotificationStateChange",
2343 JsEventDetails(&details)); 2305 JsEventDetails(&details));
2344 } 2306 }
2345 // TODO(akalin): Treat a CREDENTIALS_REJECTED state as an auth 2307 // TODO(akalin): Treat a CREDENTIALS_REJECTED state as an auth
2346 // error. 2308 // error.
2347 } 2309 }
2348 2310
2349 void SyncManagerImpl::SyncInternal::OnIncomingNotification( 2311 void SyncManagerImpl::SyncInternal::OnIncomingNotification(
2350 const syncer::ModelTypePayloadMap& type_payloads, 2312 const syncer::ModelTypePayloadMap& type_payloads,
2351 syncer::IncomingNotificationSource source) { 2313 syncer::IncomingNotificationSource source) {
2352 DCHECK(thread_checker_.CalledOnValidThread()); 2314 DCHECK(thread_checker_.CalledOnValidThread());
2353 if (source == syncer::LOCAL_NOTIFICATION) { 2315 if (source == syncer::LOCAL_NOTIFICATION) {
2354 if (scheduler()) { 2316 scheduler()->ScheduleNudgeWithPayloadsAsync(
2355 scheduler()->ScheduleNudgeWithPayloadsAsync( 2317 TimeDelta::FromMilliseconds(kSyncRefreshDelayMsec),
2356 TimeDelta::FromMilliseconds(kSyncRefreshDelayMsec), 2318 syncer::NUDGE_SOURCE_LOCAL_REFRESH,
2357 syncer::NUDGE_SOURCE_LOCAL_REFRESH, 2319 type_payloads, FROM_HERE);
2358 type_payloads, FROM_HERE);
2359 }
2360 } else if (!type_payloads.empty()) { 2320 } else if (!type_payloads.empty()) {
2361 if (scheduler()) { 2321 scheduler()->ScheduleNudgeWithPayloadsAsync(
2362 scheduler()->ScheduleNudgeWithPayloadsAsync( 2322 TimeDelta::FromMilliseconds(kSyncSchedulerDelayMsec),
2363 TimeDelta::FromMilliseconds(kSyncSchedulerDelayMsec), 2323 syncer::NUDGE_SOURCE_NOTIFICATION,
2364 syncer::NUDGE_SOURCE_NOTIFICATION, 2324 type_payloads, FROM_HERE);
2365 type_payloads, FROM_HERE);
2366 }
2367 allstatus_.IncrementNotificationsReceived(); 2325 allstatus_.IncrementNotificationsReceived();
2368 UpdateNotificationInfo(type_payloads); 2326 UpdateNotificationInfo(type_payloads);
2369 debug_info_event_listener_.OnIncomingNotification(type_payloads); 2327 debug_info_event_listener_.OnIncomingNotification(type_payloads);
2370 } else { 2328 } else {
2371 LOG(WARNING) << "Sync received notification without any type information."; 2329 LOG(WARNING) << "Sync received notification without any type information.";
2372 } 2330 }
2373 2331
2374 if (js_event_handler_.IsInitialized()) { 2332 if (js_event_handler_.IsInitialized()) {
2375 DictionaryValue details; 2333 DictionaryValue details;
2376 ListValue* changed_types = new ListValue(); 2334 ListValue* changed_types = new ListValue();
(...skipping 17 matching lines...) Expand all
2394 void SyncManagerImpl::SyncInternal::AddObserver( 2352 void SyncManagerImpl::SyncInternal::AddObserver(
2395 SyncManager::Observer* observer) { 2353 SyncManager::Observer* observer) {
2396 observers_.AddObserver(observer); 2354 observers_.AddObserver(observer);
2397 } 2355 }
2398 2356
2399 void SyncManagerImpl::SyncInternal::RemoveObserver( 2357 void SyncManagerImpl::SyncInternal::RemoveObserver(
2400 SyncManager::Observer* observer) { 2358 SyncManager::Observer* observer) {
2401 observers_.RemoveObserver(observer); 2359 observers_.RemoveObserver(observer);
2402 } 2360 }
2403 2361
2404 void SyncManagerImpl::SyncInternal::SetSyncSchedulerForTest(
2405 scoped_ptr<SyncScheduler> sync_scheduler) {
2406 scheduler_ = sync_scheduler.Pass();
2407 }
2408
2409 SyncStatus SyncManagerImpl::GetDetailedStatus() const { 2362 SyncStatus SyncManagerImpl::GetDetailedStatus() const {
2410 return data_->GetStatus(); 2363 return data_->GetStatus();
2411 } 2364 }
2412 2365
2413 void SyncManagerImpl::SaveChanges() { 2366 void SyncManagerImpl::SaveChanges() {
2414 DCHECK(thread_checker_.CalledOnValidThread()); 2367 DCHECK(thread_checker_.CalledOnValidThread());
2415 data_->SaveChanges(); 2368 data_->SaveChanges();
2416 } 2369 }
2417 2370
2418 void SyncManagerImpl::SyncInternal::SaveChanges() { 2371 void SyncManagerImpl::SyncInternal::SaveChanges() {
(...skipping 10 matching lines...) Expand all
2429 data_->UpdateCryptographerAndNigori( 2382 data_->UpdateCryptographerAndNigori(
2430 chrome_version, 2383 chrome_version,
2431 done_callback); 2384 done_callback);
2432 } 2385 }
2433 2386
2434 TimeDelta SyncManagerImpl::GetNudgeDelayTimeDelta( 2387 TimeDelta SyncManagerImpl::GetNudgeDelayTimeDelta(
2435 const ModelType& model_type) { 2388 const ModelType& model_type) {
2436 return data_->GetNudgeDelayTimeDelta(model_type); 2389 return data_->GetNudgeDelayTimeDelta(model_type);
2437 } 2390 }
2438 2391
2439 void SyncManagerImpl::SetSyncSchedulerForTest(
2440 scoped_ptr<SyncScheduler> scheduler) {
2441 data_->SetSyncSchedulerForTest(scheduler.Pass());
2442 }
2443
2444 syncer::ModelTypeSet SyncManagerImpl::GetEncryptedDataTypesForTest() const { 2392 syncer::ModelTypeSet SyncManagerImpl::GetEncryptedDataTypesForTest() const {
2445 ReadTransaction trans(FROM_HERE, GetUserShare()); 2393 ReadTransaction trans(FROM_HERE, GetUserShare());
2446 return GetEncryptedTypes(&trans); 2394 return GetEncryptedTypes(&trans);
2447 } 2395 }
2448 2396
2449 bool SyncManagerImpl::ReceivedExperiment( 2397 bool SyncManagerImpl::ReceivedExperiment(
2450 syncer::Experiments* experiments) const { 2398 syncer::Experiments* experiments) const {
2451 ReadTransaction trans(FROM_HERE, GetUserShare()); 2399 ReadTransaction trans(FROM_HERE, GetUserShare());
2452 ReadNode node(&trans); 2400 ReadNode node(&trans);
2453 if (node.InitByTagLookup(kNigoriTag) != syncer::BaseNode::INIT_OK) { 2401 if (node.InitByTagLookup(kNigoriTag) != syncer::BaseNode::INIT_OK) {
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
2493 int SyncManagerImpl::GetDefaultNudgeDelay() { 2441 int SyncManagerImpl::GetDefaultNudgeDelay() {
2494 return kDefaultNudgeDelayMilliseconds; 2442 return kDefaultNudgeDelayMilliseconds;
2495 } 2443 }
2496 2444
2497 // static. 2445 // static.
2498 int SyncManagerImpl::GetPreferencesNudgeDelay() { 2446 int SyncManagerImpl::GetPreferencesNudgeDelay() {
2499 return kPreferencesNudgeDelayMilliseconds; 2447 return kPreferencesNudgeDelayMilliseconds;
2500 } 2448 }
2501 2449
2502 } // namespace syncer 2450 } // namespace syncer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698