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

Unified Diff: runtime/vm/native_message_handler.cc

Issue 1499853004: Adds a special case for sending an int over a port with the native API. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Cleanup Created 5 years 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
Index: runtime/vm/native_message_handler.cc
diff --git a/runtime/vm/native_message_handler.cc b/runtime/vm/native_message_handler.cc
index 8f8d7a6971c725426060d8f1a5aa9aa6d4666a95..e99caa5debe3ee22d3b456bdebf6d2571faf359e 100644
--- a/runtime/vm/native_message_handler.cc
+++ b/runtime/vm/native_message_handler.cc
@@ -42,9 +42,22 @@ MessageHandler::MessageStatus NativeMessageHandler::HandleMessage(
// All allocation of objects for decoding the message is done in the
// zone associated with this scope.
ApiNativeScope scope;
- ApiMessageReader reader(message->data(), message->len());
- Dart_CObject* object = reader.ReadMessage();
- (*func())(message->dest_port(), object);
+
+ if (message->IsRaw()) {
+ // TODO(zra): This should be folded into ApiMessageReader. This will likely
+ // require ApiMessageReader to have a constructor that takes a Message*.
+ ASSERT(ApiObjectConverter::CanConvert(message->raw_obj()));
+ Dart_CObject object;
+ bool success = ApiObjectConverter::Convert(message->raw_obj(), &object);
+ ASSERT(success);
+ (*func())(message->dest_port(), &object);
+ } else {
+ Dart_CObject* object;
+ ApiMessageReader reader(message->data(), message->len());
+ object = reader.ReadMessage();
+ (*func())(message->dest_port(), object);
+ }
+
delete message;
return kOK;
}

Powered by Google App Engine
This is Rietveld 408576698