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

Side by Side Diff: chrome/browser/sync/glue/sync_backend_host_core.cc

Issue 224563004: sync: Re-implement getAllNodes WebUI function (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Comment fix Created 6 years, 8 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 | Annotate | Revision Log
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 "chrome/browser/sync/glue/sync_backend_host_core.h" 5 #include "chrome/browser/sync/glue/sync_backend_host_core.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/metrics/histogram.h" 9 #include "base/metrics/histogram.h"
10 #include "chrome/browser/sync/glue/device_info.h" 10 #include "chrome/browser/sync/glue/device_info.h"
(...skipping 622 matching lines...) Expand 10 before | Expand all | Expand 10 after
633 } 633 }
634 634
635 void SyncBackendHostCore::DeleteSyncDataFolder() { 635 void SyncBackendHostCore::DeleteSyncDataFolder() {
636 DCHECK_EQ(base::MessageLoop::current(), sync_loop_); 636 DCHECK_EQ(base::MessageLoop::current(), sync_loop_);
637 if (base::DirectoryExists(sync_data_folder_path_)) { 637 if (base::DirectoryExists(sync_data_folder_path_)) {
638 if (!base::DeleteFile(sync_data_folder_path_, true)) 638 if (!base::DeleteFile(sync_data_folder_path_, true))
639 SLOG(DFATAL) << "Could not delete the Sync Data folder."; 639 SLOG(DFATAL) << "Could not delete the Sync Data folder.";
640 } 640 }
641 } 641 }
642 642
643 void SyncBackendHostCore::GetAllNodesForTypes(
644 syncer::ModelTypeSet types,
645 scoped_refptr<base::SequencedTaskRunner> task_runner,
646 base::Callback<void(const std::vector<syncer::ModelType>& type,
647 ScopedVector<base::ListValue>)> callback) {
648 std::vector<syncer::ModelType> types_vector;
649 ScopedVector<base::ListValue> node_lists;
650
651 syncer::ModelSafeRoutingInfo routes;
652 registrar_->GetModelSafeRoutingInfo(&routes);
653 syncer::ModelTypeSet enabled_types = GetRoutingInfoTypes(routes);
654
655 for (syncer::ModelTypeSet::Iterator it = types.First(); it.Good(); it.Inc()) {
656 types_vector.push_back(it.Get());
657 if (!enabled_types.Has(it.Get())) {
658 node_lists.push_back(new base::ListValue());
659 } else {
660 node_lists.push_back(
661 sync_manager_->GetAllNodesForType(it.Get()).release());
662 }
663 }
664
665 task_runner->PostTask(
666 FROM_HERE,
667 base::Bind(callback, types_vector, base::Passed(&node_lists)));
668 }
669
643 void SyncBackendHostCore::StartSavingChanges() { 670 void SyncBackendHostCore::StartSavingChanges() {
644 // We may already be shut down. 671 // We may already be shut down.
645 if (!sync_loop_) 672 if (!sync_loop_)
646 return; 673 return;
647 DCHECK_EQ(base::MessageLoop::current(), sync_loop_); 674 DCHECK_EQ(base::MessageLoop::current(), sync_loop_);
648 DCHECK(!save_changes_timer_.get()); 675 DCHECK(!save_changes_timer_.get());
649 save_changes_timer_.reset(new base::RepeatingTimer<SyncBackendHostCore>()); 676 save_changes_timer_.reset(new base::RepeatingTimer<SyncBackendHostCore>());
650 save_changes_timer_->Start(FROM_HERE, 677 save_changes_timer_->Start(FROM_HERE,
651 base::TimeDelta::FromSeconds(kSaveChangesIntervalSeconds), 678 base::TimeDelta::FromSeconds(kSaveChangesIntervalSeconds),
652 this, &SyncBackendHostCore::SaveChanges); 679 this, &SyncBackendHostCore::SaveChanges);
653 } 680 }
654 681
655 void SyncBackendHostCore::SaveChanges() { 682 void SyncBackendHostCore::SaveChanges() {
656 DCHECK_EQ(base::MessageLoop::current(), sync_loop_); 683 DCHECK_EQ(base::MessageLoop::current(), sync_loop_);
657 sync_manager_->SaveChanges(); 684 sync_manager_->SaveChanges();
658 } 685 }
659 686
660 } // namespace browser_sync 687 } // namespace browser_sync
661 688
OLDNEW
« no previous file with comments | « chrome/browser/sync/glue/sync_backend_host_core.h ('k') | chrome/browser/sync/glue/sync_backend_host_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698