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

Unified Diff: extensions/renderer/resources/serial_custom_bindings.js

Issue 481853002: Add support for asynchronously loading modules from the background page. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 6 years, 4 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 | extensions/renderer/resources/utils.js » ('j') | extensions/renderer/resources/utils.js » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: extensions/renderer/resources/serial_custom_bindings.js
diff --git a/extensions/renderer/resources/serial_custom_bindings.js b/extensions/renderer/resources/serial_custom_bindings.js
index 31f6daec467a7a6e59a9692e57d26d0088ff8f0f..c0e2738eb080477a0580bfbf877970a520ce2ac2 100644
--- a/extensions/renderer/resources/serial_custom_bindings.js
+++ b/extensions/renderer/resources/serial_custom_bindings.js
@@ -12,21 +12,10 @@
*/
var binding = require('binding').Binding.create('serial');
+var utils = require('utils');
-function createAsyncProxy(targetPromise, functionNames) {
- var functionProxies = {};
- $Array.forEach(functionNames, function(name) {
- functionProxies[name] = function() {
- var args = arguments;
- return targetPromise.then(function(target) {
- return $Function.apply(target[name], target, args);
- });
- };
- });
- return functionProxies;
-}
-
-var serialService = createAsyncProxy(requireAsync('serial_service'), [
+var serialService = utils.createAsyncProxy(
+ utils.requireAsyncFromBackgroundPage('serial_service'), [
'getDevices',
'createConnection',
'getConnection',
« no previous file with comments | « no previous file | extensions/renderer/resources/utils.js » ('j') | extensions/renderer/resources/utils.js » ('J')

Powered by Google App Engine
This is Rietveld 408576698