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