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

Unified Diff: sky/examples/dart-mojo.sky

Issue 980323003: Clean up examples directory (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 10 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
« no previous file with comments | « sky/examples/custom-element/index.sky ('k') | sky/examples/example-element/example-element.sky » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sky/examples/dart-mojo.sky
diff --git a/sky/examples/dart-mojo.sky b/sky/examples/dart-mojo.sky
deleted file mode 100644
index 056bc71ca92d0a476b911a630f4a1acd9c58b9b6..0000000000000000000000000000000000000000
--- a/sky/examples/dart-mojo.sky
+++ /dev/null
@@ -1,82 +0,0 @@
-#!mojo mojo:sky_viewer
-<sky>
-<import src="dart-library.sky" as="library" />
-<script>
-import 'dart:async';
-import '/mojo/public/dart/application.dart';
-import 'dart:typed_data';
-import 'dart:sky.internals' as internals;
-import 'mojo:bindings';
-import 'mojo:core';
-
-import 'package:mojo/services/network/public/interfaces/network_service.mojom.dart';
-import 'package:mojo/services/network/public/interfaces/url_loader.mojom.dart';
-import 'package:mojo/public/interfaces/application/shell.mojom.dart' as shell_mojom;
-
-class WGet extends Application {
- NetworkServiceProxy _networkService;
- UrlLoaderProxy _urlLoaderProxy;
-
- WGet.fromHandle(MojoHandle handle) : super.fromHandle(handle);
- WGet(MojoMessagePipeEndpoint endpoint) : super(endpoint);
-
- void initialize(List<String> args, String url) {
- run(args);
- }
-
- run(List<String> args) async {
- if (args == null || args.length != 2) {
- throw "Expected URL argument";
- }
-
- ByteData bodyData = await _getUrl(args[1]);
- print("read ${bodyData.lengthInBytes} bytes");
-
- _closeProxies();
- close();
- }
-
- Future<ByteData> _getUrl(String url) async {
- _initProxiesIfNeeded();
-
- var urlRequest = new UrlRequest()
- ..url = url
- ..autoFollowRedirects = true;
-
- var urlResponse = await _urlLoaderProxy.start(urlRequest);
- print("url => ${urlResponse.response.url}");
- print("status_line => ${urlResponse.response.statusLine}");
- print("mime_type => ${urlResponse.response.mimeType}");
-
- return DataPipeDrainer.drainHandle(urlResponse.response.body);
- }
-
- void _initProxiesIfNeeded() {
- if (_networkService == null) {
- _networkService = new NetworkServiceProxy.unbound();
- connectToService("mojo:network_service", _networkService);
- }
- if (_urlLoaderProxy == null) {
- _urlLoaderProxy = new UrlLoaderProxy.unbound();
- _networkService.createUrlLoader(_urlLoaderProxy);
- }
- }
-
- void _closeProxies() {
- _urlLoaderProxy.close();
- _networkService.close();
- _urlLoaderProxy = null;
- _networkService = null;
- }
-}
-
-main() {
- var messagePipe = new MojoMessagePipe();
- var wget = new WGet(messagePipe.endpoints[1]);
- wget.listen();
- var shellProxy = new shell_mojom.ShellProxy.fromHandle(new MojoHandle(internals.takeShellProxyHandle()));
- wget.initializeFromShellProxy(shellProxy, ["mojo:wget", "http://www.google.com"], "mojo:wget");
-}
-
-</script>
-</sky>
« no previous file with comments | « sky/examples/custom-element/index.sky ('k') | sky/examples/example-element/example-element.sky » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698