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

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

Issue 2974233002: VM: Re-format to use at most one newline between functions (Closed)
Patch Set: Rebase and merge Created 3 years, 5 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_entry_test.cc ('k') | runtime/vm/native_symbol.h » ('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 : name_(strdup(name)), func_(func) {}
17 17
18
19 NativeMessageHandler::~NativeMessageHandler() { 18 NativeMessageHandler::~NativeMessageHandler() {
20 free(name_); 19 free(name_);
21 } 20 }
22 21
23
24 #if defined(DEBUG) 22 #if defined(DEBUG)
25 void NativeMessageHandler::CheckAccess() { 23 void NativeMessageHandler::CheckAccess() {
26 ASSERT(Isolate::Current() == NULL); 24 ASSERT(Isolate::Current() == NULL);
27 } 25 }
28 #endif 26 #endif
29 27
30
31 MessageHandler::MessageStatus NativeMessageHandler::HandleMessage( 28 MessageHandler::MessageStatus NativeMessageHandler::HandleMessage(
32 Message* message) { 29 Message* message) {
33 if (message->IsOOB()) { 30 if (message->IsOOB()) {
34 // We currently do not use OOB messages for native ports. 31 // We currently do not use OOB messages for native ports.
35 UNREACHABLE(); 32 UNREACHABLE();
36 } 33 }
37 // We create a native scope for handling the message. 34 // We create a native scope for handling the message.
38 // All allocation of objects for decoding the message is done in the 35 // All allocation of objects for decoding the message is done in the
39 // zone associated with this scope. 36 // zone associated with this scope.
40 ApiNativeScope scope; 37 ApiNativeScope scope;
41 Dart_CObject* object; 38 Dart_CObject* object;
42 ApiMessageReader reader(message); 39 ApiMessageReader reader(message);
43 object = reader.ReadMessage(); 40 object = reader.ReadMessage();
44 (*func())(message->dest_port(), object); 41 (*func())(message->dest_port(), object);
45 delete message; 42 delete message;
46 return kOK; 43 return kOK;
47 } 44 }
48 45
49 } // namespace dart 46 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/native_entry_test.cc ('k') | runtime/vm/native_symbol.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698