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

Side by Side Diff: extensions/renderer/resources/mime_handler_private_custom_bindings.js

Issue 2590393002: Revert of Mojo JS bindings: switch most usage of "connection"/"router" module to "bindings". (Closed)
Patch Set: Created 3 years, 12 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /** 5 /**
6 * Custom bindings for the mime handler API. 6 * Custom bindings for the mime handler API.
7 */ 7 */
8 8
9 var binding = require('binding').Binding.create('mimeHandlerPrivate'); 9 var binding = require('binding').Binding.create('mimeHandlerPrivate');
10 10
11 var NO_STREAM_ERROR = 11 var NO_STREAM_ERROR =
12 'Streams are only available from a mime handler view guest.'; 12 'Streams are only available from a mime handler view guest.';
13 var STREAM_ABORTED_ERROR = 'Stream has been aborted.'; 13 var STREAM_ABORTED_ERROR = 'Stream has been aborted.';
14 14
15 var servicePromise = Promise.all([ 15 var servicePromise = Promise.all([
16 requireAsync('content/public/renderer/frame_interfaces'), 16 requireAsync('content/public/renderer/frame_interfaces'),
17 requireAsync('extensions/common/api/mime_handler.mojom'), 17 requireAsync('extensions/common/api/mime_handler.mojom'),
18 requireAsync('mojo/public/js/router'),
18 ]).then(function(modules) { 19 ]).then(function(modules) {
19 var frameInterfaces = modules[0]; 20 var frameInterfaces = modules[0];
20 var mojom = modules[1]; 21 var mojom = modules[1];
21 return new mojom.MimeHandlerServicePtr( 22 var routerModule = modules[2];
22 frameInterfaces.getInterface(mojom.MimeHandlerService.name)); 23 return new mojom.MimeHandlerService.proxyClass(new routerModule.Router(
24 frameInterfaces.getInterface(mojom.MimeHandlerService.name)));
23 }); 25 });
24 26
25 // Stores a promise to the GetStreamInfo() result to avoid making additional 27 // Stores a promise to the GetStreamInfo() result to avoid making additional
26 // calls in response to getStreamInfo() calls. 28 // calls in response to getStreamInfo() calls.
27 var streamInfoPromise; 29 var streamInfoPromise;
28 30
29 function throwNoStreamError() { 31 function throwNoStreamError() {
30 throw new Error(NO_STREAM_ERROR); 32 throw new Error(NO_STREAM_ERROR);
31 } 33 }
32 34
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 }); 66 });
65 67
66 apiFunctions.setHandleRequestWithPromise('abortStream', function() { 68 apiFunctions.setHandleRequestWithPromise('abortStream', function() {
67 return servicePromise.then(function(service) { 69 return servicePromise.then(function(service) {
68 return service.abortStream().then(function() {}); 70 return service.abortStream().then(function() {});
69 }).catch(throwNoStreamError); 71 }).catch(throwNoStreamError);
70 }); 72 });
71 }); 73 });
72 74
73 exports.$set('binding', binding.generate()); 75 exports.$set('binding', binding.generate());
OLDNEW
« no previous file with comments | « extensions/renderer/resources/media_router_bindings.js ('k') | extensions/test/data/api_test_base_unittest.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698