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

Side by Side 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/native_message_handler.h" 5 #include "vm/native_message_handler.h"
6 6
7 #include "vm/dart_api_message.h" 7 #include "vm/dart_api_message.h"
8 #include "vm/isolate.h" 8 #include "vm/isolate.h"
9 #include "vm/message.h" 9 #include "vm/message.h"
10 #include "vm/snapshot.h" 10 #include "vm/snapshot.h"
(...skipping 24 matching lines...) Expand all
35 MessageHandler::MessageStatus NativeMessageHandler::HandleMessage( 35 MessageHandler::MessageStatus NativeMessageHandler::HandleMessage(
36 Message* message) { 36 Message* message) {
37 if (message->IsOOB()) { 37 if (message->IsOOB()) {
38 // We currently do not use OOB messages for native ports. 38 // We currently do not use OOB messages for native ports.
39 UNREACHABLE(); 39 UNREACHABLE();
40 } 40 }
41 // We create a native scope for handling the message. 41 // We create a native scope for handling the message.
42 // All allocation of objects for decoding the message is done in the 42 // All allocation of objects for decoding the message is done in the
43 // zone associated with this scope. 43 // zone associated with this scope.
44 ApiNativeScope scope; 44 ApiNativeScope scope;
45 ApiMessageReader reader(message->data(), message->len()); 45
46 Dart_CObject* object = reader.ReadMessage(); 46 if (message->IsRaw()) {
47 (*func())(message->dest_port(), object); 47 // TODO(zra): This should be folded into ApiMessageReader. This will likely
48 // require ApiMessageReader to have a constructor that takes a Message*.
49 ASSERT(ApiObjectConverter::CanConvert(message->raw_obj()));
50 Dart_CObject object;
51 bool success = ApiObjectConverter::Convert(message->raw_obj(), &object);
52 ASSERT(success);
53 (*func())(message->dest_port(), &object);
54 } else {
55 Dart_CObject* object;
56 ApiMessageReader reader(message->data(), message->len());
57 object = reader.ReadMessage();
58 (*func())(message->dest_port(), object);
59 }
60
48 delete message; 61 delete message;
49 return kOK; 62 return kOK;
50 } 63 }
51 64
52 } // namespace dart 65 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698