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

Side by Side Diff: mojo/apps/js/main.js

Issue 646943006: Remove mojo/apps/js, it is unused (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month 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 | « mojo/apps/js/js_app.cc ('k') | mojo/apps/js/mojo.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 // This trivial app just loads "cnn.com" using the Mojo Network and URLLoader
6 // services and then prints a brief summary of the response.
7 //
8 // To run it using mojo_js_standalone (don't forget the quotes):
9 // mojo_shell 'mojo://js_standalone THIS_DIR/main.js'
10 //
11 // To run it using mojo_js_content handler this file must be specified as
12 // a URL. For example:
13 // (cd YOUR_DIR/mojo/apps/js; python -m SimpleHTTPServer ) &
14 // mojo_shell \
15 // --content-handlers=application/javascript,mojo://js_content_handler \
16 // http://localhost:8000/test.js
17
18 define("test", [
19 "mojo/apps/js/mojo",
20 "mojo/public/js/bindings/core",
21 "mojo/public/js/bindings/connection",
22 "mojo/public/js/bindings/support",
23 "mojo/services/public/interfaces/network/network_service.mojom",
24 "mojo/services/public/interfaces/network/url_loader.mojom",
25 "console"
26 ], function(mojo, core, connection, support, net, loader, console) {
27
28 var networkService = mojo.connectToService(
29 "mojo:network_service", net.NetworkService);
30
31 var urlLoaderPipe = core.createMessagePipe();
32 networkService.createURLLoader(urlLoaderPipe.handle1);
33 var urlLoaderConnection = new connection.Connection(
34 urlLoaderPipe.handle0,
35 function(){},
36 loader.URLLoader.proxyClass);
37
38 var urlRequest = new loader.URLRequest({
39 url: "http://www.cnn.com",
40 method: "GET",
41 auto_follow_redirects: true
42 });
43
44 var urlRequestPromise = urlLoaderConnection.remote.start(urlRequest);
45 urlRequestPromise.then(function(result) {
46 for(var key in result.response)
47 console.log(key + " => " + result.response[key]);
48 var drainDataPromise = core.drainData(result.response.body);
49 drainDataPromise.then(function(result) {
50 console.log("read " + result.buffer.byteLength + " bytes");
51 }).then(function() {
52 mojo.quit();
53 });
54 });
55 });
OLDNEW
« no previous file with comments | « mojo/apps/js/js_app.cc ('k') | mojo/apps/js/mojo.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698