summaryrefslogtreecommitdiffstats
path: root/sync/engine
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/engine
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/engine')
-rw-r--r--sync/engine/directory_type_debug_info_emitter.cc26
-rw-r--r--sync/engine/directory_type_debug_info_emitter.h34
2 files changed, 60 insertions, 0 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_