| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "components/sync_driver/glue/sync_backend_host_core.h" | 5 #include "components/sync_driver/glue/sync_backend_host_core.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <utility> | 9 #include <utility> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 | 70 |
| 71 DoInitializeOptions::DoInitializeOptions( | 71 DoInitializeOptions::DoInitializeOptions( |
| 72 base::MessageLoop* sync_loop, | 72 base::MessageLoop* sync_loop, |
| 73 SyncBackendRegistrar* registrar, | 73 SyncBackendRegistrar* registrar, |
| 74 const syncer::ModelSafeRoutingInfo& routing_info, | 74 const syncer::ModelSafeRoutingInfo& routing_info, |
| 75 const std::vector<scoped_refptr<syncer::ModelSafeWorker>>& workers, | 75 const std::vector<scoped_refptr<syncer::ModelSafeWorker>>& workers, |
| 76 const scoped_refptr<syncer::ExtensionsActivity>& extensions_activity, | 76 const scoped_refptr<syncer::ExtensionsActivity>& extensions_activity, |
| 77 const syncer::WeakHandle<syncer::JsEventHandler>& event_handler, | 77 const syncer::WeakHandle<syncer::JsEventHandler>& event_handler, |
| 78 const GURL& service_url, | 78 const GURL& service_url, |
| 79 const std::string& sync_user_agent, | 79 const std::string& sync_user_agent, |
| 80 scoped_ptr<syncer::HttpPostProviderFactory> http_bridge_factory, | 80 std::unique_ptr<syncer::HttpPostProviderFactory> http_bridge_factory, |
| 81 const syncer::SyncCredentials& credentials, | 81 const syncer::SyncCredentials& credentials, |
| 82 const std::string& invalidator_client_id, | 82 const std::string& invalidator_client_id, |
| 83 scoped_ptr<syncer::SyncManagerFactory> sync_manager_factory, | 83 std::unique_ptr<syncer::SyncManagerFactory> sync_manager_factory, |
| 84 bool delete_sync_data_folder, | 84 bool delete_sync_data_folder, |
| 85 const std::string& restored_key_for_bootstrapping, | 85 const std::string& restored_key_for_bootstrapping, |
| 86 const std::string& restored_keystore_key_for_bootstrapping, | 86 const std::string& restored_keystore_key_for_bootstrapping, |
| 87 scoped_ptr<syncer::InternalComponentsFactory> internal_components_factory, | 87 std::unique_ptr<syncer::InternalComponentsFactory> |
| 88 internal_components_factory, |
| 88 const syncer::WeakHandle<syncer::UnrecoverableErrorHandler>& | 89 const syncer::WeakHandle<syncer::UnrecoverableErrorHandler>& |
| 89 unrecoverable_error_handler, | 90 unrecoverable_error_handler, |
| 90 const base::Closure& report_unrecoverable_error_function, | 91 const base::Closure& report_unrecoverable_error_function, |
| 91 scoped_ptr<syncer::SyncEncryptionHandler::NigoriState> saved_nigori_state, | 92 std::unique_ptr<syncer::SyncEncryptionHandler::NigoriState> |
| 93 saved_nigori_state, |
| 92 syncer::PassphraseTransitionClearDataOption clear_data_option, | 94 syncer::PassphraseTransitionClearDataOption clear_data_option, |
| 93 const std::map<syncer::ModelType, int64_t>& invalidation_versions) | 95 const std::map<syncer::ModelType, int64_t>& invalidation_versions) |
| 94 : sync_loop(sync_loop), | 96 : sync_loop(sync_loop), |
| 95 registrar(registrar), | 97 registrar(registrar), |
| 96 routing_info(routing_info), | 98 routing_info(routing_info), |
| 97 workers(workers), | 99 workers(workers), |
| 98 extensions_activity(extensions_activity), | 100 extensions_activity(extensions_activity), |
| 99 event_handler(event_handler), | 101 event_handler(event_handler), |
| 100 service_url(service_url), | 102 service_url(service_url), |
| 101 sync_user_agent(sync_user_agent), | 103 sync_user_agent(sync_user_agent), |
| (...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 375 host_.Call( | 377 host_.Call( |
| 376 FROM_HERE, | 378 FROM_HERE, |
| 377 &SyncBackendHostImpl::HandleMigrationRequestedOnFrontendLoop, | 379 &SyncBackendHostImpl::HandleMigrationRequestedOnFrontendLoop, |
| 378 types); | 380 types); |
| 379 } | 381 } |
| 380 | 382 |
| 381 void SyncBackendHostCore::OnProtocolEvent( | 383 void SyncBackendHostCore::OnProtocolEvent( |
| 382 const syncer::ProtocolEvent& event) { | 384 const syncer::ProtocolEvent& event) { |
| 383 // TODO(rlarocque): Find a way to pass event_clone as a scoped_ptr. | 385 // TODO(rlarocque): Find a way to pass event_clone as a scoped_ptr. |
| 384 if (forward_protocol_events_) { | 386 if (forward_protocol_events_) { |
| 385 scoped_ptr<syncer::ProtocolEvent> event_clone(event.Clone()); | 387 std::unique_ptr<syncer::ProtocolEvent> event_clone(event.Clone()); |
| 386 host_.Call( | 388 host_.Call( |
| 387 FROM_HERE, | 389 FROM_HERE, |
| 388 &SyncBackendHostImpl::HandleProtocolEventOnFrontendLoop, | 390 &SyncBackendHostImpl::HandleProtocolEventOnFrontendLoop, |
| 389 event_clone.release()); | 391 event_clone.release()); |
| 390 } | 392 } |
| 391 } | 393 } |
| 392 | 394 |
| 393 void SyncBackendHostCore::DoOnInvalidatorStateChange( | 395 void SyncBackendHostCore::DoOnInvalidatorStateChange( |
| 394 syncer::InvalidatorState state) { | 396 syncer::InvalidatorState state) { |
| 395 DCHECK_EQ(base::MessageLoop::current(), sync_loop_); | 397 DCHECK_EQ(base::MessageLoop::current(), sync_loop_); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 413 auto last_invalidation = last_invalidation_versions_.find(type); | 415 auto last_invalidation = last_invalidation_versions_.find(type); |
| 414 if (!invalidation.is_unknown_version() && | 416 if (!invalidation.is_unknown_version() && |
| 415 last_invalidation != last_invalidation_versions_.end() && | 417 last_invalidation != last_invalidation_versions_.end() && |
| 416 invalidation.version() <= last_invalidation->second) { | 418 invalidation.version() <= last_invalidation->second) { |
| 417 DVLOG(1) << "Ignoring redundant invalidation for " | 419 DVLOG(1) << "Ignoring redundant invalidation for " |
| 418 << syncer::ModelTypeToString(type) << " with version " | 420 << syncer::ModelTypeToString(type) << " with version " |
| 419 << invalidation.version() << ", last seen version was " | 421 << invalidation.version() << ", last seen version was " |
| 420 << last_invalidation->second; | 422 << last_invalidation->second; |
| 421 continue; | 423 continue; |
| 422 } | 424 } |
| 423 scoped_ptr<syncer::InvalidationInterface> inv_adapter( | 425 std::unique_ptr<syncer::InvalidationInterface> inv_adapter( |
| 424 new InvalidationAdapter(invalidation)); | 426 new InvalidationAdapter(invalidation)); |
| 425 sync_manager_->OnIncomingInvalidation(type, std::move(inv_adapter)); | 427 sync_manager_->OnIncomingInvalidation(type, std::move(inv_adapter)); |
| 426 if (!invalidation.is_unknown_version()) | 428 if (!invalidation.is_unknown_version()) |
| 427 last_invalidation_versions_[type] = invalidation.version(); | 429 last_invalidation_versions_[type] = invalidation.version(); |
| 428 } | 430 } |
| 429 } | 431 } |
| 430 } | 432 } |
| 431 | 433 |
| 432 host_.Call( | 434 host_.Call( |
| 433 FROM_HERE, | 435 FROM_HERE, |
| 434 &SyncBackendHostImpl::UpdateInvalidationVersions, | 436 &SyncBackendHostImpl::UpdateInvalidationVersions, |
| 435 last_invalidation_versions_); | 437 last_invalidation_versions_); |
| 436 } | 438 } |
| 437 | 439 |
| 438 void SyncBackendHostCore::DoInitialize( | 440 void SyncBackendHostCore::DoInitialize( |
| 439 scoped_ptr<DoInitializeOptions> options) { | 441 std::unique_ptr<DoInitializeOptions> options) { |
| 440 DCHECK(!sync_loop_); | 442 DCHECK(!sync_loop_); |
| 441 sync_loop_ = options->sync_loop; | 443 sync_loop_ = options->sync_loop; |
| 442 DCHECK(sync_loop_); | 444 DCHECK(sync_loop_); |
| 443 | 445 |
| 444 // Finish initializing the HttpBridgeFactory. We do this here because | 446 // Finish initializing the HttpBridgeFactory. We do this here because |
| 445 // building the user agent may block on some platforms. | 447 // building the user agent may block on some platforms. |
| 446 options->http_bridge_factory->Init(options->sync_user_agent, | 448 options->http_bridge_factory->Init(options->sync_user_agent, |
| 447 base::Bind(&BindFetcherToDataTracker)); | 449 base::Bind(&BindFetcherToDataTracker)); |
| 448 | 450 |
| 449 // Blow away the partial or corrupt sync data folder before doing any more | 451 // Blow away the partial or corrupt sync data folder before doing any more |
| (...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 793 | 795 |
| 794 void SyncBackendHostCore::ClearServerDataDone( | 796 void SyncBackendHostCore::ClearServerDataDone( |
| 795 const base::Closure& frontend_callback) { | 797 const base::Closure& frontend_callback) { |
| 796 DCHECK_EQ(base::MessageLoop::current(), sync_loop_); | 798 DCHECK_EQ(base::MessageLoop::current(), sync_loop_); |
| 797 host_.Call(FROM_HERE, &SyncBackendHostImpl::ClearServerDataDoneOnFrontendLoop, | 799 host_.Call(FROM_HERE, &SyncBackendHostImpl::ClearServerDataDoneOnFrontendLoop, |
| 798 frontend_callback); | 800 frontend_callback); |
| 799 } | 801 } |
| 800 | 802 |
| 801 | 803 |
| 802 } // namespace browser_sync | 804 } // namespace browser_sync |
| OLD | NEW |