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

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: 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..5992016e2aa7ee99d6a6701b306d0c4e44dc7239 100644
--- a/runtime/vm/native_message_handler.cc
+++ b/runtime/vm/native_message_handler.cc
@@ -38,13 +38,21 @@ MessageHandler::MessageStatus NativeMessageHandler::HandleMessage(
// We currently do not use OOB messages for native ports.
UNREACHABLE();
}
- // We create a native scope for handling the message.
- // 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->type() == Message::kDataType) {
+ // We create a native scope for handling the message.
+ // 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);
+ } else {
+ ASSERT(message->type() == Message::kIntegerType);
+ Dart_CObject integer;
+ integer.type = Dart_CObject_kInt64;
+ integer.value.as_int64 = message->integer();
+ (*func())(message->dest_port(), &integer);
+ }
delete message;
return kOK;
}

Powered by Google App Engine
This is Rietveld 408576698