Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2302)

Unified Diff: chrome/browser/resources/sync_internals/data.js

Issue 224563004: sync: Re-implement getAllNodes WebUI function (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Many updates Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/resources/sync_internals/data.js
diff --git a/chrome/browser/resources/sync_internals/data.js b/chrome/browser/resources/sync_internals/data.js
index c0ef90e6eb77f5d587c001325a9d622e9f3a587d..6de42c706a7f7289e04aebc898fdf3dd1b82552b 100644
--- a/chrome/browser/resources/sync_internals/data.js
+++ b/chrome/browser/resources/sync_internals/data.js
@@ -57,7 +57,11 @@ function versionToDateString(version) {
return date.toString();
}
-function getFields(node) {
+/**
+ * @param {!Object} node A JavaScript represenation of a sync entity.
+ * @return {string} A string representation of the sync entity.
+ */
+function serializeNode(node) {
return allFields.map(function(field) {
var fieldVal;
if (field == 'SERVER_VERSION_TIME') {
@@ -79,8 +83,11 @@ function getFields(node) {
});
}
-function isSelectedDatatype(node) {
- var type = node.serverModelType;
+/**
+ * @param {string} type The name of a sync model type.
+ * @return {boolean} True if the type's checkbox is selected.
+ */
+function isSelectedDatatype(type) {
var typeCheckbox = $(type);
// Some types, such as 'Top level folder', appear in the list of nodes
// but not in the list of selectable items.
@@ -116,7 +123,13 @@ function makeDateUserAgentHeader() {
return dateUaHeader;
}
-function triggerDataDownload(data) {
+/**
+ * Builds a summary of current state and exports it as a downloaded file.
+ *
+ * @param {!Array.<{type: string, nodes: !Array<!Object>}>} nodesMap
+ * Summary of local state by model type.
+ */
+function triggerDataDownload(nodesMap) {
// Prepend a header with ISO date and useragent.
var output = [makeDateUserAgentHeader()];
output.push('=====');
@@ -124,16 +137,17 @@ function triggerDataDownload(data) {
var aboutInfo = JSON.stringify(chrome.sync.aboutInfo, null, 2);
output.push(aboutInfo);
- if (data != null && data.length > 0) {
+ // Filter out non-selected types.
+ var selectedTypesNodes = nodesMap.filter(function(x) {
+ return isSelectedDatatype(x.type);
+ });
+
+ // Serialize the remaining nodes and add them to the output.
+ selectedTypesNodes.forEach(function(typeNodes) {
output.push('=====');
- var fieldLabels = allFields.join(',');
- output.push(fieldLabels);
+ output.push(typeNodes.nodes.map(serializeNode).join('\n'));
+ });
- var data = data.filter(isSelectedDatatype);
- data = data.map(getFields);
- var dataAsString = data.join('\n');
- output.push(dataAsString);
- }
output = output.join('\n');
var anchor = $('dump-to-file-anchor');

Powered by Google App Engine
This is Rietveld 408576698