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

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

Issue 24395013: Merge services into a shared IOService in dart:io, and use a native port. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Finish off native_service Created 7 years, 3 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 | « sdk/lib/io/file_system_entity.dart ('k') | sdk/lib/io/secure_socket.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/io/link.dart
diff --git a/sdk/lib/io/link.dart b/sdk/lib/io/link.dart
index c889a70979bb8b3234cc4c8949e58628a4ef7cbb..a1ba19f7033cff0435d496b409add6a4f51d8cd9 100644
--- a/sdk/lib/io/link.dart
+++ b/sdk/lib/io/link.dart
@@ -125,8 +125,6 @@ abstract class Link implements FileSystemEntity {
class _Link extends FileSystemEntity implements Link {
final String path;
- SendPort _fileService;
-
_Link(String this.path) {
if (path is! String) {
throw new ArgumentError('${Error.safeToString(path)} '
@@ -148,21 +146,17 @@ class _Link extends FileSystemEntity implements Link {
FileStat statSync() => FileStat.statSync(path);
Future<Link> create(String target) {
- _ensureFileService();
if (Platform.operatingSystem == 'windows') {
target = _makeWindowsLinkTarget(target);
}
- List request = new List(3);
- request[0] = _CREATE_LINK_REQUEST;
- request[1] = path;
- request[2] = target;
- return _fileService.call(request).then((response) {
- if (_isErrorResponse(response)) {
- throw _exceptionFromResponse(
- response, "Cannot create link to target '$target'", path);
- }
- return this;
- });
+ return IOService.dispatch(FILE_CREATE_LINK, [path, target])
+ .then((response) {
+ if (_isErrorResponse(response)) {
+ throw _exceptionFromResponse(
+ response, "Cannot create link to target '$target'", path);
+ }
+ return this;
+ });
}
void createSync(String target) {
@@ -209,11 +203,7 @@ class _Link extends FileSystemEntity implements Link {
if (recursive) {
return new Directory(path).delete(recursive: true).then((_) => this);
}
- _ensureFileService();
- List request = new List(2);
- request[0] = _DELETE_LINK_REQUEST;
- request[1] = path;
- return _fileService.call(request).then((response) {
+ return IOService.dispatch(FILE_DELETE_LINK, [path]).then((response) {
if (_isErrorResponse(response)) {
throw _exceptionFromResponse(response, "Cannot delete link", path);
}
@@ -230,18 +220,14 @@ class _Link extends FileSystemEntity implements Link {
}
Future<Link> rename(String newPath) {
- _ensureFileService();
- List request = new List(3);
- request[0] = _RENAME_LINK_REQUEST;
- request[1] = path;
- request[2] = newPath;
- return _fileService.call(request).then((response) {
- if (_isErrorResponse(response)) {
- throw _exceptionFromResponse(
- response, "Cannot rename link to '$newPath'", path);
- }
- return new Link(newPath);
- });
+ return IOService.dispatch(FILE_RENAME_LINK, [path, newPath])
+ .then((response) {
+ if (_isErrorResponse(response)) {
+ throw _exceptionFromResponse(
+ response, "Cannot rename link to '$newPath'", path);
+ }
+ return new Link(newPath);
+ });
}
Link renameSync(String newPath) {
@@ -251,11 +237,7 @@ class _Link extends FileSystemEntity implements Link {
}
Future<String> target() {
- _ensureFileService();
- List request = new List(2);
- request[0] = _LINK_TARGET_REQUEST;
- request[1] = path;
- return _fileService.call(request).then((response) {
+ return IOService.dispatch(FILE_LINK_TARGET, [path]).then((response) {
if (_isErrorResponse(response)) {
throw _exceptionFromResponse(
response, "Cannot get target of link", path);
@@ -280,12 +262,6 @@ class _Link extends FileSystemEntity implements Link {
return response is List && response[0] != _SUCCESS_RESPONSE;
}
- void _ensureFileService() {
- if (_fileService == null) {
- _fileService = _FileUtils._newServicePort();
- }
- }
-
_exceptionFromResponse(response, String message, String path) {
assert(_isErrorResponse(response));
switch (response[_ERROR_RESPONSE_ERROR_TYPE]) {
« no previous file with comments | « sdk/lib/io/file_system_entity.dart ('k') | sdk/lib/io/secure_socket.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698