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

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

Issue 2666063002: VM: [Kernel] Revert changes to the native ports that introduced peers. (Closed)
Patch Set: 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/kernel_isolate.cc ('k') | runtime/vm/native_message_handler.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) 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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 } 75 }
76 Dart_CObject cobj; 76 Dart_CObject cobj;
77 cobj.type = Dart_CObject_kInt64; 77 cobj.type = Dart_CObject_kInt64;
78 cobj.value.as_int64 = message; 78 cobj.value.as_int64 = message;
79 return PostCObjectHelper(port_id, &cobj); 79 return PostCObjectHelper(port_id, &cobj);
80 } 80 }
81 81
82 82
83 DART_EXPORT Dart_Port Dart_NewNativePort(const char* name, 83 DART_EXPORT Dart_Port Dart_NewNativePort(const char* name,
84 Dart_NativeMessageHandler handler, 84 Dart_NativeMessageHandler handler,
85 bool handle_concurrently, 85 bool handle_concurrently) {
86 void* peer) {
87 if (name == NULL) { 86 if (name == NULL) {
88 name = "<UnnamedNativePort>"; 87 name = "<UnnamedNativePort>";
89 } 88 }
90 if (handler == NULL) { 89 if (handler == NULL) {
91 OS::PrintErr("%s expects argument 'handler' to be non-null.\n", 90 OS::PrintErr("%s expects argument 'handler' to be non-null.\n",
92 CURRENT_FUNC); 91 CURRENT_FUNC);
93 return ILLEGAL_PORT; 92 return ILLEGAL_PORT;
94 } 93 }
95 // Start the native port without a current isolate. 94 // Start the native port without a current isolate.
96 IsolateSaver saver(Isolate::Current()); 95 IsolateSaver saver(Isolate::Current());
97 96
98 NativeMessageHandler* nmh = new NativeMessageHandler(name, handler, peer); 97 NativeMessageHandler* nmh = new NativeMessageHandler(name, handler);
99 Dart_Port port_id = PortMap::CreatePort(nmh); 98 Dart_Port port_id = PortMap::CreatePort(nmh);
100 PortMap::SetPortState(port_id, PortMap::kLivePort); 99 PortMap::SetPortState(port_id, PortMap::kLivePort);
101 nmh->Run(Dart::thread_pool(), NULL, NULL, 0); 100 nmh->Run(Dart::thread_pool(), NULL, NULL, 0);
102 return port_id; 101 return port_id;
103 } 102 }
104 103
105 104
106 DART_EXPORT bool Dart_CloseNativePort(Dart_Port native_port_id) { 105 DART_EXPORT bool Dart_CloseNativePort(Dart_Port native_port_id) {
107 // Close the native port without a current isolate. 106 // Close the native port without a current isolate.
108 IsolateSaver saver(Isolate::Current()); 107 IsolateSaver saver(Isolate::Current());
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 Dart_Handle result = Api::CheckAndFinalizePendingClasses(T); 152 Dart_Handle result = Api::CheckAndFinalizePendingClasses(T);
154 if (::Dart_IsError(result)) { 153 if (::Dart_IsError(result)) {
155 return result; 154 return result;
156 } 155 }
157 CHECK_CALLBACK_STATE(T); 156 CHECK_CALLBACK_STATE(T);
158 ParseAll(T, &result); 157 ParseAll(T, &result);
159 return result; 158 return result;
160 } 159 }
161 160
162 } // namespace dart 161 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/kernel_isolate.cc ('k') | runtime/vm/native_message_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698