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

Unified Diff: runtime/vm/port.cc

Issue 9182001: OOB messages and general message refactor. (Closed) Base URL: http://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/vm/port.h ('k') | runtime/vm/port_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/port.cc
===================================================================
--- runtime/vm/port.cc (revision 3557)
+++ runtime/vm/port.cc (working copy)
@@ -7,6 +7,7 @@
#include "platform/utils.h"
#include "vm/dart_api_impl.h"
#include "vm/isolate.h"
+#include "vm/message_queue.h"
#include "vm/thread.h"
namespace dart {
@@ -165,12 +166,7 @@
deleted_++;
MaintainInvariants();
}
-
- // Notify the embedder that this port is closed.
- Dart_ClosePortCallback callback = isolate->close_port_callback();
- ASSERT(callback);
- ASSERT(port != kCloseAllPorts);
- (*callback)(Api::CastIsolate(isolate), port);
+ isolate->ClosePort(port);
}
@@ -191,19 +187,16 @@
}
MaintainInvariants();
}
-
- // Notify the embedder that all ports are closed.
- Dart_ClosePortCallback callback = isolate->close_port_callback();
- ASSERT(callback);
- (*callback)(Api::CastIsolate(isolate), kCloseAllPorts);
+ isolate->CloseAllPorts();
}
-bool PortMap::PostMessage(Dart_Port dest_port,
- Dart_Port reply_port,
- Dart_Message message) {
+bool PortMap::PostMessage(Message* message) {
+ // TODO(turnidge): Add a scoped locker for mutexes which is not a
+ // stack resource. This would probably be useful in the platform
+ // headers.
mutex_->Lock();
- intptr_t index = FindPort(dest_port);
+ intptr_t index = FindPort(message->dest_port());
if (index < 0) {
free(message);
mutex_->Unlock();
@@ -214,27 +207,9 @@
Isolate* isolate = map_[index].isolate;
ASSERT(map_[index].port != 0);
ASSERT((isolate != NULL) && (isolate != deleted_entry_));
-
- // Delegate message delivery to the embedder.
- Dart_PostMessageCallback callback = isolate->post_message_callback();
- ASSERT(callback);
- bool result =
- (*callback)(Api::CastIsolate(isolate), dest_port, reply_port, message);
- if (FLAG_trace_isolates) {
- const char* source_name = "<native code>";
- Isolate* source_isolate = Isolate::Current();
- if (source_isolate) {
- source_name = source_isolate->name();
- }
- OS::Print("[>] Posting message:\n"
- "\tsource: %s\n"
- "\treply_port: %lld\n"
- "\tdest: %s\n"
- "\tdest_port: %lld\n",
- source_name, reply_port, isolate->name(), dest_port);
- }
+ isolate->PostMessage(message);
mutex_->Unlock();
- return result;
+ return true;
}
« no previous file with comments | « runtime/vm/port.h ('k') | runtime/vm/port_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698