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

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: 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
« no previous file with comments | « chrome/browser/resources/print_preview/print_preview.html ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..5121efb438e5482d4e674a57d7f59c7fde5686d1 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) {
Dan Beam 2016/03/03 21:18:24 nit: perhaps we should templatize PromiseResolver
dpapad 2016/03/04 18:58:42 Done. I templatized it in a bit simpler way compar
- /** @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
@@ -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') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698