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

Unified Diff: chrome/browser/resources/print_preview/search/provisional_destination_resolver.js

Issue 1755423003: Re-use PromiseResolver helper in print preview. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@reject_promise
Patch Set: Add @struct Created 4 years, 10 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/print_preview/search/provisional_destination_resolver.js
diff --git a/chrome/browser/resources/print_preview/search/provisional_destination_resolver.js b/chrome/browser/resources/print_preview/search/provisional_destination_resolver.js
index a78732f0ee87af42008a70bc17a6e01e0f85079b..b16e474efd91fb0b7a8d17490f81b512872ccfc3 100644
--- a/chrome/browser/resources/print_preview/search/provisional_destination_resolver.js
+++ b/chrome/browser/resources/print_preview/search/provisional_destination_resolver.js
@@ -15,41 +15,6 @@ cr.define('print_preview', function() {
};
/**
- * Utility class for bundling a promise object with it's resolver methods.
- * @param {!Promise<!print_preview.Destination>} promise A promise returning
- * a destination.
- * @param {function(!print_preview.Destination)} resolve Function resolving
- * the promise.
- * @param {function()} reject Function for rejecting the promise.
- * @constructor @struct
- */
- function PromiseResolver(promise, resolve, reject) {
- /** @type {!Promise<!print_preview.Destination>} */
- this.promise = promise;
- /** @type {function(!print_preview.Destination)} */
- this.resolve = resolve;
- /** @type {function()} */
- this.reject = reject;
- }
-
- /**
- * Create a Promise and an associated PromiseResolver.
- * @return {!PromiseResolver}
- */
- PromiseResolver.create = function() {
- var reject = null;
- var resolve = null;
- /** @type {!Promise<!print_preview.Destination>} */
- var promise = new Promise(function(resolvePromise, rejectPromise) {
- resolve = /** @type {function(!print_preview.Destination)}*/(
- resolvePromise);
- reject = /** @type {function()} */(rejectPromise);
- });
-
- return new PromiseResolver(promise, resolve, reject);
- };
-
- /**
* Overlay used to resolve a provisional extension destination. The user is
* prompted to allow print preview to grant a USB device access to an
* extension associated with the destination. If user agrees destination
@@ -78,7 +43,7 @@ cr.define('print_preview', function() {
/**
* Promise resolver for promise returned by {@code this.run}.
- * @private {?PromiseResolver}
+ * @private {?PromiseResolver<!print_preview.Destination>}
*/
this.promiseResolver_ = null;
}
@@ -126,7 +91,7 @@ cr.define('print_preview', function() {
'Showing overlay while not in initial state.');
assert(!this.promiseResolver_, 'Promise resolver already set.');
this.setState_(ResolverState.ACTIVE);
- this.promiseResolver_ = PromiseResolver.create();
+ this.promiseResolver_ = new PromiseResolver();
this.getChildElement('.default').focus();
} else if (this.state_ != ResolverState.DONE) {
assert(this.state_ != ResolverState.INITIAL, 'Hiding in initial state');
« no previous file with comments | « chrome/browser/resources/print_preview/print_preview.html ('k') | ui/webui/resources/js/promise_resolver.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698