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

Side by Side Diff: mojo/public/js/new_bindings/base.js

Issue 2946383002: Support new-style Mojo JS core API on IOS. (Closed)
Patch Set: . Created 3 years, 5 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
« no previous file with comments | « ios/web/webui/web_ui_mojo_inttest.mm ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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 'use strict'; 5 'use strict';
6 6
7 if (mojo && mojo.internal) { 7 if (mojo && mojo.internal) {
8 throw new Error('The Mojo bindings library has been initialized.'); 8 throw new Error('The Mojo bindings library has been initialized.');
9 } 9 }
10 10
(...skipping 16 matching lines...) Expand all
27 // http://example.org/scripts/b/c/foo.mojom.js 27 // http://example.org/scripts/b/c/foo.mojom.js
28 // then the URL of bar.mojom.js will be: 28 // then the URL of bar.mojom.js will be:
29 // http://example.org/scripts/b/d/bar.mojom.js 29 // http://example.org/scripts/b/d/bar.mojom.js
30 // 30 //
31 // If you would like bar.mojom.js to live at a different location, you need 31 // If you would like bar.mojom.js to live at a different location, you need
32 // to turn off |autoLoadMojomDeps| before loading foo.mojom.js, and manually 32 // to turn off |autoLoadMojomDeps| before loading foo.mojom.js, and manually
33 // load bar.mojom.js yourself. Similarly, you need to turn off the option if 33 // load bar.mojom.js yourself. Similarly, you need to turn off the option if
34 // you merge bar.mojom.js and foo.mojom.js into a single file. 34 // you merge bar.mojom.js and foo.mojom.js into a single file.
35 // 35 //
36 // Performance tip: Avoid loading the same mojom.js file multiple times. 36 // Performance tip: Avoid loading the same mojom.js file multiple times.
37 // Assume that |autoLoadMojomDeps| is set to true: 37 // Assume that |autoLoadMojomDeps| is set to true,
38 // <!-- No duplicate loading; recommended. --> 38 //
39 // <!--
40 // (This comment tag is necessary on IOS to avoid interpreting the closing
41 // script tags in the example.)
42 //
43 // No duplicate loading; recommended:
39 // <script src="http://example.org/scripts/b/c/foo.mojom.js"></script> 44 // <script src="http://example.org/scripts/b/c/foo.mojom.js"></script>
40 // 45 //
41 // <!-- No duplicate loading, although unnecessary. --> 46 // No duplicate loading, although unnecessary:
42 // <script src="http://example.org/scripts/b/d/bar.mojom.js"></script> 47 // <script src="http://example.org/scripts/b/d/bar.mojom.js"></script>
43 // <script src="http://example.org/scripts/b/c/foo.mojom.js"></script> 48 // <script src="http://example.org/scripts/b/c/foo.mojom.js"></script>
44 // 49 //
45 // <!-- Load bar.mojom.js twice; should be avoided. --> 50 // Load bar.mojom.js twice; should be avoided:
46 // <script src="http://example.org/scripts/b/c/foo.mojom.js"></script> 51 // <script src="http://example.org/scripts/b/c/foo.mojom.js"></script>
47 // <script src="http://example.org/scripts/b/d/bar.mojom.js"></script> 52 // <script src="http://example.org/scripts/b/d/bar.mojom.js"></script>
53 //
54 // -->
48 autoLoadMojomDeps: true 55 autoLoadMojomDeps: true
49 }; 56 };
50 57
51 (function() { 58 (function() {
52 var internal = mojo.internal; 59 var internal = mojo.internal;
53 60
54 var LoadState = { 61 var LoadState = {
55 PENDING_LOAD: 1, 62 PENDING_LOAD: 1,
56 LOADED: 2 63 LOADED: 2
57 }; 64 };
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 mojomRegistry.set(id, LoadState.LOADED); 99 mojomRegistry.set(id, LoadState.LOADED);
93 } 100 }
94 101
95 function loadMojomIfNecessary(id, url) { 102 function loadMojomIfNecessary(id, url) {
96 if (mojomRegistry.has(id)) { 103 if (mojomRegistry.has(id)) {
97 return; 104 return;
98 } 105 }
99 106
100 markMojomPendingLoad(id); 107 markMojomPendingLoad(id);
101 internal.global.document.write('<script type="text/javascript" src="' + 108 internal.global.document.write('<script type="text/javascript" src="' +
102 url + '"></script>'); 109 url + '"><' + '/script>');
103 } 110 }
104 111
105 internal.exposeNamespace = exposeNamespace; 112 internal.exposeNamespace = exposeNamespace;
106 internal.isMojomPendingLoad = isMojomPendingLoad; 113 internal.isMojomPendingLoad = isMojomPendingLoad;
107 internal.isMojomLoaded = isMojomLoaded; 114 internal.isMojomLoaded = isMojomLoaded;
108 internal.markMojomPendingLoad = markMojomPendingLoad; 115 internal.markMojomPendingLoad = markMojomPendingLoad;
109 internal.markMojomLoaded = markMojomLoaded; 116 internal.markMojomLoaded = markMojomLoaded;
110 internal.loadMojomIfNecessary = loadMojomIfNecessary; 117 internal.loadMojomIfNecessary = loadMojomIfNecessary;
111 })(); 118 })();
OLDNEW
« no previous file with comments | « ios/web/webui/web_ui_mojo_inttest.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698