| OLD | NEW |
| 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 29 matching lines...) Expand all Loading... |
| 40 #include "sync/js/js_event_handler.h" | 40 #include "sync/js/js_event_handler.h" |
| 41 #include "sync/js/js_reply_handler.h" | 41 #include "sync/js/js_reply_handler.h" |
| 42 #include "sync/notifier/invalidation_util.h" | 42 #include "sync/notifier/invalidation_util.h" |
| 43 #include "sync/notifier/invalidator.h" | 43 #include "sync/notifier/invalidator.h" |
| 44 #include "sync/protocol/proto_value_conversions.h" | 44 #include "sync/protocol/proto_value_conversions.h" |
| 45 #include "sync/protocol/sync.pb.h" | 45 #include "sync/protocol/sync.pb.h" |
| 46 #include "sync/syncable/directory.h" | 46 #include "sync/syncable/directory.h" |
| 47 #include "sync/syncable/entry.h" | 47 #include "sync/syncable/entry.h" |
| 48 #include "sync/syncable/in_memory_directory_backing_store.h" | 48 #include "sync/syncable/in_memory_directory_backing_store.h" |
| 49 #include "sync/syncable/on_disk_directory_backing_store.h" | 49 #include "sync/syncable/on_disk_directory_backing_store.h" |
| 50 #include "sync/util/get_session_name.h" | |
| 51 | 50 |
| 52 using base::TimeDelta; | 51 using base::TimeDelta; |
| 53 using sync_pb::GetUpdatesCallerInfo; | 52 using sync_pb::GetUpdatesCallerInfo; |
| 54 | 53 |
| 55 namespace syncer { | 54 namespace syncer { |
| 56 | 55 |
| 57 using sessions::SyncSessionContext; | 56 using sessions::SyncSessionContext; |
| 58 using syncable::ImmutableWriteTransactionInfo; | 57 using syncable::ImmutableWriteTransactionInfo; |
| 59 using syncable::SPECIFICS; | 58 using syncable::SPECIFICS; |
| 60 | 59 |
| (...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 328 retry_task.Run(); | 327 retry_task.Run(); |
| 329 | 328 |
| 330 } | 329 } |
| 331 | 330 |
| 332 void SyncManagerImpl::Init( | 331 void SyncManagerImpl::Init( |
| 333 const FilePath& database_location, | 332 const FilePath& database_location, |
| 334 const WeakHandle<JsEventHandler>& event_handler, | 333 const WeakHandle<JsEventHandler>& event_handler, |
| 335 const std::string& sync_server_and_path, | 334 const std::string& sync_server_and_path, |
| 336 int port, | 335 int port, |
| 337 bool use_ssl, | 336 bool use_ssl, |
| 338 const scoped_refptr<base::TaskRunner>& blocking_task_runner, | |
| 339 scoped_ptr<HttpPostProviderFactory> post_factory, | 337 scoped_ptr<HttpPostProviderFactory> post_factory, |
| 340 const std::vector<ModelSafeWorker*>& workers, | 338 const std::vector<ModelSafeWorker*>& workers, |
| 341 ExtensionsActivityMonitor* extensions_activity_monitor, | 339 ExtensionsActivityMonitor* extensions_activity_monitor, |
| 342 SyncManager::ChangeDelegate* change_delegate, | 340 SyncManager::ChangeDelegate* change_delegate, |
| 343 const SyncCredentials& credentials, | 341 const SyncCredentials& credentials, |
| 344 scoped_ptr<Invalidator> invalidator, | 342 scoped_ptr<Invalidator> invalidator, |
| 345 const std::string& restored_key_for_bootstrapping, | 343 const std::string& restored_key_for_bootstrapping, |
| 346 const std::string& restored_keystore_key_for_bootstrapping, | 344 const std::string& restored_keystore_key_for_bootstrapping, |
| 347 scoped_ptr<InternalComponentsFactory> internal_components_factory, | 345 scoped_ptr<InternalComponentsFactory> internal_components_factory, |
| 348 Encryptor* encryptor, | 346 Encryptor* encryptor, |
| 349 UnrecoverableErrorHandler* unrecoverable_error_handler, | 347 UnrecoverableErrorHandler* unrecoverable_error_handler, |
| 350 ReportUnrecoverableErrorFunction report_unrecoverable_error_function) { | 348 ReportUnrecoverableErrorFunction report_unrecoverable_error_function) { |
| 351 CHECK(!initialized_); | 349 CHECK(!initialized_); |
| 352 DCHECK(thread_checker_.CalledOnValidThread()); | 350 DCHECK(thread_checker_.CalledOnValidThread()); |
| 353 DCHECK(post_factory.get()); | 351 DCHECK(post_factory.get()); |
| 354 DCHECK(!credentials.email.empty()); | 352 DCHECK(!credentials.email.empty()); |
| 355 DCHECK(!credentials.sync_token.empty()); | 353 DCHECK(!credentials.sync_token.empty()); |
| 356 DVLOG(1) << "SyncManager starting Init..."; | 354 DVLOG(1) << "SyncManager starting Init..."; |
| 357 | 355 |
| 358 weak_handle_this_ = MakeWeakHandle(weak_ptr_factory_.GetWeakPtr()); | 356 weak_handle_this_ = MakeWeakHandle(weak_ptr_factory_.GetWeakPtr()); |
| 359 | 357 |
| 360 blocking_task_runner_ = blocking_task_runner; | |
| 361 | |
| 362 change_delegate_ = change_delegate; | 358 change_delegate_ = change_delegate; |
| 363 | 359 |
| 364 invalidator_ = invalidator.Pass(); | 360 invalidator_ = invalidator.Pass(); |
| 365 invalidator_->RegisterHandler(this); | 361 invalidator_->RegisterHandler(this); |
| 366 | 362 |
| 367 AddObserver(&js_sync_manager_observer_); | 363 AddObserver(&js_sync_manager_observer_); |
| 368 SetJsEventHandler(event_handler); | 364 SetJsEventHandler(event_handler); |
| 369 | 365 |
| 370 AddObserver(&debug_info_event_listener_); | 366 AddObserver(&debug_info_event_listener_); |
| 371 | 367 |
| (...skipping 917 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1289 | 1285 |
| 1290 const std::string& SyncManagerImpl::username_for_share() const { | 1286 const std::string& SyncManagerImpl::username_for_share() const { |
| 1291 return share_.name; | 1287 return share_.name; |
| 1292 } | 1288 } |
| 1293 | 1289 |
| 1294 UserShare* SyncManagerImpl::GetUserShare() { | 1290 UserShare* SyncManagerImpl::GetUserShare() { |
| 1295 DCHECK(initialized_); | 1291 DCHECK(initialized_); |
| 1296 return &share_; | 1292 return &share_; |
| 1297 } | 1293 } |
| 1298 | 1294 |
| 1295 const std::string SyncManagerImpl::cache_guid() { |
| 1296 DCHECK(initialized_); |
| 1297 return directory()->cache_guid(); |
| 1298 } |
| 1299 |
| 1299 bool SyncManagerImpl::ReceivedExperiment(Experiments* experiments) { | 1300 bool SyncManagerImpl::ReceivedExperiment(Experiments* experiments) { |
| 1300 ReadTransaction trans(FROM_HERE, GetUserShare()); | 1301 ReadTransaction trans(FROM_HERE, GetUserShare()); |
| 1301 ReadNode nigori_node(&trans); | 1302 ReadNode nigori_node(&trans); |
| 1302 if (nigori_node.InitByTagLookup(kNigoriTag) != BaseNode::INIT_OK) { | 1303 if (nigori_node.InitByTagLookup(kNigoriTag) != BaseNode::INIT_OK) { |
| 1303 DVLOG(1) << "Couldn't find Nigori node."; | 1304 DVLOG(1) << "Couldn't find Nigori node."; |
| 1304 return false; | 1305 return false; |
| 1305 } | 1306 } |
| 1306 bool found_experiment = false; | 1307 bool found_experiment = false; |
| 1307 if (nigori_node.GetNigoriSpecifics().sync_tab_favicons()) { | 1308 if (nigori_node.GetNigoriSpecifics().sync_tab_favicons()) { |
| 1308 experiments->sync_tab_favicons = true; | 1309 experiments->sync_tab_favicons = true; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 1334 int SyncManagerImpl::GetDefaultNudgeDelay() { | 1335 int SyncManagerImpl::GetDefaultNudgeDelay() { |
| 1335 return kDefaultNudgeDelayMilliseconds; | 1336 return kDefaultNudgeDelayMilliseconds; |
| 1336 } | 1337 } |
| 1337 | 1338 |
| 1338 // static. | 1339 // static. |
| 1339 int SyncManagerImpl::GetPreferencesNudgeDelay() { | 1340 int SyncManagerImpl::GetPreferencesNudgeDelay() { |
| 1340 return kPreferencesNudgeDelayMilliseconds; | 1341 return kPreferencesNudgeDelayMilliseconds; |
| 1341 } | 1342 } |
| 1342 | 1343 |
| 1343 } // namespace syncer | 1344 } // namespace syncer |
| OLD | NEW |