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

Unified Diff: runtime/bin/eventhandler.cc

Issue 2760293002: [dart:io] Adds a finalizer to _NativeSocket to avoid socket leaks (Closed)
Patch Set: Address comments Created 3 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/bin/eventhandler.h ('k') | runtime/bin/eventhandler_android.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/eventhandler.cc
diff --git a/runtime/bin/eventhandler.cc b/runtime/bin/eventhandler.cc
index 60c13a512e6c18d63c94c4289ea9cc15c2be749e..d73ed879693c1df21726584b91505df2e0ebe4ba 100644
--- a/runtime/bin/eventhandler.cc
+++ b/runtime/bin/eventhandler.cc
@@ -112,18 +112,16 @@ EventHandlerImplementation* EventHandler::delegate() {
}
+void EventHandler::SendFromNative(intptr_t id, Dart_Port port, int64_t data) {
+ event_handler->SendData(id, port, data);
+}
+
+
/*
* Send data to the EventHandler thread to register for a given instance
* args[0] a ReceivePort args[1] with a notification event args[2].
*/
void FUNCTION_NAME(EventHandler_SendData)(Dart_NativeArguments args) {
- Dart_Handle sender = Dart_GetNativeArgument(args, 0);
- intptr_t id;
- if (Dart_IsNull(sender)) {
- id = kTimerId;
- } else {
- id = Socket::GetSocketIdNativeField(sender);
- }
// Get the id out of the send port. If the handle is not a send port
// we will get an error and propagate that out.
Dart_Handle handle = Dart_GetNativeArgument(args, 1);
@@ -133,6 +131,17 @@ void FUNCTION_NAME(EventHandler_SendData)(Dart_NativeArguments args) {
Dart_PropagateError(handle);
UNREACHABLE();
}
+ Dart_Handle sender = Dart_GetNativeArgument(args, 0);
+ intptr_t id;
+ if (Dart_IsNull(sender)) {
+ id = kTimerId;
+ } else {
+ Socket* socket = Socket::GetSocketIdNativeField(sender);
+ ASSERT(dart_port != ILLEGAL_PORT);
+ socket->set_port(dart_port);
+ socket->Retain(); // inc refcount before sending to the eventhandler.
+ id = reinterpret_cast<intptr_t>(socket);
+ }
int64_t data = DartUtils::GetIntegerValue(Dart_GetNativeArgument(args, 2));
event_handler->SendData(id, dart_port, data);
}
« no previous file with comments | « runtime/bin/eventhandler.h ('k') | runtime/bin/eventhandler_android.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698