Chromium Code Reviews| 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..49db2080d06141240bdae85856121d689191e834 100644 |
| --- a/sdk/lib/io/file_impl.dart |
| +++ b/sdk/lib/io/file_impl.dart |
| @@ -556,18 +556,50 @@ class _File extends FileSystemEntity implements File { |
| } |
| -class _RandomAccessFile implements RandomAccessFile { |
| +class _RandomAccessFile |
| + extends Object with _ServiceObject |
| + implements RandomAccessFile { |
| + |
| final String path; |
| int _id; |
| bool _asyncDispatched = false; |
| SendPort _fileService; |
| - _RandomAccessFile(this._id, this.path); |
| + final String _serviceTypePath = 'io/file/randomaccessfiles'; |
|
Anders Johnsen
2014/05/25 17:59:23
Make getters so they don't take up an extra word.
Cutch
2014/05/26 15:32:17
Done.
|
| + final String _serviceTypeName = 'RandomAccessFile'; |
| + |
| + // Use default Map so we keep order. |
| + static Map<int, _RandomAccessFile> _files = new Map<int, _RandomAccessFile>(); |
|
Anders Johnsen
2014/05/25 17:59:23
Please move statics to the top of the class.
Cutch
2014/05/26 15:32:17
Done.
|
| + |
| + Map _toJSON(bool ref) { |
|
Anders Johnsen
2014/05/25 17:59:23
Move methods below constructor.
Cutch
2014/05/26 15:32:17
Done.
|
| + var r = { |
| + 'id': _servicePath, |
| + 'type': _serviceType(ref), |
| + 'name': '$path', |
| + 'user_name': '$path', |
| + }; |
| + if (ref) { |
| + return r; |
| + } |
| + r['asyncDispatched'] = _asyncDispatched; |
| + return r; |
| + } |
| + |
| + _RandomAccessFile(this._id, this.path) { |
| + _files[_serviceId] = this; |
| + } |
| + |
| + 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 +616,7 @@ class _RandomAccessFile implements RandomAccessFile { |
| throw new FileSystemException("Cannot close file", path); |
| } |
| _id = id; |
| + _maybePerformCleanup(); |
| } |
| Future<int> readByte() { |