From c77435705b8f6a9173cdecc5e6eeb2f1911cc48a Mon Sep 17 00:00:00 2001 From: "rlarocque@chromium.org" Date: Mon, 7 Apr 2014 20:30:34 +0000 Subject: 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 --- sync/engine/directory_type_debug_info_emitter.cc | 26 ++++++++++++++++++ sync/engine/directory_type_debug_info_emitter.h | 34 ++++++++++++++++++++++++ 2 files changed, 60 insertions(+) create mode 100644 sync/engine/directory_type_debug_info_emitter.cc create mode 100644 sync/engine/directory_type_debug_info_emitter.h (limited to 'sync/engine') 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 DirectoryTypeDebugInfoEmitter::GetAllNodes() { + syncable::ReadTransaction trans(FROM_HERE, directory_); + scoped_ptr 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 GetAllNodes(); + + private: + syncable::Directory* directory_; + ModelType type_; + + DISALLOW_COPY_AND_ASSIGN(DirectoryTypeDebugInfoEmitter); +}; + +} // namespace syncer + +#endif // SYNC_ENGINE_DIRECTORY_TYPE_DEBUG_INFO_EMITTER_H_ -- cgit v1.1