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

Unified Diff: mojo/apps/js/main.js

Issue 637373002: Mojo JS bindings: simplify mojo.connectToService() usage - Part 2 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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
Index: mojo/apps/js/main.js
diff --git a/mojo/apps/js/main.js b/mojo/apps/js/main.js
index e2562cf088f4b6ddcdaa0f8189e81e3556722341..3a44f04f5c7a95d1b2c82356b20e364057c5cda1 100644
--- a/mojo/apps/js/main.js
+++ b/mojo/apps/js/main.js
@@ -3,36 +3,36 @@
// found in the LICENSE file.
// This trivial app just loads "cnn.com" using the Mojo Network and URLLoader
-// services and then prints a brief summary of the response. It's intended to
-// be run using the mojo_js content handler and assumes that this source file
-// is specified as a URL. For example:
+// services and then prints a brief summary of the response.
//
+// To run it using mojo_js_standalone (don't forget the quotes):
+// mojo_shell 'mojo://mojo_js_standalone THIS_DIR/main.js'
+//
+// To run it using mojo_js_content handler this file must be specified as
+// a URL. For example:
// (cd YOUR_DIR/mojo/apps/js; python -m SimpleHTTPServer ) &
-// mojo_shell --content-handlers=application/javascript,mojo://mojo_js \
-// http://localhost:8000/test.js
+// mojo_shell \
+// --content-handlers=application/javascript,mojo://mojo_js_content_handler \
+// http://localhost:8000/test.js
define("test", [
+ "mojo/apps/js/mojo",
"mojo/public/js/bindings/core",
"mojo/public/js/bindings/connection",
"mojo/public/js/bindings/support",
"mojo/services/public/interfaces/network/network_service.mojom",
"mojo/services/public/interfaces/network/url_loader.mojom",
- "mojo",
"console"
-], function(core, connection, support, net, loader, mojo, console) {
+], function(mojo, core, connection, support, net, loader, console) {
- var netServiceHandle = mojo.connectToService(
- "mojo:mojo_network_service", net.NetworkService.name);
- var netConnection = new connection.Connection(
- netServiceHandle,
- net.NetworkService.stubClass,
- net.NetworkService.proxyClass);
+ var networkService = mojo.connectToService(
+ "mojo:mojo_network_service", net.NetworkService);
var urlLoaderPipe = core.createMessagePipe();
- netConnection.remote.createURLLoader(urlLoaderPipe.handle1);
+ networkService.createURLLoader(urlLoaderPipe.handle1);
var urlLoaderConnection = new connection.Connection(
urlLoaderPipe.handle0,
- loader.URLLoader.stubClass,
+ function(){},
loader.URLLoader.proxyClass);
var urlRequest = new loader.URLRequest({
« no previous file with comments | « mojo/apps/js/js_app.cc ('k') | mojo/apps/js/mojo.js » ('j') | mojo/apps/js/mojo.js » ('J')

Powered by Google App Engine
This is Rietveld 408576698