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

Unified Diff: runtime/bin/file.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/file.h ('k') | runtime/bin/platform_win.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/file.cc
diff --git a/runtime/bin/file.cc b/runtime/bin/file.cc
index bd32b5b5dc94b5635c940de870a91364088c3140..e366fc23cda3069030abca5d0f6b1d028a7b0559 100644
--- a/runtime/bin/file.cc
+++ b/runtime/bin/file.cc
@@ -14,10 +14,11 @@
static const int kMSPerSecond = 1000;
-dart::Mutex File::mutex_;
-int File::service_ports_size_ = 0;
-Dart_Port* File::service_ports_ = NULL;
-int File::service_ports_index_ = 0;
+
+// Forward declaration.
+static void FileService(Dart_Port, Dart_Port, Dart_CObject*);
+
+NativeService File::file_service_("FileService", FileService, 16);
// The file pointer has been passed into Dart as an intptr_t and it is safe
@@ -890,10 +891,10 @@ static CObject* FileWriteListRequest(const CObjectArray& request) {
}
-void FileService(Dart_Port dest_port_id,
+static void FileService(Dart_Port dest_port_id,
Dart_Port reply_port_id,
Dart_CObject* message) {
- CObject* response = CObject::False();
+ CObject* response = CObject::IllegalArgumentError();
CObjectArray request(message);
if (message->type == Dart_CObject::kArray) {
if (request.Length() > 1 && request[0]->IsInt32()) {
@@ -967,27 +968,7 @@ void FileService(Dart_Port dest_port_id,
Dart_Port File::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("FileService",
- FileService,
- true);
- ASSERT(result != ILLEGAL_PORT);
- service_ports_[service_ports_index_] = result;
- }
- service_ports_index_ = (service_ports_index_ + 1) % service_ports_size_;
- return result;
+ return file_service_.GetServicePort();
}
« no previous file with comments | « runtime/bin/file.h ('k') | runtime/bin/platform_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698