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

Unified Diff: chrome/browser/resources/md_history/history.js

Issue 2171693002: [MD History] Force history results to be processed in order. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@move_menu_up
Patch Set: missed one Created 4 years, 5 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 | chrome/test/data/webui/md_history/md_history_browsertest.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/resources/md_history/history.js
diff --git a/chrome/browser/resources/md_history/history.js b/chrome/browser/resources/md_history/history.js
index 8f248b966dfa747c29fc5efed33c3e0c95e7fdc3..e9d55e7fcc4c472ad73af8e852956ae4c82dc886 100644
--- a/chrome/browser/resources/md_history/history.js
+++ b/chrome/browser/resources/md_history/history.js
@@ -7,17 +7,24 @@
chrome.send('queryHistory', ['', 0, 0, 0, RESULTS_PER_PAGE]);
chrome.send('getForeignSessions');
+/** @type {Promise} */
+var upgradePromise = null;
+
/**
- * @param {HTMLElement} element
- * @return {!Promise} Resolves once a Polymer element has been fully upgraded.
+ * @return {!Promise} Resolves once the history-app has been fully upgraded.
*/
-function waitForUpgrade(element) {
- return new Promise(function(resolve, reject) {
- if (window.Polymer && Polymer.isInstance && Polymer.isInstance(element))
- resolve();
- else
- $('bundle').addEventListener('load', resolve);
- });
+function waitForAppUpgrade() {
+ if (!upgradePromise) {
+ upgradePromise = new Promise(function(resolve, reject) {
+ if (window.Polymer && Polymer.isInstance &&
+ Polymer.isInstance($('history-app'))) {
+ resolve();
+ } else {
+ $('bundle').addEventListener('load', resolve);
+ }
+ });
+ }
+ return upgradePromise;
}
// Chrome Callbacks-------------------------------------------------------------
@@ -28,9 +35,9 @@ function waitForUpgrade(element) {
* @param {!Array<HistoryEntry>} results A list of results.
*/
function historyResult(info, results) {
- var appElem = $('history-app');
- waitForUpgrade(appElem).then(function() {
- /** @type {HistoryAppElement} */(appElem).historyResult(info, results);
+ waitForAppUpgrade().then(function() {
+ /** @type {HistoryAppElement} */($('history-app'))
+ .historyResult(info, results);
// TODO(tsergeant): Showing everything as soon as the list is ready is not
// ideal, as the sidebar can still pop in after. Fix this to show everything
// at once.
@@ -52,9 +59,8 @@ function showNotification(
// in the MD history anymore, so the parameter is not needed. Remove it
// when WebUI is removed and this becomes the only client of
// BrowsingHistoryHandler.
- var appElem = $('history-app');
- waitForUpgrade(appElem).then(function() {
- /** @type {HistoryAppElement} */(appElem)
+ waitForAppUpgrade().then(function() {
+ /** @type {HistoryAppElement} */($('history-app'))
.getSideBar().showFooter = includeOtherFormsOfBrowsingHistory;
});
}
@@ -69,9 +75,8 @@ function showNotification(
* @param {boolean} isTabSyncEnabled Is tab sync enabled for this profile?
*/
function setForeignSessions(sessionList, isTabSyncEnabled) {
- var appElem = $('history-app');
- waitForUpgrade(appElem).then(function() {
- /** @type {HistoryAppElement} */(appElem)
+ waitForAppUpgrade().then(function() {
+ /** @type {HistoryAppElement} */($('history-app'))
.setForeignSessions(sessionList, isTabSyncEnabled);
});
}
@@ -87,9 +92,8 @@ function historyDeleted() {
* @param {boolean} isUserSignedIn Whether user is signed in or not now.
*/
function updateSignInState(isUserSignedIn) {
- var appElem = $('history-app');
- waitForUpgrade(appElem).then(function() {
- /** @type {HistoryAppElement} */(appElem)
+ waitForAppUpgrade().then(function() {
+ /** @type {HistoryAppElement} */($('history-app'))
.updateSignInState(isUserSignedIn);
});
}
« no previous file with comments | « no previous file | chrome/test/data/webui/md_history/md_history_browsertest.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698