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

Unified Diff: runtime/bin/directory.cc

Issue 12316036: Merge IO v2 branch to bleeding edge (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Rebased to r18818 Created 7 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
« no previous file with comments | « runtime/bin/directory.h ('k') | runtime/bin/eventhandler_linux.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/directory.cc
diff --git a/runtime/bin/directory.cc b/runtime/bin/directory.cc
index a4b5e084350a943209271ed0c524e9ba4fcf2e34..1493b2d4fe0efa16061ff8c164c2fd33448b6810 100644
--- a/runtime/bin/directory.cc
+++ b/runtime/bin/directory.cc
@@ -9,10 +9,14 @@
#include "include/dart_api.h"
#include "platform/assert.h"
-dart::Mutex Directory::mutex_;
-int Directory::service_ports_size_ = 0;
-Dart_Port* Directory::service_ports_ = NULL;
-int Directory::service_ports_index_ = 0;
+
+// Forward declaration.
+static void DirectoryService(Dart_Port, Dart_Port, Dart_CObject*);
+
+NativeService Directory::directory_service_("DirectoryService",
+ DirectoryService,
+ 16);
+
void FUNCTION_NAME(Directory_Current)(Dart_NativeArguments args) {
Dart_EnterScope();
@@ -236,10 +240,10 @@ static CObject* DirectoryRenameRequest(const CObjectArray& request,
}
-void DirectoryService(Dart_Port dest_port_id,
- Dart_Port reply_port_id,
- Dart_CObject* message) {
- CObject* response = CObject::False();
+static void DirectoryService(Dart_Port dest_port_id,
+ Dart_Port reply_port_id,
+ Dart_CObject* message) {
+ CObject* response = CObject::IllegalArgumentError();
CObjectArray request(message);
if (message->type == Dart_CObject::kArray) {
if (request.Length() > 1 && request[0]->IsInt32()) {
@@ -274,27 +278,7 @@ void DirectoryService(Dart_Port dest_port_id,
Dart_Port Directory::GetServicePort() {
- MutexLocker lock(&mutex_);
- if (service_ports_size_ == 0) {
- ASSERT(service_ports_ == NULL);
- service_ports_size_ = 16;
- service_ports_ = new Dart_Port[service_ports_size_];
- service_ports_index_ = 0;
- for (int i = 0; i < service_ports_size_; i++) {
- service_ports_[i] = ILLEGAL_PORT;
- }
- }
-
- Dart_Port result = service_ports_[service_ports_index_];
- if (result == ILLEGAL_PORT) {
- result = Dart_NewNativePort("DirectoryService",
- DirectoryService,
- true);
- ASSERT(result != ILLEGAL_PORT);
- service_ports_[service_ports_index_] = result;
- }
- service_ports_index_ = (service_ports_index_ + 1) % service_ports_size_;
- return result;
+ return directory_service_.GetServicePort();
}
@@ -342,14 +326,16 @@ bool AsyncDirectoryListing::HandleError(const char* dir_name) {
bool SyncDirectoryListing::HandleDirectory(char* dir_name) {
Dart_Handle dir_name_dart = DartUtils::NewString(dir_name);
- Dart_Handle dir = Dart_New(directory_class_, Dart_Null(), 1, &dir_name_dart);
+ Dart_Handle dir =
+ Dart_New(directory_class_, Dart_Null(), 1, &dir_name_dart);
Dart_Invoke(results_, add_string_, 1, &dir);
return true;
}
bool SyncDirectoryListing::HandleFile(char* file_name) {
Dart_Handle file_name_dart = DartUtils::NewString(file_name);
- Dart_Handle file = Dart_New(file_class_, Dart_Null(), 1, &file_name_dart);
+ Dart_Handle file =
+ Dart_New(file_class_, Dart_Null(), 1, &file_name_dart);
Dart_Invoke(results_, add_string_, 1, &file);
return true;
}
« no previous file with comments | « runtime/bin/directory.h ('k') | runtime/bin/eventhandler_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698