summaryrefslogtreecommitdiffstats
path: root/sync
diff options
context:
space:
mode:
authorrlarocque@chromium.org <rlarocque@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-04-07 20:30:34 +0000
committerrlarocque@chromium.org <rlarocque@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-04-07 20:30:34 +0000
commitc77435705b8f6a9173cdecc5e6eeb2f1911cc48a (patch)
tree8d1113110fed798c28e18124c68440baeaeed88d /sync
parente5af9bcbb29f9207de974e278e614ebc0609ea08 (diff)
downloadchromium_src-c77435705b8f6a9173cdecc5e6eeb2f1911cc48a.zip
chromium_src-c77435705b8f6a9173cdecc5e6eeb2f1911cc48a.tar.gz
chromium_src-c77435705b8f6a9173cdecc5e6eeb2f1911cc48a.tar.bz2
sync: Re-implement getAllNodes WebUI function
Removes the existing implementation of getAllNodes. This was the last function based on the old "makeSyncFunction" and "JsMessageHandler" interface, so its removal leaves behind quite a bit of dead code. This CL removes some of it. The rest will be removed in a future CL. Replaces it with some infrastructure intended to be more compatible with the future of sync, where each type is more independent. Requests to getAllNodes are routed through a DirectoryTypeDebugInfoEmitter in the ModelTypeRegistry. A NonBlockingTypeDebugInfoEmitter will be implemented in a future CL. The new system also intended to support "streaming" results. Rather than waiting for all types to return their nodes, the system could be modified to allow some types to get back to the JavaScript layer sooner than others so it can display results earlier. However, we do not currently take advantage of this functionality. The return type of getAllNodes is now an array of per-type objects, rather than one big list of nodes. This, too, should help us implement streaming support in the future. For now, most of the JavaScript callbacks will convert the data back to the old format before operating on it. BUG=328606 Review URL: https://codereview.chromium.org/224563004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@262193 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'sync')
-rw-r--r--sync/engine/directory_type_debug_info_emitter.cc26
-rw-r--r--sync/engine/directory_type_debug_info_emitter.h34
-rw-r--r--sync/internal_api/public/sync_manager.h3
-rw-r--r--sync/internal_api/public/test/fake_sync_manager.h2
-rw-r--r--sync/internal_api/sync_manager_impl.cc55
-rw-r--r--sync/internal_api/sync_manager_impl.h17
-rw-r--r--sync/internal_api/sync_manager_impl_unittest.cc50
-rw-r--r--sync/internal_api/test/fake_sync_manager.cc5
-rw-r--r--sync/sessions/model_type_registry.cc17
-rw-r--r--sync/sessions/model_type_registry.h12
-rw-r--r--sync/sync_core.gypi2
-rw-r--r--sync/syncable/directory.cc9
-rw-r--r--sync/syncable/directory.h5
13 files changed, 138 insertions, 99 deletions
diff --git a/sync/engine/directory_type_debug_info_emitter.cc b/sync/engine/directory_type_debug_info_emitter.cc
new file mode 100644
index 0000000..6788786
--- /dev/null
+++ b/sync/engine/directory_type_debug_info_emitter.cc
@@ -0,0 +1,26 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "sync/engine/directory_type_debug_info_emitter.h"
+
+#include "sync/syncable/syncable_read_transaction.h"
+
+namespace syncer {
+
+DirectoryTypeDebugInfoEmitter::DirectoryTypeDebugInfoEmitter(
+ syncable::Directory* directory,
+ syncer::ModelType type)
+ : directory_(directory),
+ type_(type) {}
+
+DirectoryTypeDebugInfoEmitter::~DirectoryTypeDebugInfoEmitter() {}
+
+scoped_ptr<base::ListValue> DirectoryTypeDebugInfoEmitter::GetAllNodes() {
+ syncable::ReadTransaction trans(FROM_HERE, directory_);
+ scoped_ptr<base::ListValue> nodes(
+ directory_->GetNodeDetailsForType(&trans, type_));
+ return nodes.Pass();
+}
+
+} // namespace syncer
diff --git a/sync/engine/directory_type_debug_info_emitter.h b/sync/engine/directory_type_debug_info_emitter.h
new file mode 100644
index 0000000..d2247dd
--- /dev/null
+++ b/sync/engine/directory_type_debug_info_emitter.h
@@ -0,0 +1,34 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef SYNC_ENGINE_DIRECTORY_TYPE_DEBUG_INFO_EMITTER_H_
+#define SYNC_ENGINE_DIRECTORY_TYPE_DEBUG_INFO_EMITTER_H_
+
+#include "base/macros.h"
+#include "base/memory/scoped_ptr.h"
+#include "base/values.h"
+#include "sync/syncable/directory.h"
+
+namespace syncer {
+
+// Supports debugging requests for a certain directory type.
+class DirectoryTypeDebugInfoEmitter {
+ public:
+ DirectoryTypeDebugInfoEmitter(syncable::Directory* directory,
+ syncer::ModelType type);
+ virtual ~DirectoryTypeDebugInfoEmitter();
+
+ // Returns a ListValue representation of all known nodes of this type.
+ scoped_ptr<base::ListValue> GetAllNodes();
+
+ private:
+ syncable::Directory* directory_;
+ ModelType type_;
+
+ DISALLOW_COPY_AND_ASSIGN(DirectoryTypeDebugInfoEmitter);
+};
+
+} // namespace syncer
+
+#endif // SYNC_ENGINE_DIRECTORY_TYPE_DEBUG_INFO_EMITTER_H_
diff --git a/sync/internal_api/public/sync_manager.h b/sync/internal_api/public/sync_manager.h
index 0cdb599..d10b998 100644
--- a/sync/internal_api/public/sync_manager.h
+++ b/sync/internal_api/public/sync_manager.h
@@ -352,6 +352,9 @@ class SYNC_EXPORT SyncManager : public syncer::InvalidationHandler {
// Returns the SyncManager's encryption handler.
virtual SyncEncryptionHandler* GetEncryptionHandler() = 0;
+ virtual scoped_ptr<base::ListValue> GetAllNodesForType(
+ syncer::ModelType type) = 0;
+
// Ask the SyncManager to fetch updates for the given types.
virtual void RefreshTypes(ModelTypeSet types) = 0;
diff --git a/sync/internal_api/public/test/fake_sync_manager.h b/sync/internal_api/public/test/fake_sync_manager.h
index 33d619a..fae4c8e 100644
--- a/sync/internal_api/public/test/fake_sync_manager.h
+++ b/sync/internal_api/public/test/fake_sync_manager.h
@@ -126,6 +126,8 @@ class FakeSyncManager : public SyncManager {
virtual SyncEncryptionHandler* GetEncryptionHandler() OVERRIDE;
virtual ScopedVector<syncer::ProtocolEvent>
GetBufferedProtocolEvents() OVERRIDE;
+ virtual scoped_ptr<base::ListValue> GetAllNodesForType(
+ syncer::ModelType type) OVERRIDE;
virtual void RefreshTypes(ModelTypeSet types) OVERRIDE;
private:
diff --git a/sync/internal_api/sync_manager_impl.cc b/sync/internal_api/sync_manager_impl.cc
index 65d6176db..94dfc58 100644
--- a/sync/internal_api/sync_manager_impl.cc
+++ b/sync/internal_api/sync_manager_impl.cc
@@ -16,6 +16,7 @@
#include "base/observer_list.h"
#include "base/strings/string_number_conversions.h"
#include "base/values.h"
+#include "sync/engine/directory_type_debug_info_emitter.h"
#include "sync/engine/sync_scheduler.h"
#include "sync/engine/syncer_types.h"
#include "sync/internal_api/change_reorder_buffer.h"
@@ -35,8 +36,6 @@
#include "sync/internal_api/sync_core.h"
#include "sync/internal_api/syncapi_internal.h"
#include "sync/internal_api/syncapi_server_connection_manager.h"
-#include "sync/js/js_arg_list.h"
-#include "sync/js/js_reply_handler.h"
#include "sync/notifier/invalidation_util.h"
#include "sync/notifier/invalidator.h"
#include "sync/notifier/object_id_invalidation_map.h"
@@ -175,11 +174,6 @@ SyncManagerImpl::SyncManagerImpl(const std::string& name)
notification_info_map_.insert(
std::make_pair(ModelTypeFromInt(i), NotificationInfo()));
}
-
- // Bind message handlers.
- BindJsMessageHandler(
- "getAllNodes",
- &SyncManagerImpl::GetAllNodes);
}
SyncManagerImpl::~SyncManagerImpl() {
@@ -947,46 +941,27 @@ void SyncManagerImpl::SetJsEventHandler(
js_sync_encryption_handler_observer_.SetJsEventHandler(event_handler);
}
+// TODO(rlarocque): This function is no longer needed and should be removed.
+// See http://crbug.com/357821.
void SyncManagerImpl::ProcessJsMessage(
const std::string& name, const JsArgList& args,
const WeakHandle<JsReplyHandler>& reply_handler) {
- if (!initialized_) {
- NOTREACHED();
- return;
- }
+ NOTREACHED();
+}
- if (!reply_handler.IsInitialized()) {
- DVLOG(1) << "Uninitialized reply handler; dropping unknown message "
- << name << " with args " << args.ToString();
- return;
- }
+scoped_ptr<base::ListValue> SyncManagerImpl::GetAllNodesForType(
+ syncer::ModelType type) {
+ DirectoryTypeDebugInfoEmitterMap* emitter_map =
+ model_type_registry_->directory_type_debug_info_emitter_map();
+ DirectoryTypeDebugInfoEmitterMap::iterator it = emitter_map->find(type);
- JsMessageHandler js_message_handler = js_message_handlers_[name];
- if (js_message_handler.is_null()) {
- DVLOG(1) << "Dropping unknown message " << name
- << " with args " << args.ToString();
- return;
+ if (it == emitter_map->end()) {
+ NOTREACHED() << "Asked to return debug info for invalid type "
+ << ModelTypeToString(type);
+ return scoped_ptr<base::ListValue>();
}
- reply_handler.Call(FROM_HERE,
- &JsReplyHandler::HandleJsReply,
- name, js_message_handler.Run(args));
-}
-
-void SyncManagerImpl::BindJsMessageHandler(
- const std::string& name,
- UnboundJsMessageHandler unbound_message_handler) {
- js_message_handlers_[name] =
- base::Bind(unbound_message_handler, base::Unretained(this));
-}
-
-JsArgList SyncManagerImpl::GetAllNodes(const JsArgList& args) {
- ReadTransaction trans(FROM_HERE, GetUserShare());
- base::ListValue return_args;
- scoped_ptr<base::ListValue> nodes(
- trans.GetDirectory()->GetAllNodeDetails(trans.GetWrappedTrans()));
- return_args.Append(nodes.release());
- return JsArgList(&return_args);
+ return it->second->GetAllNodes();
}
void SyncManagerImpl::OnInvalidatorStateChange(InvalidatorState state) {
diff --git a/sync/internal_api/sync_manager_impl.h b/sync/internal_api/sync_manager_impl.h
index f73a89d..52d382e 100644
--- a/sync/internal_api/sync_manager_impl.h
+++ b/sync/internal_api/sync_manager_impl.h
@@ -117,6 +117,8 @@ class SYNC_EXPORT_PRIVATE SyncManagerImpl :
virtual SyncEncryptionHandler* GetEncryptionHandler() OVERRIDE;
virtual ScopedVector<syncer::ProtocolEvent>
GetBufferedProtocolEvents() OVERRIDE;
+ virtual scoped_ptr<base::ListValue> GetAllNodesForType(
+ syncer::ModelType type) OVERRIDE;
// SyncEncryptionHandler::Observer implementation.
virtual void OnPassphraseRequired(
@@ -217,10 +219,6 @@ class SYNC_EXPORT_PRIVATE SyncManagerImpl :
base::TimeDelta GetNudgeDelayTimeDelta(const ModelType& model_type);
typedef std::map<ModelType, NotificationInfo> NotificationInfoMap;
- typedef JsArgList (SyncManagerImpl::*UnboundJsMessageHandler)(
- const JsArgList&);
- typedef base::Callback<JsArgList(const JsArgList&)> JsMessageHandler;
- typedef std::map<std::string, JsMessageHandler> JsMessageHandlerMap;
// Determine if the parents or predecessors differ between the old and new
// versions of an entry. Note that a node's index may change without its
@@ -266,16 +264,6 @@ class SYNC_EXPORT_PRIVATE SyncManagerImpl :
// Checks for server reachabilty and requests a nudge.
void OnNetworkConnectivityChangedImpl();
- // Helper function used only by the constructor.
- void BindJsMessageHandler(
- const std::string& name, UnboundJsMessageHandler unbound_message_handler);
-
- // JS message handlers.
- JsArgList GetAllNodes(const JsArgList& args);
- JsArgList GetNodeSummariesById(const JsArgList& args);
- JsArgList GetNodeDetailsById(const JsArgList& args);
- JsArgList GetChildNodeIds(const JsArgList& args);
-
syncable::Directory* directory();
base::FilePath database_path_;
@@ -351,7 +339,6 @@ class SYNC_EXPORT_PRIVATE SyncManagerImpl :
NotificationInfoMap notification_info_map_;
// These are for interacting with chrome://sync-internals.
- JsMessageHandlerMap js_message_handlers_;
JsSyncManagerObserver js_sync_manager_observer_;
JsMutationEventObserver js_mutation_event_observer_;
JsSyncEncryptionHandlerObserver js_sync_encryption_handler_observer_;
diff --git a/sync/internal_api/sync_manager_impl_unittest.cc b/sync/internal_api/sync_manager_impl_unittest.cc
index 7da7070..a8ee0be 100644
--- a/sync/internal_api/sync_manager_impl_unittest.cc
+++ b/sync/internal_api/sync_manager_impl_unittest.cc
@@ -42,10 +42,8 @@
#include "sync/internal_api/sync_encryption_handler_impl.h"
#include "sync/internal_api/sync_manager_impl.h"
#include "sync/internal_api/syncapi_internal.h"
-#include "sync/js/js_arg_list.h"
#include "sync/js/js_backend.h"
#include "sync/js/js_event_handler.h"
-#include "sync/js/js_reply_handler.h"
#include "sync/js/js_test_util.h"
#include "sync/notifier/fake_invalidation_handler.h"
#include "sync/notifier/invalidation_handler.h"
@@ -754,6 +752,7 @@ class SyncManagerTest : public testing::Test,
sync_manager_.GetUserShare(), i->first);
}
}
+
PumpLoop();
}
@@ -836,13 +835,6 @@ class SyncManagerTest : public testing::Test,
message_loop_.RunUntilIdle();
}
- void SendJsMessage(const std::string& name, const JsArgList& args,
- const WeakHandle<JsReplyHandler>& reply_handler) {
- js_backend_.Call(FROM_HERE, &JsBackend::ProcessJsMessage,
- name, args, reply_handler);
- PumpLoop();
- }
-
void SetJsEventHandler(const WeakHandle<JsEventHandler>& event_handler) {
js_backend_.Call(FROM_HERE, &JsBackend::SetJsEventHandler,
event_handler);
@@ -938,42 +930,18 @@ class SyncManagerTest : public testing::Test,
InternalComponentsFactory::Switches switches_;
};
-TEST_F(SyncManagerTest, GetAllNodesTest) {
- StrictMock<MockJsReplyHandler> reply_handler;
- JsArgList return_args;
+TEST_F(SyncManagerTest, GetAllNodesForTypeTest) {
+ ModelSafeRoutingInfo routing_info;
+ GetModelSafeRoutingInfo(&routing_info);
+ sync_manager_.StartSyncingNormally(routing_info);
- EXPECT_CALL(reply_handler,
- HandleJsReply("getAllNodes", _))
- .Times(1).WillRepeatedly(SaveArg<1>(&return_args));
+ scoped_ptr<base::ListValue> node_list(
+ sync_manager_.GetAllNodesForType(syncer::PREFERENCES));
- {
- base::ListValue args;
- SendJsMessage("getAllNodes",
- JsArgList(&args), reply_handler.AsWeakHandle());
- }
-
- // There's not much value in verifying every attribute on every node here.
- // Most of the value of this test has already been achieved: we've verified we
- // can call the above function without crashing or leaking memory.
- //
- // Let's just check the list size and a few of its elements. Anything more
- // would make this test brittle without greatly increasing our chances of
- // catching real bugs.
+ // Should have one node: the type root node.
+ ASSERT_EQ(1U, node_list->GetSize());
- const base::ListValue* node_list;
const base::DictionaryValue* first_result;
-
- // The resulting argument list should have one argument, a list of nodes.
- ASSERT_EQ(1U, return_args.Get().GetSize());
- ASSERT_TRUE(return_args.Get().GetList(0, &node_list));
-
- // The database creation logic depends on the routing info.
- // Refer to setup methods for more information.
- ModelSafeRoutingInfo routes;
- GetModelSafeRoutingInfo(&routes);
- size_t directory_size = routes.size() + 1;
-
- ASSERT_EQ(directory_size, node_list->GetSize());
ASSERT_TRUE(node_list->GetDictionary(0, &first_result));
EXPECT_TRUE(first_result->HasKey("ID"));
EXPECT_TRUE(first_result->HasKey("NON_UNIQUE_NAME"));
diff --git a/sync/internal_api/test/fake_sync_manager.cc b/sync/internal_api/test/fake_sync_manager.cc
index c7dd249..9f1abb8 100644
--- a/sync/internal_api/test/fake_sync_manager.cc
+++ b/sync/internal_api/test/fake_sync_manager.cc
@@ -244,6 +244,11 @@ FakeSyncManager::GetBufferedProtocolEvents() {
return ScopedVector<syncer::ProtocolEvent>();
}
+scoped_ptr<base::ListValue> FakeSyncManager::GetAllNodesForType(
+ syncer::ModelType type) {
+ return scoped_ptr<base::ListValue>(new base::ListValue());
+}
+
void FakeSyncManager::RefreshTypes(ModelTypeSet types) {
last_refresh_request_types_ = types;
}
diff --git a/sync/sessions/model_type_registry.cc b/sync/sessions/model_type_registry.cc
index b9d4114..fcf3996 100644
--- a/sync/sessions/model_type_registry.cc
+++ b/sync/sessions/model_type_registry.cc
@@ -7,6 +7,7 @@
#include "base/bind.h"
#include "base/message_loop/message_loop_proxy.h"
#include "sync/engine/directory_commit_contributor.h"
+#include "sync/engine/directory_type_debug_info_emitter.h"
#include "sync/engine/directory_update_handler.h"
#include "sync/engine/non_blocking_type_processor_core.h"
#include "sync/internal_api/public/non_blocking_type_processor.h"
@@ -34,14 +35,17 @@ void ModelTypeRegistry::SetEnabledDirectoryTypes(
it.Good(); it.Inc()) {
size_t result1 = update_handler_map_.erase(it.Get());
size_t result2 = commit_contributor_map_.erase(it.Get());
+ size_t result3 = directory_type_debug_info_emitter_map_.erase(it.Get());
DCHECK_EQ(1U, result1);
DCHECK_EQ(1U, result2);
+ DCHECK_EQ(1U, result3);
}
// Clear the old instances of directory update handlers and commit
// contributors, deleting their contents in the processs.
directory_update_handlers_.clear();
directory_commit_contributors_.clear();
+ directory_type_debug_info_emitters_.clear();
// Create new ones and add them to the appropriate containers.
for (ModelSafeRoutingInfo::const_iterator routing_iter = routing_info.begin();
@@ -57,10 +61,13 @@ void ModelTypeRegistry::SetEnabledDirectoryTypes(
new DirectoryCommitContributor(directory_, type);
DirectoryUpdateHandler* updater =
new DirectoryUpdateHandler(directory_, type, worker);
+ DirectoryTypeDebugInfoEmitter* emitter =
+ new DirectoryTypeDebugInfoEmitter(directory_, type);
// These containers take ownership of their contents.
directory_commit_contributors_.push_back(committer);
directory_update_handlers_.push_back(updater);
+ directory_type_debug_info_emitters_.push_back(emitter);
bool inserted1 =
update_handler_map_.insert(std::make_pair(type, updater)).second;
@@ -69,6 +76,11 @@ void ModelTypeRegistry::SetEnabledDirectoryTypes(
bool inserted2 =
commit_contributor_map_.insert(std::make_pair(type, committer)).second;
DCHECK(inserted2) << "Attempt to override existing type handler in map";
+
+ bool inserted3 =
+ directory_type_debug_info_emitter_map_.insert(
+ std::make_pair(type, emitter)).second;
+ DCHECK(inserted3) << "Attempt to override existing type handler in map";
}
enabled_directory_types_ = GetRoutingInfoTypes(routing_info);
@@ -142,6 +154,11 @@ CommitContributorMap* ModelTypeRegistry::commit_contributor_map() {
return &commit_contributor_map_;
}
+DirectoryTypeDebugInfoEmitterMap*
+ModelTypeRegistry::directory_type_debug_info_emitter_map() {
+ return &directory_type_debug_info_emitter_map_;
+}
+
ModelTypeSet ModelTypeRegistry::GetEnabledDirectoryTypes() const {
return enabled_directory_types_;
}
diff --git a/sync/sessions/model_type_registry.h b/sync/sessions/model_type_registry.h
index 1317a6a..71d304f 100644
--- a/sync/sessions/model_type_registry.h
+++ b/sync/sessions/model_type_registry.h
@@ -23,12 +23,15 @@ class Directory;
class CommitContributor;
class DirectoryCommitContributor;
class DirectoryUpdateHandler;
+class DirectoryTypeDebugInfoEmitter;
class NonBlockingTypeProcessorCore;
class NonBlockingTypeProcessor;
class UpdateHandler;
typedef std::map<ModelType, UpdateHandler*> UpdateHandlerMap;
typedef std::map<ModelType, CommitContributor*> CommitContributorMap;
+typedef std::map<ModelType, DirectoryTypeDebugInfoEmitter*>
+ DirectoryTypeDebugInfoEmitterMap;
// Keeps track of the sets of active update handlers and commit contributors.
class SYNC_EXPORT_PRIVATE ModelTypeRegistry {
@@ -67,6 +70,7 @@ class SYNC_EXPORT_PRIVATE ModelTypeRegistry {
// Simple getters.
UpdateHandlerMap* update_handler_map();
CommitContributorMap* commit_contributor_map();
+ DirectoryTypeDebugInfoEmitterMap* directory_type_debug_info_emitter_map();
private:
ModelTypeSet GetEnabledNonBlockingTypes() const;
@@ -75,6 +79,9 @@ class SYNC_EXPORT_PRIVATE ModelTypeRegistry {
// Sets of handlers and contributors.
ScopedVector<DirectoryCommitContributor> directory_commit_contributors_;
ScopedVector<DirectoryUpdateHandler> directory_update_handlers_;
+ ScopedVector<DirectoryTypeDebugInfoEmitter>
+ directory_type_debug_info_emitters_;
+
ScopedVector<NonBlockingTypeProcessorCore> non_blocking_type_processor_cores_;
// Maps of UpdateHandlers and CommitContributors.
@@ -82,6 +89,11 @@ class SYNC_EXPORT_PRIVATE ModelTypeRegistry {
UpdateHandlerMap update_handler_map_;
CommitContributorMap commit_contributor_map_;
+ // Map of DebugInfoEmitters for directory types.
+ // Non-blocking types handle debug info differently.
+ // Does not own its contents.
+ DirectoryTypeDebugInfoEmitterMap directory_type_debug_info_emitter_map_;
+
// The known ModelSafeWorkers.
std::map<ModelSafeGroup, scoped_refptr<ModelSafeWorker> > workers_map_;
diff --git a/sync/sync_core.gypi b/sync/sync_core.gypi
index 0c263cb..4ba949c 100644
--- a/sync/sync_core.gypi
+++ b/sync/sync_core.gypi
@@ -54,6 +54,8 @@
'engine/directory_commit_contributor.h',
'engine/directory_update_handler.cc',
'engine/directory_update_handler.h',
+ 'engine/directory_type_debug_info_emitter.cc',
+ 'engine/directory_type_debug_info_emitter.h',
'engine/get_commit_ids.cc',
'engine/get_commit_ids.h',
'engine/get_updates_delegate.cc',
diff --git a/sync/syncable/directory.cc b/sync/syncable/directory.cc
index 88fe94a..193a538 100644
--- a/sync/syncable/directory.cc
+++ b/sync/syncable/directory.cc
@@ -950,13 +950,18 @@ void Directory::CollectMetaHandleCounts(
}
}
-scoped_ptr<base::ListValue> Directory::GetAllNodeDetails(
- BaseTransaction* trans) {
+scoped_ptr<base::ListValue> Directory::GetNodeDetailsForType(
+ BaseTransaction* trans,
+ ModelType type) {
scoped_ptr<base::ListValue> nodes(new base::ListValue());
ScopedKernelLock lock(this);
for (MetahandlesMap::iterator it = kernel_->metahandles_map.begin();
it != kernel_->metahandles_map.end(); ++it) {
+ if (GetModelTypeFromSpecifics(it->second->ref(SPECIFICS)) != type) {
+ continue;
+ }
+
EntryKernel* kernel = it->second;
scoped_ptr<base::DictionaryValue> node(
kernel->ToValue(GetCryptographer(trans)));
diff --git a/sync/syncable/directory.h b/sync/syncable/directory.h
index 5efa348..07e66e6 100644
--- a/sync/syncable/directory.h
+++ b/sync/syncable/directory.h
@@ -337,7 +337,10 @@ class SYNC_EXPORT Directory {
void CollectMetaHandleCounts(std::vector<int>* num_entries_by_type,
std::vector<int>* num_to_delete_entries_by_type);
- scoped_ptr<base::ListValue> GetAllNodeDetails(BaseTransaction* trans);
+ // Returns a ListValue serialization of all nodes for the given type.
+ scoped_ptr<base::ListValue> GetNodeDetailsForType(
+ BaseTransaction* trans,
+ ModelType type);
// Sets the level of invariant checking performed after transactions.
void SetInvariantCheckLevel(InvariantCheckLevel check_level);