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

Unified Diff: runtime/bin/directory.cc

Issue 9310082: Run all directory async operations on a separate thread using native ports (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 11 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/builtin_natives.cc ('k') | runtime/bin/directory_impl.dart » ('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 739c43aaaaef8b64b94667a4877f3ab076b0fbf3..8e4cc6062832c1cf4602d76573364ba2a2f8aedf 100644
--- a/runtime/bin/directory.cc
+++ b/runtime/bin/directory.cc
@@ -129,3 +129,75 @@ void FUNCTION_NAME(Directory_Delete)(Dart_NativeArguments args) {
}
Dart_ExitScope();
}
+
+
+void DirectoryCreateService(Dart_Port dest_port_id,
+ Dart_Port reply_port_id,
+ Dart_CMessage* message) {
+ Dart_CMessage response;
Mads Ager (google) 2012/02/03 14:09:32 We should streamline this. 5 lines just to create
Søren Gjesse 2012/02/15 15:09:39 Working on adding dartutil stuff for this while po
+ Dart_CObject object;
+ response.root = &object;
+ object.type = Dart_CObject::kBool;
+ object.value.as_bool = false;
+
+ if (message->root->type == Dart_CObject::kString) {
+ bool created = Directory::Create(message->root->value.as_string);
+ object.value.as_bool = created;
+ }
+
+ Dart_PostCMessage(reply_port_id, &response);
+}
+
+
+void DirectoryDeleteService(Dart_Port dest_port_id,
+ Dart_Port reply_port_id,
+ Dart_CMessage* message) {
+ Dart_CMessage response;
+ Dart_CObject object;
+ response.root = &object;
+ object.type = Dart_CObject::kBool;
+ object.value.as_bool = false;
+
+ if (message->root->type == Dart_CObject::kString) {
Mads Ager (google) 2012/02/03 14:09:32 This takes a bool too now. Should be easy to updat
Søren Gjesse 2012/02/15 15:09:39 Done.
+ bool created = Directory::Delete(message->root->value.as_string);
Mads Ager (google) 2012/02/03 14:09:32 deleted
Søren Gjesse 2012/02/15 15:09:39 Done.
+ object.value.as_bool = created;
+ }
+
+ Dart_PostCMessage(reply_port_id, &response);
+}
+
+
+static const int kCreateService = 0;
+static const int kDeleteService = 1;
+
+
+void FUNCTION_NAME(Directory_NewServicePort)(Dart_NativeArguments args) {
+ Dart_EnterScope();
+ Dart_SetReturnValue(args, Dart_Null());
+ Dart_Handle service_id = Dart_GetNativeArgument(args, 0);
+ if (Dart_IsInteger(service_id)) {
+ int64_t value;
+ Dart_Handle result = Dart_IntegerToInt64(service_id, &value);
+ if (!Dart_IsError(result)) {
+ Dart_Port service_port = kIllegalPort;
+ switch (value) {
+ case kCreateService:
+ service_port = Dart_NewNativePort("DirectoryCreateService",
+ DirectoryCreateService,
+ true);
+ break;
+ case kDeleteService:
+ service_port = Dart_NewNativePort("DirectoryDeleteService",
+ DirectoryDeleteService,
+ true);
+ break;
+ }
+ if (service_port != kIllegalPort) {
+ // Return a send port for the service port.
+ Dart_Handle send_port = Dart_NewSendPort(service_port);
+ Dart_SetReturnValue(args, send_port);
+ }
+ }
+ }
+ Dart_ExitScope();
+}
« no previous file with comments | « runtime/bin/builtin_natives.cc ('k') | runtime/bin/directory_impl.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698