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

Unified Diff: sdk/lib/io/file_impl.dart

Issue 291343009: Add initial Random Access File information to Observatory (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 7 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 | « runtime/bin/vmservice/client/lib/src/elements/service_view.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/io/file_impl.dart
diff --git a/sdk/lib/io/file_impl.dart b/sdk/lib/io/file_impl.dart
index 5b4cddb0bd2b3f3490e00372834ba0ce5cb43581..d5e4cfc2950e1f203fa63a091a43800537f87a78 100644
--- a/sdk/lib/io/file_impl.dart
+++ b/sdk/lib/io/file_impl.dart
@@ -556,18 +556,51 @@ class _File extends FileSystemEntity implements File {
}
-class _RandomAccessFile implements RandomAccessFile {
+class _RandomAccessFile
+ extends Object with _ServiceObject
+ implements RandomAccessFile {
+ // Use default Map so we keep order.
+ static Map<int, _RandomAccessFile> _files = new Map<int, _RandomAccessFile>();
+
final String path;
int _id;
bool _asyncDispatched = false;
SendPort _fileService;
- _RandomAccessFile(this._id, this.path);
+
+ _RandomAccessFile(this._id, this.path) {
+ _files[_serviceId] = this;
+ }
+
+ String get _serviceTypePath => 'io/file/randomaccessfiles';
+ String get _serviceTypeName => 'RandomAccessFile';
+
+ Map _toJSON(bool ref) {
+ var r = {
+ 'id': _servicePath,
+ 'type': _serviceType(ref),
+ 'name': '$path',
+ 'user_name': '$path',
+ };
+ if (ref) {
+ return r;
+ }
+ r['asyncDispatched'] = _asyncDispatched;
+ r['fd'] = _id;
+ return r;
+ }
+
+ void _maybePerformCleanup() {
+ if (closed) {
+ _files.remove(_serviceId);
+ }
+ }
Future<RandomAccessFile> close() {
return _dispatch(_FILE_CLOSE, [_id], markClosed: true).then((result) {
if (result != -1) {
_id = result;
+ _maybePerformCleanup();
return this;
} else {
throw new FileSystemException("Cannot close file", path);
@@ -584,6 +617,7 @@ class _RandomAccessFile implements RandomAccessFile {
throw new FileSystemException("Cannot close file", path);
}
_id = id;
+ _maybePerformCleanup();
}
Future<int> readByte() {
« no previous file with comments | « runtime/bin/vmservice/client/lib/src/elements/service_view.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698