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

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

Issue 2571903003: Mojo JS bindings: switch most usage of "connection"/"router" module to "bindings". (Closed)
Patch Set: remove the changes to web_ui_mojo.js which seemed to cause flakiness. Created 4 years 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'),
19 ]).then(function(modules) { 18 ]).then(function(modules) {
20 var frameInterfaces = modules[0]; 19 var frameInterfaces = modules[0];
21 var mojom = modules[1]; 20 var mojom = modules[1];
22 var routerModule = modules[2]; 21 return new mojom.MimeHandlerServicePtr(
23 return new mojom.MimeHandlerService.proxyClass(new routerModule.Router( 22 frameInterfaces.getInterface(mojom.MimeHandlerService.name));
24 frameInterfaces.getInterface(mojom.MimeHandlerService.name)));
25 }); 23 });
26 24
27 // Stores a promise to the GetStreamInfo() result to avoid making additional 25 // Stores a promise to the GetStreamInfo() result to avoid making additional
28 // calls in response to getStreamInfo() calls. 26 // calls in response to getStreamInfo() calls.
29 var streamInfoPromise; 27 var streamInfoPromise;
30 28
31 function throwNoStreamError() { 29 function throwNoStreamError() {
32 throw new Error(NO_STREAM_ERROR); 30 throw new Error(NO_STREAM_ERROR);
33 } 31 }
34 32
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 }); 64 });
67 65
68 apiFunctions.setHandleRequestWithPromise('abortStream', function() { 66 apiFunctions.setHandleRequestWithPromise('abortStream', function() {
69 return servicePromise.then(function(service) { 67 return servicePromise.then(function(service) {
70 return service.abortStream().then(function() {}); 68 return service.abortStream().then(function() {});
71 }).catch(throwNoStreamError); 69 }).catch(throwNoStreamError);
72 }); 70 });
73 }); 71 });
74 72
75 exports.$set('binding', binding.generate()); 73 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