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

Side by Side Diff: pkg/watcher/lib/src/directory_watcher/mac_os.dart

Issue 69013003: Fix some analyzer warnings and hints in pkg/watcher. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library watcher.directory_watcher.mac_os; 5 library watcher.directory_watcher.mac_os;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:io'; 8 import 'dart:io';
9 9
10 import '../constructable_file_system_event.dart'; 10 import '../constructable_file_system_event.dart';
11 import '../path_set.dart'; 11 import '../path_set.dart';
12 import '../utils.dart'; 12 import '../utils.dart';
13 import '../watch_event.dart'; 13 import '../watch_event.dart';
14 import 'resubscribable.dart'; 14 import 'resubscribable.dart';
15 15
16 import 'package:path/path.dart' as p;
17
18 /// Uses the FSEvents subsystem to watch for filesystem events. 16 /// Uses the FSEvents subsystem to watch for filesystem events.
19 /// 17 ///
20 /// FSEvents has two main idiosyncrasies that this class works around. First, it 18 /// FSEvents has two main idiosyncrasies that this class works around. First, it
21 /// will occasionally report events that occurred before the filesystem watch 19 /// will occasionally report events that occurred before the filesystem watch
22 /// was initiated. Second, if multiple events happen to the same file in close 20 /// was initiated. Second, if multiple events happen to the same file in close
23 /// succession, it won't report them in the order they occurred. See issue 21 /// succession, it won't report them in the order they occurred. See issue
24 /// 14373. 22 /// 14373.
25 /// 23 ///
26 /// This also works around issues 14793, 14806, and 14849 in the implementation 24 /// This also works around issues 14793, 14806, and 14849 in the implementation
27 /// of [Directory.watch]. 25 /// of [Directory.watch].
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 // Don't emit ADD events for files that we already know about. Such an event 328 // Don't emit ADD events for files that we already know about. Such an event
331 // probably comes from FSEvents reporting an add that happened prior to the 329 // probably comes from FSEvents reporting an add that happened prior to the
332 // watch beginning. 330 // watch beginning.
333 if (type == ChangeType.ADD && _files.contains(path)) return; 331 if (type == ChangeType.ADD && _files.contains(path)) return;
334 332
335 _eventsController.add(new WatchEvent(type, path)); 333 _eventsController.add(new WatchEvent(type, path));
336 } 334 }
337 335
338 /// Emit an error, then close the watcher. 336 /// Emit an error, then close the watcher.
339 void _emitError(error, StackTrace stackTrace) { 337 void _emitError(error, StackTrace stackTrace) {
340 _eventsController.add(error, stackTrace); 338 _eventsController.addError(error, stackTrace);
341 close(); 339 close();
342 } 340 }
343 341
344 /// Like [Stream.listen], but automatically adds the subscription to 342 /// Like [Stream.listen], but automatically adds the subscription to
345 /// [_subscriptions] so that it can be canceled when [close] is called. 343 /// [_subscriptions] so that it can be canceled when [close] is called.
346 void _listen(Stream stream, void onData(event), {Function onError, 344 void _listen(Stream stream, void onData(event), {Function onError,
347 void onDone(), bool cancelOnError}) { 345 void onDone(), bool cancelOnError}) {
348 var subscription; 346 var subscription;
349 subscription = stream.listen(onData, onError: onError, onDone: () { 347 subscription = stream.listen(onData, onError: onError, onDone: () {
350 _subscriptions.remove(subscription); 348 _subscriptions.remove(subscription);
351 if (onDone != null) onDone(); 349 if (onDone != null) onDone();
352 }, cancelOnError: cancelOnError); 350 }, cancelOnError: cancelOnError);
353 _subscriptions.add(subscription); 351 _subscriptions.add(subscription);
354 } 352 }
355 } 353 }
OLDNEW
« no previous file with comments | « pkg/watcher/lib/src/directory_watcher/linux.dart ('k') | pkg/watcher/lib/src/directory_watcher/polling.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698