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

Side by Side Diff: runtime/vm/native_api_impl.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 | « no previous file | runtime/vm/native_message_handler.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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 "include/dart_native_api.h" 5 #include "include/dart_native_api.h"
6 6
7 #include "platform/assert.h" 7 #include "platform/assert.h"
8 #include "vm/dart_api_impl.h" 8 #include "vm/dart_api_impl.h"
9 #include "vm/dart_api_message.h" 9 #include "vm/dart_api_message.h"
10 #include "vm/dart_api_state.h" 10 #include "vm/dart_api_state.h"
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 if (handler == NULL) { 83 if (handler == NULL) {
84 OS::PrintErr("%s expects argument 'handler' to be non-null.\n", 84 OS::PrintErr("%s expects argument 'handler' to be non-null.\n",
85 CURRENT_FUNC); 85 CURRENT_FUNC);
86 return ILLEGAL_PORT; 86 return ILLEGAL_PORT;
87 } 87 }
88 // Start the native port without a current isolate. 88 // Start the native port without a current isolate.
89 IsolateSaver saver(Isolate::Current()); 89 IsolateSaver saver(Isolate::Current());
90 90
91 NativeMessageHandler* nmh = new NativeMessageHandler(name, handler); 91 NativeMessageHandler* nmh = new NativeMessageHandler(name, handler);
92 Dart_Port port_id = PortMap::CreatePort(nmh); 92 Dart_Port port_id = PortMap::CreatePort(nmh);
93 // Mark that the port is a live port so that PortMap::ClosePort decrements
94 // the live port count when it is closed.
95 PortMap::SetPortState(port_id, PortMap::kLivePort);
96 nmh->Run(Dart::thread_pool(), NULL, NULL, 0); 93 nmh->Run(Dart::thread_pool(), NULL, NULL, 0);
97 return port_id; 94 return port_id;
98 } 95 }
99 96
100 97
101 DART_EXPORT bool Dart_CloseNativePort(Dart_Port native_port_id) { 98 DART_EXPORT bool Dart_CloseNativePort(Dart_Port native_port_id) {
102 // Close the native port without a current isolate. 99 // Close the native port without a current isolate.
103 IsolateSaver saver(Isolate::Current()); 100 IsolateSaver saver(Isolate::Current());
104 101
105 // TODO(turnidge): Check that the port is native before trying to close. 102 // TODO(turnidge): Check that the port is native before trying to close.
(...skipping 19 matching lines...) Expand all
125 Dart_Handle result = Api::CheckAndFinalizePendingClasses(T); 122 Dart_Handle result = Api::CheckAndFinalizePendingClasses(T);
126 if (::Dart_IsError(result)) { 123 if (::Dart_IsError(result)) {
127 return result; 124 return result;
128 } 125 }
129 CHECK_CALLBACK_STATE(T); 126 CHECK_CALLBACK_STATE(T);
130 CompileAll(T, &result); 127 CompileAll(T, &result);
131 return result; 128 return result;
132 } 129 }
133 130
134 } // namespace dart 131 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/native_message_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698