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

Unified Diff: chrome/browser/resources/settings/site_settings/site_data.js

Issue 2439233002: [MD settings] use promises rather than a counter var to fetch cookie data (Closed)
Patch Set: fix a whoops Created 4 years, 2 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/resources/settings/site_settings/site_data.js
diff --git a/chrome/browser/resources/settings/site_settings/site_data.js b/chrome/browser/resources/settings/site_settings/site_data.js
index e17c67bf4926b9f00c2b0cb57090bbaf1a5c7bef..d6505bcde07c80c6b1bb92f770c2358cc8acd52b 100644
--- a/chrome/browser/resources/settings/site_settings/site_data.js
+++ b/chrome/browser/resources/settings/site_settings/site_data.js
@@ -28,12 +28,6 @@ Polymer({
treeNodes_: Object,
/**
- * Keeps track of how many outstanding requests for more data there are.
- * @private
- */
- requests_: Number,
-
- /**
* The current filter applied to the cookie data list.
* @private
*/
@@ -108,37 +102,30 @@ Polymer({
* @private
*/
loadChildren_: function(list) {
- var parentId = list.id;
- var data = list.children;
-
- if (parentId == null) {
- // New root being added, clear the list and add the nodes.
- this.sites = [];
- this.requests_ = 0;
- this.treeNodes_.addChildNodes(this.treeNodes_, data);
- } else {
- this.treeNodes_.populateChildNodes(parentId, this.treeNodes_, data);
- }
-
- for (var i = 0; i < data.length; ++i) {
- var prefix = parentId == null ? '' : parentId + ', ';
- if (data[i].hasChildren) {
- ++this.requests_;
- this.browserProxy.loadCookieChildren(
- prefix + data[i].id).then(function(list) {
- --this.requests_;
- this.loadChildren_(list);
- }.bind(this));
+ var loadChildrenRecurse = function(list) {
+ var parentId = list.id;
+ var children = list.children;
+ var prefix = '';
+ if (parentId !== null) {
+ this.treeNodes_.populateChildNodes(parentId, this.treeNodes_, children);
+ prefix = parentId + ', ';
}
- }
+ var promises = [];
+ for (let child of children) {
+ if (child.hasChildren) {
+ promises.push(this.browserProxy.loadCookieChildren(
+ prefix + child.id).then(loadChildrenRecurse.bind(this)));
+ }
+ }
+ return Promise.all(promises);
+ }.bind(this);
- if (this.requests_ == 0)
+ // New root being added, clear the list and add the nodes.
+ this.sites = [];
+ this.treeNodes_.addChildNodes(this.treeNodes_, list.children);
+ loadChildrenRecurse(list).then(function() {
this.sites = this.treeNodes_.getSummaryList();
-
- // If this reaches below zero then we're forgetting to increase the
- // outstanding request count and the summary list won't be updated at the
- // end.
- assert(this.requests_ >= 0);
+ }.bind(this));
},
/**
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698