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

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

Issue 2207663002: Revert "Fix NativeMessageHandler leak" (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 4 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_api_impl.cc ('k') | no next file » | 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)), 16 : name_(strdup(name)),
17 func_(func) { 17 func_(func) {
18 // A NativeMessageHandler always has one live port.
19 increment_live_ports();
18 } 20 }
19 21
20 22
21 NativeMessageHandler::~NativeMessageHandler() { 23 NativeMessageHandler::~NativeMessageHandler() {
22 free(name_); 24 free(name_);
23 } 25 }
24 26
25 27
26 #if defined(DEBUG) 28 #if defined(DEBUG)
27 void NativeMessageHandler::CheckAccess() { 29 void NativeMessageHandler::CheckAccess() {
(...skipping 14 matching lines...) Expand all
42 ApiNativeScope scope; 44 ApiNativeScope scope;
43 Dart_CObject* object; 45 Dart_CObject* object;
44 ApiMessageReader reader(message); 46 ApiMessageReader reader(message);
45 object = reader.ReadMessage(); 47 object = reader.ReadMessage();
46 (*func())(message->dest_port(), object); 48 (*func())(message->dest_port(), object);
47 delete message; 49 delete message;
48 return kOK; 50 return kOK;
49 } 51 }
50 52
51 } // namespace dart 53 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/native_api_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698