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

Unified Diff: sdk/lib/_internal/pub_generated/lib/src/barback/source_directory.dart

Issue 657673002: Regenerate pub sources. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
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: sdk/lib/_internal/pub_generated/lib/src/barback/source_directory.dart
diff --git a/sdk/lib/_internal/pub_generated/lib/src/barback/source_directory.dart b/sdk/lib/_internal/pub_generated/lib/src/barback/source_directory.dart
index 14b0646a16560600398d26175843617068ab492c..9996ab9d1fa690e7995eba1f49b6a42c279b8926 100644
--- a/sdk/lib/_internal/pub_generated/lib/src/barback/source_directory.dart
+++ b/sdk/lib/_internal/pub_generated/lib/src/barback/source_directory.dart
@@ -1,17 +1,46 @@
+// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
library pub.barback.source_directory;
+
import 'dart:async';
+
import 'package:watcher/watcher.dart';
+
import 'asset_environment.dart';
import 'barback_server.dart';
+
+/// A directory in the entrypoint package whose contents have been made
+/// available to barback and that are bound to a server.
class SourceDirectory {
final AssetEnvironment _environment;
+
+ /// The relative directory path within the package.
final String directory;
+
+ /// The hostname to serve this directory on.
final String hostname;
+
+ /// The port to serve this directory on.
final int port;
+
+ /// The server bound to this directory.
+ ///
+ /// This is a future that will complete once [serve] has been called and the
+ /// server has been successfully spun up.
Future<BarbackServer> get server => _serverCompleter.future;
final _serverCompleter = new Completer<BarbackServer>();
+
+ /// The subscription to the [DirectoryWatcher] used to watch this directory
+ /// for changes.
+ ///
+ /// If the directory is not being watched, this will be `null`.
StreamSubscription<WatchEvent> watchSubscription;
+
SourceDirectory(this._environment, this.directory, this.hostname, this.port);
+
+ /// Binds a server running on [hostname]:[port] to this directory.
Future<BarbackServer> serve() {
return BarbackServer.bind(
_environment,
@@ -22,13 +51,20 @@ class SourceDirectory {
return server;
});
}
+
+ /// Removes the source directory from the build environment.
+ ///
+ /// Closes the server, removes the assets from barback, and stops watching it.
Future close() {
return server.then((server) {
var futures = [server.close()];
+
+ // Stop watching the directory.
if (watchSubscription != null) {
var cancel = watchSubscription.cancel();
if (cancel != null) futures.add(cancel);
}
+
return Future.wait(futures);
});
}

Powered by Google App Engine
This is Rietveld 408576698