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

Unified Diff: runtime/bin/file_impl.dart

Issue 9500002: Rename blahHandler to onBlah throughout dart:io. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Revert temporary edit Created 8 years, 10 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: runtime/bin/file_impl.dart
diff --git a/runtime/bin/file_impl.dart b/runtime/bin/file_impl.dart
index e21fb88b68abbd84a37720bd8467c9750659bb61..410f34a73959a0d0900e469fb8f0cd37228f8f0b 100644
--- a/runtime/bin/file_impl.dart
+++ b/runtime/bin/file_impl.dart
@@ -7,13 +7,13 @@ class _FileInputStream extends _BaseDataInputStream implements InputStream {
_file = new File(name);
_data = [];
_position = 0;
- _file.errorHandler = (String s) {
+ _file.onError = (String s) {
if (_clientErrorHandler != null) {
_clientErrorHandler();
}
};
_file.open();
- _file.openHandler = (openedFile) {
+ _file.onOpen = (openedFile) {
_readDataFromFile(openedFile);
};
}
@@ -27,17 +27,17 @@ class _FileInputStream extends _BaseDataInputStream implements InputStream {
}
void _readDataFromFile(RandomAccessFile openedFile) {
- openedFile.errorHandler = (String s) {
+ openedFile.onError = (String s) {
if (_clientErrorHandler != null) {
_clientErrorHandler();
}
};
openedFile.length();
- openedFile.lengthHandler = (length) {
+ openedFile.onLength = (length) {
var contents = new ByteArray(length);
if (length != 0) {
openedFile.readList(contents, 0, length);
- openedFile.readListHandler = (read) {
+ openedFile.onReadList = (read) {
if (read != length) {
if (_clientErrorHandler != null) {
_clientErrorHandler();
@@ -99,13 +99,13 @@ class _FileOutputStream implements OutputStream {
_pendingOperations = new List<List<int>>();
var f = new File(name);
f.open(mode);
- f.openHandler = (openedFile) {
+ f.onOpen = (openedFile) {
_file = openedFile;
_setupFileHandlers();
_processPendingOperations();
};
- f.errorHandler = (e) {
- if (_errorHandler != null) _errorHandler();
+ f.onError = (e) {
+ if (_onError != null) _onError();
};
}
@@ -117,16 +117,16 @@ class _FileOutputStream implements OutputStream {
void _setupFileHandlers() {
- _file.errorHandler = (e) {
- if (_errorHandler != null) _errorHandler();
+ _file.onError = (e) {
+ if (_onError != null) _onError();
};
- _file.noPendingWriteHandler = () {
- if (!_streamMarkedClosed && _noPendingWriteHandler != null) {
- _noPendingWriteHandler();
+ _file.onNoPendingWrite = () {
+ if (!_streamMarkedClosed && _onNoPendingWrite != null) {
+ _onNoPendingWrite();
}
};
- _file.closeHandler = () {
- if (_closeHandler != null) _closeHandler();
+ _file.onClose = () {
+ if (_onClose != null) _onClose();
};
}
@@ -166,16 +166,16 @@ class _FileOutputStream implements OutputStream {
}
}
- void set noPendingWriteHandler(void callback()) {
- _noPendingWriteHandler = callback;
+ void set onNoPendingWrite(void callback()) {
+ _onNoPendingWrite = callback;
}
- void set closeHandler(void callback()) {
- _closeHandler = callback;
+ void set onClose(void callback()) {
+ _onClose = callback;
}
- void set errorHandler(void callback()) {
- _errorHandler = callback;
+ void set onError(void callback()) {
+ _onError = callback;
}
void _processPendingOperations() {
@@ -203,9 +203,9 @@ class _FileOutputStream implements OutputStream {
// file was successfully opened.
List<List<int>> _pendingOperations;
- Function _noPendingWriteHandler;
- Function _closeHandler;
- Function _errorHandler;
+ Function _onNoPendingWrite;
+ Function _onClose;
+ Function _onError;
}
@@ -327,8 +327,8 @@ class _File implements File {
_ensureFileService();
_asyncUsed = true;
if (_name is !String) {
- if (_errorHandler != null) {
- _errorHandler('File name is not a string: $_name');
+ if (_onError != null) {
+ _onError('File name is not a string: $_name');
}
return;
}
@@ -336,7 +336,7 @@ class _File implements File {
request[0] = _FileUtils.kExistsRequest;
request[1] = _name;
_fileService.call(request).receive((exists, replyTo) {
- if (_existsHandler != null) _existsHandler(exists);
+ if (_onExists != null) _onExists(exists);
});
}
@@ -359,9 +359,9 @@ class _File implements File {
request[1] = _name;
_fileService.call(request).receive((created, replyTo) {
if (created) {
- if (_createHandler != null) _createHandler();
- } else if (_errorHandler != null) {
- _errorHandler("Cannot create file: $_name");
+ if (_onCreate != null) _onCreate();
+ } else if (_onError != null) {
+ _onError("Cannot create file: $_name");
}
});
}
@@ -385,9 +385,9 @@ class _File implements File {
request[1] = _name;
_fileService.call(request).receive((deleted, replyTo) {
if (deleted) {
- if (_deleteHandler != null) _deleteHandler();
- } else if (_errorHandler != null) {
- _errorHandler("Cannot delete file: $_name");
+ if (_onDelete != null) _onDelete();
+ } else if (_onError != null) {
+ _onError("Cannot delete file: $_name");
}
});
}
@@ -411,9 +411,9 @@ class _File implements File {
request[1] = _name;
_fileService.call(request).receive((path, replyTo) {
if (path != null) {
- if (_directoryHandler != null) _directoryHandler(new Directory(path));
- } else if (_errorHandler != null) {
- _errorHandler("Cannot get directory for: ${_name}");
+ if (_onDirectory != null) _onDirectory(new Directory(path));
+ } else if (_onError != null) {
+ _onError("Cannot get directory for: ${_name}");
}
});
}
@@ -435,9 +435,9 @@ class _File implements File {
if (mode != FileMode.READ &&
mode != FileMode.WRITE &&
mode != FileMode.APPEND) {
- if (_errorHandler != null) {
- _errorHandler("Unknown file mode. Use FileMode.READ, FileMode.WRITE " +
- "or FileMode.APPEND.");
+ if (_onError != null) {
+ _onError("Unknown file mode. Use FileMode.READ, FileMode.WRITE " +
+ "or FileMode.APPEND.");
return;
}
}
@@ -446,7 +446,7 @@ class _File implements File {
request[1] = _name;
request[2] = mode._mode; // Direct int value for serialization.
_fileService.call(request).receive((id, replyTo) {
- var handler = _openHandler;
+ var handler = _onOpen;
if (handler === null) {
// If no open handler is present, close the file immediately to
// avoid leaking an open file descriptor.
@@ -455,8 +455,8 @@ class _File implements File {
if (id != 0) {
var randomAccessFile = new _RandomAccessFile(id, _name);
handler(randomAccessFile);
- } else if (_errorHandler != null) {
- _errorHandler("Cannot open file: $_name");
+ } else if (_onError != null) {
+ _onError("Cannot open file: $_name");
}
});
}
@@ -495,9 +495,9 @@ class _File implements File {
request[1] = _name;
_fileService.call(request).receive((result, replyTo) {
if (result != null) {
- if (_fullPathHandler != null) _fullPathHandler(result);
- } else if (_errorHandler != null) {
- _errorHandler("fullPath failed");
+ if (_onFullPath != null) _onFullPath(result);
+ } else if (_onError != null) {
+ _onError("fullPath failed");
}
});
}
@@ -531,18 +531,18 @@ class _File implements File {
_asyncUsed = true;
var chunks = new _BufferList();
var stream = openInputStream();
- stream.closeHandler = () {
- if (_readAsBytesHandler != null) {
- _readAsBytesHandler(chunks.readBytes(chunks.length));
+ stream.onClose = () {
+ if (_onReadAsBytes != null) {
+ _onReadAsBytes(chunks.readBytes(chunks.length));
}
};
- stream.dataHandler = () {
+ stream.onData = () {
var chunk = stream.read();
chunks.add(chunk);
};
- stream.errorHandler = () {
- if (_errorHandler != null) {
- _errorHandler("Failed to read file as bytes: $_name");
+ stream.onError = () {
+ if (_onError != null) {
+ _onError("Failed to read file as bytes: $_name");
}
};
}
@@ -578,17 +578,17 @@ class _File implements File {
_asyncUsed = true;
var decoder = _getDecoder(encoding);
readAsBytes();
- readAsBytesHandler = (bytes) {
- if (_readAsTextHandler != null) {
+ onReadAsBytes = (bytes) {
+ if (_onReadAsText != null) {
try {
decoder.write(bytes);
} catch (var e) {
- if (_errorHandler != null) {
- _errorHandler(e.toString());
+ if (_onError != null) {
+ _onError(e.toString());
return;
}
}
- _readAsTextHandler(decoder.decoded);
+ _onReadAsText(decoder.decoded);
}
};
}
@@ -624,17 +624,17 @@ class _File implements File {
_asyncUsed = true;
var decoder = _getDecoder(encoding);
readAsBytes();
- readAsBytesHandler = (bytes) {
- if (_readAsLinesHandler != null) {
+ onReadAsBytes = (bytes) {
+ if (_onReadAsLines != null) {
try {
decoder.write(bytes);
} catch (var e) {
- if (_errorHandler != null) {
- _errorHandler(e.toString());
+ if (_onError != null) {
+ _onError(e.toString());
return;
}
}
- _readAsLinesHandler(_getDecodedLines(decoder));
+ _onReadAsLines(_getDecodedLines(decoder));
}
};
}
@@ -652,44 +652,44 @@ class _File implements File {
String get name() => _name;
- void set existsHandler(void handler(bool exists)) {
- _existsHandler = handler;
+ void set onExists(void handler(bool exists)) {
+ _onExists = handler;
}
- void set createHandler(void handler()) {
- _createHandler = handler;
+ void set onCreate(void handler()) {
+ _onCreate = handler;
}
- void set deleteHandler(void handler()) {
- _deleteHandler = handler;
+ void set onDelete(void handler()) {
+ _onDelete = handler;
}
- void set directoryHandler(void handler(Directory directory)) {
- _directoryHandler = handler;
+ void set onDirectory(void handler(Directory directory)) {
+ _onDirectory = handler;
}
- void set openHandler(void handler(RandomAccessFile file)) {
- _openHandler = handler;
+ void set onOpen(void handler(RandomAccessFile file)) {
+ _onOpen = handler;
}
- void set readAsBytesHandler(void handler(List<int> bytes)) {
- _readAsBytesHandler = handler;
+ void set onReadAsBytes(void handler(List<int> bytes)) {
+ _onReadAsBytes = handler;
}
- void set readAsTextHandler(void handler(String text)) {
- _readAsTextHandler = handler;
+ void set onReadAsText(void handler(String text)) {
+ _onReadAsText = handler;
}
- void set readAsLinesHandler(void handler(List<String> lines)) {
- _readAsLinesHandler = handler;
+ void set onReadAsLines(void handler(List<String> lines)) {
+ _onReadAsLines = handler;
}
- void set fullPathHandler(void handler(String)) {
- _fullPathHandler = handler;
+ void set onFullPath(void handler(String)) {
+ _onFullPath = handler;
}
- void set errorHandler(void handler(String error)) {
- _errorHandler = handler;
+ void set onError(void handler(String error)) {
+ _onError = handler;
}
void _ensureFileService() {
@@ -703,16 +703,16 @@ class _File implements File {
SendPort _fileService;
- Function _existsHandler;
- Function _createHandler;
- Function _deleteHandler;
- Function _directoryHandler;
- Function _openHandler;
- Function _readAsBytesHandler;
- Function _readAsTextHandler;
- Function _readAsLinesHandler;
- Function _fullPathHandler;
- Function _errorHandler;
+ Function _onExists;
+ Function _onCreate;
+ Function _onDelete;
+ Function _onDirectory;
+ Function _onOpen;
+ Function _onReadAsBytes;
+ Function _onReadAsText;
+ Function _onReadAsLines;
+ Function _onFullPath;
+ Function _onError;
}
@@ -732,9 +732,9 @@ class _RandomAccessFile implements RandomAccessFile {
_fileService.call(request).receive((result, replyTo) {
if (result != -1) {
_id = result;
- if (_closeHandler != null) _closeHandler();
- } else if (_errorHandler != null) {
- _errorHandler("Cannot close file: $_name");
+ if (_onClose != null) _onClose();
+ } else if (_onError != null) {
+ _onError("Cannot close file: $_name");
}
});
}
@@ -759,9 +759,9 @@ class _RandomAccessFile implements RandomAccessFile {
request[1] = _id;
_fileService.call(request).receive((result, replyTo) {
if (result != -1) {
- if (_readByteHandler != null) _readByteHandler(result);
- } else if (_errorHandler != null) {
- _errorHandler("readByte failed");
+ if (_onReadByte != null) _onReadByte(result);
+ } else if (_onError != null) {
+ _onError("readByte failed");
}
});
}
@@ -782,8 +782,8 @@ class _RandomAccessFile implements RandomAccessFile {
_ensureFileService();
_asyncUsed = true;
if (buffer is !List || offset is !int || bytes is !int) {
- if (_errorHandler != null) {
- _errorHandler("Invalid arguments to readList");
+ if (_onError != null) {
+ _onError("Invalid arguments to readList");
}
return;
};
@@ -796,10 +796,10 @@ class _RandomAccessFile implements RandomAccessFile {
var read = result[0];
var data = result[1];
buffer.setRange(offset, read, data);
- if (_readListHandler != null) _readListHandler(read);
+ if (_onReadList != null) _onReadList(read);
return;
- } else if (_errorHandler != null) {
- _errorHandler(result is String ? result : "readList failed");
+ } else if (_onError != null) {
+ _onError(result is String ? result : "readList failed");
}
});
}
@@ -829,8 +829,8 @@ class _RandomAccessFile implements RandomAccessFile {
_ensureFileService();
_asyncUsed = true;
if (value is !int) {
- if (_errorHandler != null) {
- _errorHandler("Invalid argument to writeByte");
+ if (_onError != null) {
+ _onError("Invalid argument to writeByte");
}
return;
}
@@ -841,8 +841,8 @@ class _RandomAccessFile implements RandomAccessFile {
_writeEnqueued();
_fileService.call(request).receive((result, replyTo) {
_writeCompleted();
- if (result == -1 && _errorHandler !== null) {
- _errorHandler("writeByte failed");
+ if (result == -1 && _onError !== null) {
+ _onError("writeByte failed");
}
});
}
@@ -866,8 +866,8 @@ class _RandomAccessFile implements RandomAccessFile {
_ensureFileService();
_asyncUsed = true;
if (buffer is !List || offset is !int || bytes is !int) {
- if (_errorHandler != null) {
- _errorHandler("Invalid arguments to writeList");
+ if (_onError != null) {
+ _onError("Invalid arguments to writeList");
}
return;
}
@@ -886,8 +886,8 @@ class _RandomAccessFile implements RandomAccessFile {
_writeEnqueued();
_fileService.call(request).receive((result, replyTo) {
_writeCompleted();
- if (result == -1 && _errorHandler !== null) {
- _errorHandler("writeList failed");
+ if (result == -1 && _onError !== null) {
+ _onError("writeList failed");
}
});
}
@@ -923,8 +923,8 @@ class _RandomAccessFile implements RandomAccessFile {
_writeEnqueued();
_fileService.call(request).receive((result, replyTo) {
_writeCompleted();
- if (result == -1 && _errorHandler !== null) {
- _errorHandler("writeString failed");
+ if (result == -1 && _onError !== null) {
+ _onError("writeString failed");
}
});
}
@@ -949,9 +949,9 @@ class _RandomAccessFile implements RandomAccessFile {
request[1] = _id;
_fileService.call(request).receive((result, replyTo) {
if (result != -1) {
- if (_positionHandler != null) _positionHandler(result);
- } else if (_errorHandler != null) {
- _errorHandler("position failed");
+ if (_onPosition != null) _onPosition(result);
+ } else if (_onError != null) {
+ _onError("position failed");
}
});
}
@@ -977,9 +977,9 @@ class _RandomAccessFile implements RandomAccessFile {
request[2] = position;
_fileService.call(request).receive((result, replyTo) {
if (result) {
- if (_setPositionHandler != null) _setPositionHandler();
- } else if (_errorHandler != null) {
- _errorHandler("setPosition failed");
+ if (_onSetPosition != null) _onSetPosition();
+ } else if (_onError != null) {
+ _onError("setPosition failed");
}
});
}
@@ -1005,9 +1005,9 @@ class _RandomAccessFile implements RandomAccessFile {
request[2] = length;
_fileService.call(request).receive((result, replyTo) {
if (result) {
- if (_truncateHandler != null) _truncateHandler();
- } else if (_errorHandler != null) {
- _errorHandler("truncate failed");
+ if (_onTruncate != null) _onTruncate();
+ } else if (_onError != null) {
+ _onError("truncate failed");
}
});
}
@@ -1031,9 +1031,9 @@ class _RandomAccessFile implements RandomAccessFile {
request[1] = _id;
_fileService.call(request).receive((result, replyTo) {
if (result != -1) {
- if (_lengthHandler != null) _lengthHandler(result);
- } else if (_errorHandler != null) {
- _errorHandler("length failed");
+ if (_onLength != null) _onLength(result);
+ } else if (_onError != null) {
+ _onError("length failed");
}
});
}
@@ -1058,9 +1058,9 @@ class _RandomAccessFile implements RandomAccessFile {
request[1] = _id;
_fileService.call(request).receive((result, replyTo) {
if (result != -1) {
- if (_flushHandler != null) _flushHandler();
- } else if (_errorHandler != null) {
- _errorHandler("flush failed");
+ if (_onFlush != null) _onFlush();
+ } else if (_onError != null) {
+ _onError("flush failed");
}
});
}
@@ -1078,49 +1078,49 @@ class _RandomAccessFile implements RandomAccessFile {
String get name() => _name;
- void set errorHandler(void handler(String error)) {
- _errorHandler = handler;
+ void set onError(void handler(String error)) {
+ _onError = handler;
}
- void set closeHandler(void handler()) {
- _closeHandler = handler;
+ void set onClose(void handler()) {
+ _onClose = handler;
}
- void set readByteHandler(void handler(int byte)) {
- _readByteHandler = handler;
+ void set onReadByte(void handler(int byte)) {
+ _onReadByte = handler;
}
- void set readListHandler(void handler(int read)) {
- _readListHandler = handler;
+ void set onReadList(void handler(int read)) {
+ _onReadList = handler;
}
- void set noPendingWriteHandler(void handler()) {
- _noPendingWriteHandler = handler;
+ void set onNoPendingWrite(void handler()) {
+ _onNoPendingWrite = handler;
if (_pendingWrites == 0) {
_noPendingWriteTimer = new Timer((t) {
- if (_noPendingWriteHandler != null) _noPendingWriteHandler();
+ if (_onNoPendingWrite != null) _onNoPendingWrite();
}, 0);
}
}
- void set positionHandler(void handler(int pos)) {
- _positionHandler = handler;
+ void set onPosition(void handler(int pos)) {
+ _onPosition = handler;
}
- void set setPositionHandler(void handler()) {
- _setPositionHandler = handler;
+ void set onSetPosition(void handler()) {
+ _onSetPosition = handler;
}
- void set truncateHandler(void handler()) {
- _truncateHandler = handler;
+ void set onTruncate(void handler()) {
+ _onTruncate = handler;
}
- void set lengthHandler(void handler(int length)) {
- _lengthHandler = handler;
+ void set onLength(void handler(int length)) {
+ _onLength = handler;
}
- void set flushHandler(void handler()) {
- _flushHandler = handler;
+ void set onFlush(void handler()) {
+ _onFlush = handler;
}
void _ensureFileService() {
@@ -1139,8 +1139,8 @@ class _RandomAccessFile implements RandomAccessFile {
void _writeCompleted() {
_pendingWrites--;
- if (_pendingWrites == 0 && _noPendingWriteHandler != null) {
- _noPendingWriteHandler();
+ if (_pendingWrites == 0 && _onNoPendingWrite != null) {
+ _onNoPendingWrite();
}
}
@@ -1154,14 +1154,14 @@ class _RandomAccessFile implements RandomAccessFile {
Timer _noPendingWriteTimer;
- Function _closeHandler;
- Function _readByteHandler;
- Function _readListHandler;
- Function _noPendingWriteHandler;
- Function _positionHandler;
- Function _setPositionHandler;
- Function _truncateHandler;
- Function _lengthHandler;
- Function _flushHandler;
- Function _errorHandler;
+ Function _onClose;
+ Function _onReadByte;
+ Function _onReadList;
+ Function _onNoPendingWrite;
+ Function _onPosition;
+ Function _onSetPosition;
+ Function _onTruncate;
+ Function _onLength;
+ Function _onFlush;
+ Function _onError;
}

Powered by Google App Engine
This is Rietveld 408576698