| Index: components/browser_sync/browser/profile_sync_service.cc
|
| diff --git a/components/browser_sync/browser/profile_sync_service.cc b/components/browser_sync/browser/profile_sync_service.cc
|
| index a23b37b70282cccb5645fae0277583df6e174878..b5ebe8039ba0c9889f56cdb07bbf7494e7b4b9d7 100644
|
| --- a/components/browser_sync/browser/profile_sync_service.cc
|
| +++ b/components/browser_sync/browser/profile_sync_service.cc
|
| @@ -61,6 +61,7 @@
|
| #include "components/sync/driver/backend_migrator.h"
|
| #include "components/sync/driver/change_processor.h"
|
| #include "components/sync/driver/data_type_controller.h"
|
| +#include "components/sync/driver/directory_data_type_controller.h"
|
| #include "components/sync/driver/glue/chrome_report_unrecoverable_error.h"
|
| #include "components/sync/driver/glue/sync_backend_host.h"
|
| #include "components/sync/driver/glue/sync_backend_host_impl.h"
|
| @@ -81,6 +82,7 @@
|
| #include "components/sync/js/js_event_details.h"
|
| #include "components/sync/protocol/sync.pb.h"
|
| #include "components/sync/syncable/directory.h"
|
| +#include "components/sync/syncable/syncable_read_transaction.h"
|
| #include "components/sync_sessions/favicon_cache.h"
|
| #include "components/sync_sessions/session_data_type_controller.h"
|
| #include "components/sync_sessions/sessions_sync_manager.h"
|
| @@ -2199,9 +2201,8 @@ class GetAllNodesRequestHelper
|
| syncer::ModelTypeSet requested_types,
|
| const base::Callback<void(std::unique_ptr<base::ListValue>)>& callback);
|
|
|
| - void OnReceivedNodesForTypes(
|
| - const std::vector<syncer::ModelType>& types,
|
| - ScopedVector<base::ListValue> scoped_node_lists);
|
| + void OnReceivedNodesForType(const syncer::ModelType type,
|
| + std::unique_ptr<base::ListValue> node_list);
|
|
|
| private:
|
| friend class base::RefCountedThreadSafe<GetAllNodesRequestHelper>;
|
| @@ -2228,34 +2229,19 @@ GetAllNodesRequestHelper::~GetAllNodesRequestHelper() {
|
| }
|
| }
|
|
|
| -// Called when the set of nodes for a type or set of types has been returned.
|
| -//
|
| -// The nodes for several types can be returned at the same time by specifying
|
| -// their types in the |types| array, and putting their results at the
|
| -// correspnding indices in the |scoped_node_lists|.
|
| -void GetAllNodesRequestHelper::OnReceivedNodesForTypes(
|
| - const std::vector<syncer::ModelType>& types,
|
| - ScopedVector<base::ListValue> scoped_node_lists) {
|
| - DCHECK_EQ(types.size(), scoped_node_lists.size());
|
| +// Called when the set of nodes for a type has been returned.
|
| +// Only return one type of nodes each time.
|
| +void GetAllNodesRequestHelper::OnReceivedNodesForType(
|
| + const syncer::ModelType type,
|
| + std::unique_ptr<base::ListValue> node_list) {
|
| + // Add these results to our list.
|
| + std::unique_ptr<base::DictionaryValue> type_dict(new base::DictionaryValue());
|
| + type_dict->SetString("type", ModelTypeToString(type));
|
| + type_dict->Set("nodes", std::move(node_list));
|
| + result_accumulator_->Append(std::move(type_dict));
|
|
|
| - // Take unsafe ownership of the node list.
|
| - std::vector<base::ListValue*> node_lists;
|
| - scoped_node_lists.release(&node_lists);
|
| -
|
| - for (size_t i = 0; i < node_lists.size() && i < types.size(); ++i) {
|
| - const ModelType type = types[i];
|
| - base::ListValue* node_list = node_lists[i];
|
| -
|
| - // Add these results to our list.
|
| - std::unique_ptr<base::DictionaryValue> type_dict(
|
| - new base::DictionaryValue());
|
| - type_dict->SetString("type", ModelTypeToString(type));
|
| - type_dict->Set("nodes", node_list);
|
| - result_accumulator_->Append(std::move(type_dict));
|
| -
|
| - // Remember that this part of the request is satisfied.
|
| - awaiting_types_.Remove(type);
|
| - }
|
| + // Remember that this part of the request is satisfied.
|
| + awaiting_types_.Remove(type);
|
|
|
| if (awaiting_types_.Empty()) {
|
| callback_.Run(std::move(result_accumulator_));
|
| @@ -2275,17 +2261,14 @@ void ProfileSyncService::GetAllNodes(
|
|
|
| if (!backend_initialized_) {
|
| // If there's no backend available to fulfill the request, handle it here.
|
| - ScopedVector<base::ListValue> empty_results;
|
| - std::vector<ModelType> type_vector;
|
| for (ModelTypeSet::Iterator it = all_types.First(); it.Good(); it.Inc()) {
|
| - type_vector.push_back(it.Get());
|
| - empty_results.push_back(new base::ListValue());
|
| + std::unique_ptr<base::ListValue> empty_results;
|
| + helper->OnReceivedNodesForType(it.Get(), std::move(empty_results));
|
| }
|
| - helper->OnReceivedNodesForTypes(type_vector, std::move(empty_results));
|
| } else {
|
| - backend_->GetAllNodesForTypes(
|
| + GetAllNodesForTypes(
|
| all_types,
|
| - base::Bind(&GetAllNodesRequestHelper::OnReceivedNodesForTypes, helper));
|
| + base::Bind(&GetAllNodesRequestHelper::OnReceivedNodesForType, helper));
|
| }
|
| }
|
|
|
| @@ -2540,3 +2523,22 @@ void ProfileSyncService::OnSetupInProgressHandleDestroyed() {
|
| ReconfigureDatatypeManager();
|
| NotifyObservers();
|
| }
|
| +
|
| +void ProfileSyncService::GetAllNodesForTypes(
|
| + syncer::ModelTypeSet types,
|
| + base::Callback<void(const syncer::ModelType,
|
| + std::unique_ptr<base::ListValue>)> callback) {
|
| + for (syncer::ModelTypeSet::Iterator it = types.First(); it.Good(); it.Inc()) {
|
| + DataTypeController::TypeMap::const_iterator iter =
|
| + data_type_controllers_.find(it.Get());
|
| + if (iter != data_type_controllers_.end()) {
|
| + iter->second->GetAllNodes(callback);
|
| + } else {
|
| + // Control Types
|
| + callback.Run(it.Get(),
|
| + sync_driver::DirectoryDataTypeController::
|
| + GetAllNodesForTypeFromDirectory(
|
| + it.Get(), GetUserShare()->directory.get()));
|
| + }
|
| + }
|
| +}
|
|
|