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

Side by Side Diff: components/sync/driver/glue/sync_backend_host_core.cc

Issue 2284283002: Remove stl_util's STLElementDeleter from sync. (Closed)
Patch Set: Created 4 years, 3 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
OLDNEW
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 <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/files/file_util.h" 10 #include "base/files/file_util.h"
11 #include "base/location.h" 11 #include "base/location.h"
12 #include "base/memory/ptr_util.h"
12 #include "base/single_thread_task_runner.h" 13 #include "base/single_thread_task_runner.h"
13 #include "components/data_use_measurement/core/data_use_user_data.h" 14 #include "components/data_use_measurement/core/data_use_user_data.h"
14 #include "components/invalidation/public/invalidation_util.h" 15 #include "components/invalidation/public/invalidation_util.h"
15 #include "components/invalidation/public/object_id_invalidation_map.h" 16 #include "components/invalidation/public/object_id_invalidation_map.h"
16 #include "components/sync/core/http_post_provider_factory.h" 17 #include "components/sync/core/http_post_provider_factory.h"
17 #include "components/sync/core/internal_components_factory.h" 18 #include "components/sync/core/internal_components_factory.h"
18 #include "components/sync/core/sync_manager.h" 19 #include "components/sync/core/sync_manager.h"
19 #include "components/sync/core/sync_manager_factory.h" 20 #include "components/sync/core/sync_manager_factory.h"
20 #include "components/sync/device_info/local_device_info_provider_impl.h" 21 #include "components/sync/device_info/local_device_info_provider_impl.h"
21 #include "components/sync/driver/glue/sync_backend_registrar.h" 22 #include "components/sync/driver/glue/sync_backend_registrar.h"
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 } 323 }
323 324
324 void SyncBackendHostCore::OnMigrationRequested(syncer::ModelTypeSet types) { 325 void SyncBackendHostCore::OnMigrationRequested(syncer::ModelTypeSet types) {
325 DCHECK(sync_loop_->task_runner()->BelongsToCurrentThread()); 326 DCHECK(sync_loop_->task_runner()->BelongsToCurrentThread());
326 host_.Call(FROM_HERE, 327 host_.Call(FROM_HERE,
327 &SyncBackendHostImpl::HandleMigrationRequestedOnFrontendLoop, 328 &SyncBackendHostImpl::HandleMigrationRequestedOnFrontendLoop,
328 types); 329 types);
329 } 330 }
330 331
331 void SyncBackendHostCore::OnProtocolEvent(const syncer::ProtocolEvent& event) { 332 void SyncBackendHostCore::OnProtocolEvent(const syncer::ProtocolEvent& event) {
332 // TODO(rlarocque): Find a way to pass event_clone as a scoped_ptr.
333 if (forward_protocol_events_) { 333 if (forward_protocol_events_) {
334 std::unique_ptr<syncer::ProtocolEvent> event_clone(event.Clone()); 334 std::unique_ptr<syncer::ProtocolEvent> event_clone(event.Clone());
335 host_.Call(FROM_HERE, 335 host_.Call(FROM_HERE,
336 &SyncBackendHostImpl::HandleProtocolEventOnFrontendLoop, 336 &SyncBackendHostImpl::HandleProtocolEventOnFrontendLoop,
337 event_clone.release()); 337 base::Passed(std::move(event_clone)));
338 } 338 }
339 } 339 }
340 340
341 void SyncBackendHostCore::DoOnInvalidatorStateChange( 341 void SyncBackendHostCore::DoOnInvalidatorStateChange(
342 syncer::InvalidatorState state) { 342 syncer::InvalidatorState state) {
343 DCHECK(sync_loop_->task_runner()->BelongsToCurrentThread()); 343 DCHECK(sync_loop_->task_runner()->BelongsToCurrentThread());
344 sync_manager_->SetInvalidatorEnabled(state == syncer::INVALIDATIONS_ENABLED); 344 sync_manager_->SetInvalidatorEnabled(state == syncer::INVALIDATIONS_ENABLED);
345 } 345 }
346 346
347 void SyncBackendHostCore::DoOnIncomingInvalidation( 347 void SyncBackendHostCore::DoOnIncomingInvalidation(
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
609 retry_callback); 609 retry_callback);
610 } 610 }
611 611
612 void SyncBackendHostCore::SendBufferedProtocolEventsAndEnableForwarding() { 612 void SyncBackendHostCore::SendBufferedProtocolEventsAndEnableForwarding() {
613 DCHECK(sync_loop_->task_runner()->BelongsToCurrentThread()); 613 DCHECK(sync_loop_->task_runner()->BelongsToCurrentThread());
614 forward_protocol_events_ = true; 614 forward_protocol_events_ = true;
615 615
616 if (sync_manager_) { 616 if (sync_manager_) {
617 // Grab our own copy of the buffered events. 617 // Grab our own copy of the buffered events.
618 // The buffer is not modified by this operation. 618 // The buffer is not modified by this operation.
619 std::vector<syncer::ProtocolEvent*> buffered_events; 619 std::vector<std::unique_ptr<syncer::ProtocolEvent>> buffered_events =
620 sync_manager_->GetBufferedProtocolEvents().release(&buffered_events); 620 sync_manager_->GetBufferedProtocolEvents();
621 621
622 // Send them all over the fence to the host. 622 // Send them all over the fence to the host.
623 for (std::vector<syncer::ProtocolEvent*>::iterator it = 623 for (auto& event : buffered_events) {
624 buffered_events.begin();
625 it != buffered_events.end(); ++it) {
626 // TODO(rlarocque): Make it explicit that host_ takes ownership.
627 host_.Call(FROM_HERE, 624 host_.Call(FROM_HERE,
628 &SyncBackendHostImpl::HandleProtocolEventOnFrontendLoop, *it); 625 &SyncBackendHostImpl::HandleProtocolEventOnFrontendLoop,
626 base::Passed(std::move(event)));
629 } 627 }
630 } 628 }
631 } 629 }
632 630
633 void SyncBackendHostCore::DisableProtocolEventForwarding() { 631 void SyncBackendHostCore::DisableProtocolEventForwarding() {
634 forward_protocol_events_ = false; 632 forward_protocol_events_ = false;
635 } 633 }
636 634
637 void SyncBackendHostCore::EnableDirectoryTypeDebugInfoForwarding() { 635 void SyncBackendHostCore::EnableDirectoryTypeDebugInfoForwarding() {
638 DCHECK(sync_manager_); 636 DCHECK(sync_manager_);
(...skipping 22 matching lines...) Expand all
661 if (base::DirectoryExists(sync_data_folder_path_)) { 659 if (base::DirectoryExists(sync_data_folder_path_)) {
662 if (!base::DeleteFile(sync_data_folder_path_, true)) 660 if (!base::DeleteFile(sync_data_folder_path_, true))
663 SLOG(DFATAL) << "Could not delete the Sync Data folder."; 661 SLOG(DFATAL) << "Could not delete the Sync Data folder.";
664 } 662 }
665 } 663 }
666 664
667 void SyncBackendHostCore::GetAllNodesForTypes( 665 void SyncBackendHostCore::GetAllNodesForTypes(
668 syncer::ModelTypeSet types, 666 syncer::ModelTypeSet types,
669 scoped_refptr<base::SequencedTaskRunner> task_runner, 667 scoped_refptr<base::SequencedTaskRunner> task_runner,
670 base::Callback<void(const std::vector<syncer::ModelType>& type, 668 base::Callback<void(const std::vector<syncer::ModelType>& type,
671 ScopedVector<base::ListValue>)> callback) { 669 std::vector<std::unique_ptr<base::ListValue>>)>
670 callback) {
672 std::vector<syncer::ModelType> types_vector; 671 std::vector<syncer::ModelType> types_vector;
673 ScopedVector<base::ListValue> node_lists; 672 std::vector<std::unique_ptr<base::ListValue>> node_lists;
674 673
675 syncer::ModelSafeRoutingInfo routes; 674 syncer::ModelSafeRoutingInfo routes;
676 registrar_->GetModelSafeRoutingInfo(&routes); 675 registrar_->GetModelSafeRoutingInfo(&routes);
677 syncer::ModelTypeSet enabled_types = GetRoutingInfoTypes(routes); 676 syncer::ModelTypeSet enabled_types = GetRoutingInfoTypes(routes);
678 677
679 for (syncer::ModelTypeSet::Iterator it = types.First(); it.Good(); it.Inc()) { 678 for (syncer::ModelTypeSet::Iterator it = types.First(); it.Good(); it.Inc()) {
680 types_vector.push_back(it.Get()); 679 types_vector.push_back(it.Get());
681 if (!enabled_types.Has(it.Get())) { 680 if (!enabled_types.Has(it.Get())) {
682 node_lists.push_back(new base::ListValue()); 681 node_lists.push_back(base::MakeUnique<base::ListValue>());
683 } else { 682 } else {
684 node_lists.push_back( 683 node_lists.push_back(sync_manager_->GetAllNodesForType(it.Get()));
685 sync_manager_->GetAllNodesForType(it.Get()).release());
686 } 684 }
687 } 685 }
688 686
689 task_runner->PostTask( 687 task_runner->PostTask(
690 FROM_HERE, base::Bind(callback, types_vector, base::Passed(&node_lists))); 688 FROM_HERE, base::Bind(callback, types_vector, base::Passed(&node_lists)));
691 } 689 }
692 690
693 void SyncBackendHostCore::StartSavingChanges() { 691 void SyncBackendHostCore::StartSavingChanges() {
694 // We may already be shut down. 692 // We may already be shut down.
695 if (!sync_loop_) 693 if (!sync_loop_)
(...skipping 27 matching lines...) Expand all
723 } 721 }
724 722
725 void SyncBackendHostCore::ClearServerDataDone( 723 void SyncBackendHostCore::ClearServerDataDone(
726 const base::Closure& frontend_callback) { 724 const base::Closure& frontend_callback) {
727 DCHECK(sync_loop_->task_runner()->BelongsToCurrentThread()); 725 DCHECK(sync_loop_->task_runner()->BelongsToCurrentThread());
728 host_.Call(FROM_HERE, &SyncBackendHostImpl::ClearServerDataDoneOnFrontendLoop, 726 host_.Call(FROM_HERE, &SyncBackendHostImpl::ClearServerDataDoneOnFrontendLoop,
729 frontend_callback); 727 frontend_callback);
730 } 728 }
731 729
732 } // namespace browser_sync 730 } // namespace browser_sync
OLDNEW
« no previous file with comments | « components/sync/driver/glue/sync_backend_host_core.h ('k') | components/sync/driver/glue/sync_backend_host_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698