Index: runtime/bin/directory_impl.dart |
diff --git a/runtime/bin/directory_impl.dart b/runtime/bin/directory_impl.dart |
index 598a5a4e14e5c58dfbba03bd88cb4e9146b58992..021599d37567f94cf1964f44f04429d545876d44 100644 |
--- a/runtime/bin/directory_impl.dart |
+++ b/runtime/bin/directory_impl.dart |
@@ -1,4 +1,4 @@ |
-// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
// for details. All rights reserved. Use of this source code is governed by a |
// BSD-style license that can be found in the LICENSE file. |
@@ -157,6 +157,8 @@ class _DirectoryOperationScheduler { |
class _Directory implements Directory { |
+ static final int kCreateService = 0; |
+ static final int kDeleteService = 1; |
_Directory(String this._path) |
: _scheduler = new _DirectoryOperationScheduler(); |
@@ -166,6 +168,8 @@ class _Directory implements Directory { |
static int _exists(String path) native "Directory_Exists"; |
static bool _create(String path) native "Directory_Create"; |
static bool _delete(String path) native "Directory_Delete"; |
+ static SendPort _newServicePort(int service_id) |
+ native "Directory_NewServicePort"; |
void exists() { |
var handler = (_existsHandler != null) ? _existsHandler : (result) => null; |
@@ -190,15 +194,16 @@ class _Directory implements Directory { |
} |
void create() { |
- var handler = (_createHandler != null) ? _createHandler : () => null; |
- var operation = new _DirCreateOperation(_path); |
- _scheduler.enqueue(operation, (result, ignored) { |
- if (result) { |
- handler(); |
- } else if (_errorHandler != null) { |
- _errorHandler("Directory creation failed: $_path"); |
- } |
- }); |
+ if (_directoryCreateService == null) { |
+ _directoryCreateService = _newServicePort(kCreateService); |
+ } |
+ _directoryCreateService.call(_path).receive((result, replyTo) { |
+ if (result) { |
+ if (_createHandler != null) _createHandler(); |
+ } else if (_errorHandler != null) { |
+ _errorHandler("Directory creation failed: $_path"); |
+ } |
+ }); |
} |
void createSync() { |
@@ -236,15 +241,16 @@ class _Directory implements Directory { |
} |
void delete() { |
- var handler = (_deleteHandler != null) ? _deleteHandler : () => null; |
- var operation = new _DirDeleteOperation(_path); |
- _scheduler.enqueue(operation, (result, ignored) { |
- if (result) { |
- handler(); |
- } else if (_errorHandler != null) { |
- _errorHandler("Directory deletion failed: $_path"); |
- } |
- }); |
+ if (_directoryDeleteService == null) { |
+ _directoryDeleteService = _newServicePort(kDeleteService); |
+ } |
+ _directoryDeleteService.call(_path).receive((result, replyTo) { |
+ if (result) { |
+ if (_deleteHandler != null) _deleteHandler(); |
+ } else if (_errorHandler != null) { |
+ _errorHandler("Directory deletion failed: $_path"); |
+ } |
+ }); |
} |
void deleteSync() { |
@@ -368,4 +374,7 @@ class _Directory implements Directory { |
String _path; |
_DirectoryOperationScheduler _scheduler; |
+ |
+ static SendPort _directoryCreateService; |
+ static SendPort _directoryDeleteService; |
} |