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

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

Issue 2276943006: [USS] Move GetAllNodes from backend to controller (Closed)
Patch Set: update for Max 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"
(...skipping 644 matching lines...) Expand 10 before | Expand all | Expand 10 after
655 } 655 }
656 656
657 void SyncBackendHostCore::DeleteSyncDataFolder() { 657 void SyncBackendHostCore::DeleteSyncDataFolder() {
658 DCHECK(sync_loop_->task_runner()->BelongsToCurrentThread()); 658 DCHECK(sync_loop_->task_runner()->BelongsToCurrentThread());
659 if (base::DirectoryExists(sync_data_folder_path_)) { 659 if (base::DirectoryExists(sync_data_folder_path_)) {
660 if (!base::DeleteFile(sync_data_folder_path_, true)) 660 if (!base::DeleteFile(sync_data_folder_path_, true))
661 SLOG(DFATAL) << "Could not delete the Sync Data folder."; 661 SLOG(DFATAL) << "Could not delete the Sync Data folder.";
662 } 662 }
663 } 663 }
664 664
665 void SyncBackendHostCore::GetAllNodesForTypes(
666 syncer::ModelTypeSet types,
667 scoped_refptr<base::SequencedTaskRunner> task_runner,
668 base::Callback<void(const std::vector<syncer::ModelType>& type,
669 std::vector<std::unique_ptr<base::ListValue>>)>
670 callback) {
671 std::vector<syncer::ModelType> types_vector;
672 std::vector<std::unique_ptr<base::ListValue>> node_lists;
673
674 syncer::ModelSafeRoutingInfo routes;
675 registrar_->GetModelSafeRoutingInfo(&routes);
676 syncer::ModelTypeSet enabled_types = GetRoutingInfoTypes(routes);
677
678 for (syncer::ModelTypeSet::Iterator it = types.First(); it.Good(); it.Inc()) {
679 types_vector.push_back(it.Get());
680 if (!enabled_types.Has(it.Get())) {
681 node_lists.push_back(base::MakeUnique<base::ListValue>());
682 } else {
683 node_lists.push_back(sync_manager_->GetAllNodesForType(it.Get()));
684 }
685 }
686
687 task_runner->PostTask(
688 FROM_HERE, base::Bind(callback, types_vector, base::Passed(&node_lists)));
689 }
690
691 void SyncBackendHostCore::StartSavingChanges() { 665 void SyncBackendHostCore::StartSavingChanges() {
692 // We may already be shut down. 666 // We may already be shut down.
693 if (!sync_loop_) 667 if (!sync_loop_)
694 return; 668 return;
695 DCHECK(sync_loop_->task_runner()->BelongsToCurrentThread()); 669 DCHECK(sync_loop_->task_runner()->BelongsToCurrentThread());
696 DCHECK(!save_changes_timer_.get()); 670 DCHECK(!save_changes_timer_.get());
697 save_changes_timer_.reset(new base::RepeatingTimer()); 671 save_changes_timer_.reset(new base::RepeatingTimer());
698 save_changes_timer_->Start( 672 save_changes_timer_->Start(
699 FROM_HERE, base::TimeDelta::FromSeconds(kSaveChangesIntervalSeconds), 673 FROM_HERE, base::TimeDelta::FromSeconds(kSaveChangesIntervalSeconds),
700 this, &SyncBackendHostCore::SaveChanges); 674 this, &SyncBackendHostCore::SaveChanges);
(...skipping 20 matching lines...) Expand all
721 } 695 }
722 696
723 void SyncBackendHostCore::ClearServerDataDone( 697 void SyncBackendHostCore::ClearServerDataDone(
724 const base::Closure& frontend_callback) { 698 const base::Closure& frontend_callback) {
725 DCHECK(sync_loop_->task_runner()->BelongsToCurrentThread()); 699 DCHECK(sync_loop_->task_runner()->BelongsToCurrentThread());
726 host_.Call(FROM_HERE, &SyncBackendHostImpl::ClearServerDataDoneOnFrontendLoop, 700 host_.Call(FROM_HERE, &SyncBackendHostImpl::ClearServerDataDoneOnFrontendLoop,
727 frontend_callback); 701 frontend_callback);
728 } 702 }
729 703
730 } // namespace browser_sync 704 } // 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