OLD | NEW |
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 "build/build_config.h" | 5 #include "build/build_config.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 DCHECK(!core_ && !frontend_) << "Must call Shutdown before destructor."; | 84 DCHECK(!core_ && !frontend_) << "Must call Shutdown before destructor."; |
85 DCHECK(registrar_.workers.empty()); | 85 DCHECK(registrar_.workers.empty()); |
86 } | 86 } |
87 | 87 |
88 void SyncBackendHost::Initialize( | 88 void SyncBackendHost::Initialize( |
89 SyncFrontend* frontend, | 89 SyncFrontend* frontend, |
90 const GURL& sync_service_url, | 90 const GURL& sync_service_url, |
91 const syncable::ModelTypeSet& types, | 91 const syncable::ModelTypeSet& types, |
92 URLRequestContextGetter* baseline_context_getter, | 92 URLRequestContextGetter* baseline_context_getter, |
93 const SyncCredentials& credentials, | 93 const SyncCredentials& credentials, |
94 bool delete_sync_data_folder, | 94 bool delete_sync_data_folder) { |
95 const notifier::NotifierOptions& notifier_options) { | |
96 if (!core_thread_.Start()) | 95 if (!core_thread_.Start()) |
97 return; | 96 return; |
98 | 97 |
99 frontend_ = frontend; | 98 frontend_ = frontend; |
100 DCHECK(frontend); | 99 DCHECK(frontend); |
101 | 100 |
102 // Create a worker for the UI thread and route bookmark changes to it. | 101 // Create a worker for the UI thread and route bookmark changes to it. |
103 // TODO(tim): Pull this into a method to reuse. For now we don't even | 102 // TODO(tim): Pull this into a method to reuse. For now we don't even |
104 // need to lock because we init before the syncapi exists and we tear down | 103 // need to lock because we init before the syncapi exists and we tear down |
105 // after the syncapi is destroyed. Make sure to NULL-check workers_ indices | 104 // after the syncapi is destroyed. Make sure to NULL-check workers_ indices |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 } | 137 } |
139 | 138 |
140 // Nigori is populated by default now. | 139 // Nigori is populated by default now. |
141 registrar_.routing_info[syncable::NIGORI] = GROUP_PASSIVE; | 140 registrar_.routing_info[syncable::NIGORI] = GROUP_PASSIVE; |
142 | 141 |
143 InitCore(Core::DoInitializeOptions( | 142 InitCore(Core::DoInitializeOptions( |
144 sync_service_url, | 143 sync_service_url, |
145 MakeHttpBridgeFactory(baseline_context_getter), | 144 MakeHttpBridgeFactory(baseline_context_getter), |
146 credentials, | 145 credentials, |
147 delete_sync_data_folder, | 146 delete_sync_data_folder, |
148 notifier_options, | |
149 RestoreEncryptionBootstrapToken(), | 147 RestoreEncryptionBootstrapToken(), |
150 false)); | 148 false)); |
151 } | 149 } |
152 | 150 |
153 void SyncBackendHost::PersistEncryptionBootstrapToken( | 151 void SyncBackendHost::PersistEncryptionBootstrapToken( |
154 const std::string& token) { | 152 const std::string& token) { |
155 PrefService* prefs = profile_->GetPrefs(); | 153 PrefService* prefs = profile_->GetPrefs(); |
156 | 154 |
157 prefs->SetString(prefs::kEncryptionBootstrapToken, token); | 155 prefs->SetString(prefs::kEncryptionBootstrapToken, token); |
158 prefs->ScheduleSavePersistentPrefs(); | 156 prefs->ScheduleSavePersistentPrefs(); |
(...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
584 return; | 582 return; |
585 DCHECK_EQ(MessageLoop::current(), host_->frontend_loop_); | 583 DCHECK_EQ(MessageLoop::current(), host_->frontend_loop_); |
586 host_->frontend_->OnEncryptionComplete(encrypted_types); | 584 host_->frontend_->OnEncryptionComplete(encrypted_types); |
587 } | 585 } |
588 | 586 |
589 SyncBackendHost::Core::DoInitializeOptions::DoInitializeOptions( | 587 SyncBackendHost::Core::DoInitializeOptions::DoInitializeOptions( |
590 const GURL& service_url, | 588 const GURL& service_url, |
591 sync_api::HttpPostProviderFactory* http_bridge_factory, | 589 sync_api::HttpPostProviderFactory* http_bridge_factory, |
592 const sync_api::SyncCredentials& credentials, | 590 const sync_api::SyncCredentials& credentials, |
593 bool delete_sync_data_folder, | 591 bool delete_sync_data_folder, |
594 const notifier::NotifierOptions& notifier_options, | |
595 std::string restored_key_for_bootstrapping, | 592 std::string restored_key_for_bootstrapping, |
596 bool setup_for_test_mode) | 593 bool setup_for_test_mode) |
597 : service_url(service_url), | 594 : service_url(service_url), |
598 http_bridge_factory(http_bridge_factory), | 595 http_bridge_factory(http_bridge_factory), |
599 credentials(credentials), | 596 credentials(credentials), |
600 delete_sync_data_folder(delete_sync_data_folder), | 597 delete_sync_data_folder(delete_sync_data_folder), |
601 notifier_options(notifier_options), | |
602 restored_key_for_bootstrapping(restored_key_for_bootstrapping), | 598 restored_key_for_bootstrapping(restored_key_for_bootstrapping), |
603 setup_for_test_mode(setup_for_test_mode) { | 599 setup_for_test_mode(setup_for_test_mode) { |
604 } | 600 } |
605 | 601 |
606 SyncBackendHost::Core::DoInitializeOptions::~DoInitializeOptions() {} | 602 SyncBackendHost::Core::DoInitializeOptions::~DoInitializeOptions() {} |
607 | 603 |
608 sync_api::UserShare* SyncBackendHost::GetUserShare() const { | 604 sync_api::UserShare* SyncBackendHost::GetUserShare() const { |
609 DCHECK(syncapi_initialized_); | 605 DCHECK(syncapi_initialized_); |
610 return core_->syncapi()->GetUserShare(); | 606 return core_->syncapi()->GetUserShare(); |
611 } | 607 } |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
709 const FilePath& path_str = host_->sync_data_folder_path(); | 705 const FilePath& path_str = host_->sync_data_folder_path(); |
710 success = syncapi_->Init( | 706 success = syncapi_->Init( |
711 path_str, | 707 path_str, |
712 (options.service_url.host() + options.service_url.path()).c_str(), | 708 (options.service_url.host() + options.service_url.path()).c_str(), |
713 options.service_url.EffectiveIntPort(), | 709 options.service_url.EffectiveIntPort(), |
714 options.service_url.SchemeIsSecure(), | 710 options.service_url.SchemeIsSecure(), |
715 options.http_bridge_factory, | 711 options.http_bridge_factory, |
716 host_, // ModelSafeWorkerRegistrar. | 712 host_, // ModelSafeWorkerRegistrar. |
717 MakeUserAgentForSyncapi().c_str(), | 713 MakeUserAgentForSyncapi().c_str(), |
718 options.credentials, | 714 options.credentials, |
719 options.notifier_options, | |
720 options.restored_key_for_bootstrapping, | 715 options.restored_key_for_bootstrapping, |
721 options.setup_for_test_mode); | 716 options.setup_for_test_mode); |
722 DCHECK(success) << "Syncapi initialization failed!"; | 717 DCHECK(success) << "Syncapi initialization failed!"; |
723 } | 718 } |
724 | 719 |
725 void SyncBackendHost::Core::DoUpdateCredentials( | 720 void SyncBackendHost::Core::DoUpdateCredentials( |
726 const SyncCredentials& credentials) { | 721 const SyncCredentials& credentials) { |
727 DCHECK(MessageLoop::current() == host_->core_thread_.message_loop()); | 722 DCHECK(MessageLoop::current() == host_->core_thread_.message_loop()); |
728 syncapi_->UpdateCredentials(credentials); | 723 syncapi_->UpdateCredentials(credentials); |
729 } | 724 } |
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1132 } | 1127 } |
1133 | 1128 |
1134 void SyncBackendHost::Core::DoProcessMessage( | 1129 void SyncBackendHost::Core::DoProcessMessage( |
1135 const std::string& name, const JsArgList& args, | 1130 const std::string& name, const JsArgList& args, |
1136 const JsEventHandler* sender) { | 1131 const JsEventHandler* sender) { |
1137 DCHECK_EQ(MessageLoop::current(), host_->core_thread_.message_loop()); | 1132 DCHECK_EQ(MessageLoop::current(), host_->core_thread_.message_loop()); |
1138 syncapi_->GetJsBackend()->ProcessMessage(name, args, sender); | 1133 syncapi_->GetJsBackend()->ProcessMessage(name, args, sender); |
1139 } | 1134 } |
1140 | 1135 |
1141 } // namespace browser_sync | 1136 } // namespace browser_sync |
OLD | NEW |