OLD | NEW |
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" |
11 | 11 |
12 namespace dart { | 12 namespace dart { |
13 | 13 |
14 NativeMessageHandler::NativeMessageHandler(const char* name, | 14 NativeMessageHandler::NativeMessageHandler(const char* name, |
15 Dart_NativeMessageHandler func) | 15 Dart_NativeMessageHandler func) |
16 : name_(strdup(name)), | 16 : name_(strdup(name)), func_(func) {} |
17 func_(func) { | |
18 } | |
19 | 17 |
20 | 18 |
21 NativeMessageHandler::~NativeMessageHandler() { | 19 NativeMessageHandler::~NativeMessageHandler() { |
22 free(name_); | 20 free(name_); |
23 } | 21 } |
24 | 22 |
25 | 23 |
26 #if defined(DEBUG) | 24 #if defined(DEBUG) |
27 void NativeMessageHandler::CheckAccess() { | 25 void NativeMessageHandler::CheckAccess() { |
28 ASSERT(Isolate::Current() == NULL); | 26 ASSERT(Isolate::Current() == NULL); |
(...skipping 13 matching lines...) Expand all Loading... |
42 ApiNativeScope scope; | 40 ApiNativeScope scope; |
43 Dart_CObject* object; | 41 Dart_CObject* object; |
44 ApiMessageReader reader(message); | 42 ApiMessageReader reader(message); |
45 object = reader.ReadMessage(); | 43 object = reader.ReadMessage(); |
46 (*func())(message->dest_port(), object); | 44 (*func())(message->dest_port(), object); |
47 delete message; | 45 delete message; |
48 return kOK; | 46 return kOK; |
49 } | 47 } |
50 | 48 |
51 } // namespace dart | 49 } // namespace dart |
OLD | NEW |