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

Unified Diff: mojo/dart/mojom/lib/src/utils.dart

Issue 1318903005: Move mojom to public/dart (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 4 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 | « mojo/dart/mojom/lib/src/options.dart ('k') | mojo/dart/mojom/pubspec.lock » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/dart/mojom/lib/src/utils.dart
diff --git a/mojo/dart/mojom/lib/src/utils.dart b/mojo/dart/mojom/lib/src/utils.dart
deleted file mode 100644
index c62c1bab7851be7f18f8642c2653e5c8637c9734..0000000000000000000000000000000000000000
--- a/mojo/dart/mojom/lib/src/utils.dart
+++ /dev/null
@@ -1,100 +0,0 @@
-// Copyright 2015 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-part of generate;
-
-bool isMojomDart(String path) => path.endsWith('.mojom.dart');
-bool isMojom(String path) => path.endsWith('.mojom');
-
-/// An Error for problems on the command line.
-class CommandLineError extends Error {
- final _msg;
- CommandLineError(this._msg);
- toString() => _msg;
-}
-
-/// An Error for failures of the bindings generation script.
-class GenerationError extends Error {
- final _msg;
- GenerationError(this._msg);
- toString() => _msg;
-}
-
-/// An Error for failing to download a .mojom file.
-class DownloadError extends Error {
- final _msg;
- DownloadError(this._msg);
- toString() => _msg;
-}
-
-/// The base type of data passed to actions for [mojomDirIter].
-class PackageIterData {
- Directory currentPackage;
- PackageIterData(this.currentPackage);
-}
-
-/// Data for [mojomDirIter] that includes the path to the Mojo SDK for bindings
-/// generation.
-class GenerateIterData extends PackageIterData {
- final Directory _mojoSdk;
- GenerateIterData(this._mojoSdk) : super(null);
- Directory get mojoSdk => _mojoSdk;
-}
-
-/// The type of action performed by [mojomDirIter].
-typedef Future MojomAction(PackageIterData data, Directory mojomDirectory);
-
-packageDirIter(
- Directory packages, PackageIterData data, MojomAction action) async {
- await for (var package in packages.list()) {
- if (package is Directory) {
- if (data != null) {
- data.currentPackage = package;
- }
- await action(data, package);
- }
- }
-}
-
-/// Iterates over mojom directories of Dart packages, taking some action for
-/// each.
-///
-/// For each 'mojom' subdirectory of each subdirectory in [packages], runs
-/// [action] on the subdirectory passing along [data] to [action].
-mojomDirIter(
- Directory packages, PackageIterData data, MojomAction action) async {
- await packageDirIter(packages, data, (d, p) async {
- if (verbose) print("package = $p");
- final mojomDirectory = new Directory(path.join(p.path, 'mojom'));
- if (verbose) print("looking for = $mojomDirectory");
- if (await mojomDirectory.exists()) {
- await action(d, mojomDirectory);
- } else if (verbose) {
- print("$mojomDirectory not found");
- }
- });
-}
-
-/// Download file at [url] using [httpClient]. Throw a [DownloadError] if
-/// the file is not successfully downloaded.
-Future<String> getUrl(HttpClient httpClient, String url) async {
- try {
- var request = await httpClient.getUrl(Uri.parse(url));
- var response = await request.close();
- if (response.statusCode >= 400) {
- var msg = "Failed to download $url\nCode ${response.statusCode}";
- if (response.reasonPhrase != null) {
- msg = "$msg: ${response.reasonPhrase}";
- }
- throw new DownloadError(msg);
- }
- var fileString = new StringBuffer();
- await for (String contents in response.transform(UTF8.decoder)) {
- fileString.write(contents);
- }
- return fileString.toString();
- } catch (e) {
- throw new DownloadError("$e");
- }
-}
« no previous file with comments | « mojo/dart/mojom/lib/src/options.dart ('k') | mojo/dart/mojom/pubspec.lock » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698