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

Side by Side Diff: runtime/bin/file_patch.dart

Issue 1892623002: Fixes leak of native File objects. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Address comments Created 4 years, 8 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 unified diff | Download patch
« no previous file with comments | « runtime/bin/file_macos.cc ('k') | runtime/bin/file_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 patch class _File { 5 patch class _File {
6 /* patch */ static _exists(String path) native "File_Exists"; 6 /* patch */ static _exists(String path) native "File_Exists";
7 /* patch */ static _create(String path) native "File_Create"; 7 /* patch */ static _create(String path) native "File_Create";
8 /* patch */ static _createLink(String path, String target) 8 /* patch */ static _createLink(String path, String target)
9 native "File_CreateLink"; 9 native "File_CreateLink";
10 /* patch */ static _linkTarget(String path) native "File_LinkTarget"; 10 /* patch */ static _linkTarget(String path) native "File_LinkTarget";
11 /* patch */ static _deleteNative(String path) native "File_Delete"; 11 /* patch */ static _deleteNative(String path) native "File_Delete";
12 /* patch */ static _deleteLinkNative(String path) native "File_DeleteLink"; 12 /* patch */ static _deleteLinkNative(String path) native "File_DeleteLink";
13 /* patch */ static _rename(String oldPath, String newPath) 13 /* patch */ static _rename(String oldPath, String newPath)
14 native "File_Rename"; 14 native "File_Rename";
15 /* patch */ static _renameLink(String oldPath, String newPath) 15 /* patch */ static _renameLink(String oldPath, String newPath)
16 native "File_RenameLink"; 16 native "File_RenameLink";
17 /* patch */ static _copy(String oldPath, String newPath) native "File_Copy"; 17 /* patch */ static _copy(String oldPath, String newPath) native "File_Copy";
18 /* patch */ static _lengthFromPath(String path) native "File_LengthFromPath"; 18 /* patch */ static _lengthFromPath(String path) native "File_LengthFromPath";
19 /* patch */ static _lastModified(String path) native "File_LastModified"; 19 /* patch */ static _lastModified(String path) native "File_LastModified";
20 /* patch */ static _open(String path, int mode) native "File_Open"; 20 /* patch */ static _open(String path, int mode) native "File_Open";
21 /* patch */ static int _openStdio(int fd) native "File_OpenStdio"; 21 /* patch */ static int _openStdio(int fd) native "File_OpenStdio";
22 } 22 }
23 23
24 24
25 patch class _RandomAccessFile { 25 patch class _RandomAccessFileOps {
26 /* patch */ static int _close(int id) native "File_Close"; 26 /* patch */ factory _RandomAccessFileOps(int pointer)
27 /* patch */ static int _getFD(int id) native "File_GetFD"; 27 => new _RandomAccessFileOpsImpl(pointer);
28 /* patch */ static _readByte(int id) native "File_ReadByte";
29 /* patch */ static _read(int id, int bytes) native "File_Read";
30 /* patch */ static _readInto(int id, List<int> buffer, int start, int end)
31 native "File_ReadInto";
32 /* patch */ static _writeByte(int id, int value) native "File_WriteByte";
33 /* patch */ static _writeFrom(int id, List<int> buffer, int start, int end)
34 native "File_WriteFrom";
35 /* patch */ static _position(int id) native "File_Position";
36 /* patch */ static _setPosition(int id, int position)
37 native "File_SetPosition";
38 /* patch */ static _truncate(int id, int length) native "File_Truncate";
39 /* patch */ static _length(int id) native "File_Length";
40 /* patch */ static _flush(int id) native "File_Flush";
41 /* patch */ static _lock(int id, int lock, int start, int end)
42 native "File_Lock";
43 } 28 }
44 29
45 30
31 class _RandomAccessFileOpsImpl extends NativeFieldWrapperClass1
32 implements _RandomAccessFileOps {
33 _RandomAccessFileOpsImpl._();
34
35 factory _RandomAccessFileOpsImpl(int pointer)
36 => new _RandomAccessFileOpsImpl._().._setPointer(pointer);
37
38 void _setPointer(int pointer) native "File_SetPointer";
39
40 int getPointer() native "File_GetPointer";
41 int close() native "File_Close";
42 readByte() native "File_ReadByte";
43 read(int bytes) native "File_Read";
44 readInto(List<int> buffer, int start, int end) native "File_ReadInto";
45 writeByte(int value) native "File_WriteByte";
46 writeFrom(List<int> buffer, int start, int end) native "File_WriteFrom";
47 position() native "File_Position";
48 setPosition(int position) native "File_SetPosition";
49 truncate(int length) native "File_Truncate";
50 length() native "File_Length";
51 flush() native "File_Flush";
52 lock(int lock, int start, int end) native "File_Lock";
53 }
54
55
46 class _WatcherPath { 56 class _WatcherPath {
47 final int pathId; 57 final int pathId;
48 final String path; 58 final String path;
49 final int events; 59 final int events;
50 int count = 0; 60 int count = 0;
51 _WatcherPath(this.pathId, this.path, this.events); 61 _WatcherPath(this.pathId, this.path, this.events);
52 } 62 }
53 63
54 64
55 patch class _FileSystemWatcher { 65 patch class _FileSystemWatcher {
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
365 void _pathWatchedEnd() { 375 void _pathWatchedEnd() {
366 _subscription.cancel(); 376 _subscription.cancel();
367 _controller.close(); 377 _controller.close();
368 } 378 }
369 } 379 }
370 380
371 381
372 Uint8List _makeUint8ListView(Uint8List source, int offsetInBytes, int length) { 382 Uint8List _makeUint8ListView(Uint8List source, int offsetInBytes, int length) {
373 return new Uint8List.view(source.buffer, offsetInBytes, length); 383 return new Uint8List.view(source.buffer, offsetInBytes, length);
374 } 384 }
OLDNEW
« no previous file with comments | « runtime/bin/file_macos.cc ('k') | runtime/bin/file_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698