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

Side by Side Diff: runtime/vm/native_message_handler.cc

Issue 2651633002: VM: [Kernel] Fix bootstraping when Kernel isolate is used. (Closed)
Patch Set: Landing issue Created 3 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 unified diff | Download patch
« no previous file with comments | « runtime/vm/native_message_handler.h ('k') | runtime/vm/service_isolate.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"
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)), func_(func) {} 16 void* peer)
17 : name_(strdup(name)), func_(func), peer_(peer) {}
17 18
18 19
19 NativeMessageHandler::~NativeMessageHandler() { 20 NativeMessageHandler::~NativeMessageHandler() {
20 free(name_); 21 free(name_);
21 } 22 }
22 23
23 24
24 #if defined(DEBUG) 25 #if defined(DEBUG)
25 void NativeMessageHandler::CheckAccess() { 26 void NativeMessageHandler::CheckAccess() {
26 ASSERT(Isolate::Current() == NULL); 27 ASSERT(Isolate::Current() == NULL);
27 } 28 }
28 #endif 29 #endif
29 30
30 31
31 MessageHandler::MessageStatus NativeMessageHandler::HandleMessage( 32 MessageHandler::MessageStatus NativeMessageHandler::HandleMessage(
32 Message* message) { 33 Message* message) {
33 if (message->IsOOB()) { 34 if (message->IsOOB()) {
34 // We currently do not use OOB messages for native ports. 35 // We currently do not use OOB messages for native ports.
35 UNREACHABLE(); 36 UNREACHABLE();
36 } 37 }
37 // We create a native scope for handling the message. 38 // We create a native scope for handling the message.
38 // All allocation of objects for decoding the message is done in the 39 // All allocation of objects for decoding the message is done in the
39 // zone associated with this scope. 40 // zone associated with this scope.
40 ApiNativeScope scope; 41 ApiNativeScope scope;
41 Dart_CObject* object; 42 Dart_CObject* object;
42 ApiMessageReader reader(message); 43 ApiMessageReader reader(message);
43 object = reader.ReadMessage(); 44 object = reader.ReadMessage();
44 (*func())(message->dest_port(), object); 45 (*func())(message->dest_port(), object, peer());
45 delete message; 46 delete message;
46 return kOK; 47 return kOK;
47 } 48 }
48 49
49 } // namespace dart 50 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/native_message_handler.h ('k') | runtime/vm/service_isolate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698