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

Unified Diff: runtime/vm/native_message_handler.cc

Issue 9325022: Decode the Dart message into a Dart_CMessage structure before calling the native port callback (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressed review comments from asiva@ Created 8 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/vm/growable_array.h ('k') | runtime/vm/snapshot.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/native_message_handler.cc
diff --git a/runtime/vm/native_message_handler.cc b/runtime/vm/native_message_handler.cc
index ebc7121c84895ddd193c3ed90128fdbca84e8eb9..8f47e7ff748afed58d107113ae100744aac54e29 100644
--- a/runtime/vm/native_message_handler.cc
+++ b/runtime/vm/native_message_handler.cc
@@ -4,8 +4,10 @@
#include "vm/native_message_handler.h"
+#include "vm/dart_api_message.h"
#include "vm/isolate.h"
#include "vm/message.h"
+#include "vm/snapshot.h"
#include "vm/thread.h"
namespace dart {
@@ -31,6 +33,14 @@ void NativeMessageHandler::CheckAccess() {
#endif
+static uint8_t* zone_allocator(
+ uint8_t* ptr, intptr_t old_size, intptr_t new_size) {
+ ApiZone* zone = ApiNativeScope::Current()->zone();
+ return reinterpret_cast<uint8_t*>(
+ zone->Reallocate(reinterpret_cast<uword>(ptr), old_size, new_size));
+}
+
+
static void RunWorker(uword parameter) {
NativeMessageHandler* handler =
reinterpret_cast<NativeMessageHandler*>(parameter);
@@ -47,12 +57,19 @@ static void RunWorker(uword parameter) {
// dispatched to special vm code. Implement.
UNIMPLEMENTED();
}
- // TODO(sgjesse): Once CMessageReader::ReadObject is committed,
- // use that here and pass the resulting data object to the
- // handler instead.
+ // Enter a native scope for handling the message. This will create a
+ // zone for allocating the objects for decoding the message.
+ ApiNativeScope scope;
+
+ int32_t length = reinterpret_cast<int32_t*>(
+ message->data())[Snapshot::kLengthIndex];
+ ApiMessageReader reader(message->data() + Snapshot::kHeaderSize,
+ length,
+ zone_allocator);
+ Dart_CObject* object = reader.ReadMessage();
(*handler->func())(message->dest_port(),
message->reply_port(),
- message->data());
+ object);
delete message;
}
}
« no previous file with comments | « runtime/vm/growable_array.h ('k') | runtime/vm/snapshot.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698