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

Unified Diff: runtime/bin/socket.cc

Issue 169383003: Make event-handlers edge-triggered and move socket-state to Dart. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Mac os X support. Created 6 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 side-by-side diff with in-line comments
Download patch
Index: runtime/bin/socket.cc
diff --git a/runtime/bin/socket.cc b/runtime/bin/socket.cc
index 351bfc66334c3f73d9b93394f2afae6ab4246f74..d87e0178c75f6af5b97405af0929e7165ee502dd 100644
--- a/runtime/bin/socket.cc
+++ b/runtime/bin/socket.cc
@@ -224,7 +224,9 @@ void FUNCTION_NAME(Socket_WriteList)(Dart_NativeArguments args) {
DartUtils::GetIntptrValue(Dart_GetNativeArgument(args, 2));
intptr_t length =
DartUtils::GetIntptrValue(Dart_GetNativeArgument(args, 3));
+ bool short_write = false;
if (short_socket_writes) {
+ if (length > 1) short_write = true;
length = (length + 1) / 2;
}
Dart_TypedData_Type type;
@@ -238,7 +240,11 @@ void FUNCTION_NAME(Socket_WriteList)(Dart_NativeArguments args) {
intptr_t bytes_written = Socket::Write(socket, buffer, length);
if (bytes_written >= 0) {
Dart_TypedDataReleaseData(buffer_obj);
- Dart_SetReturnValue(args, Dart_NewInteger(bytes_written));
+ if (short_write) {
Søren Gjesse 2014/02/18 14:28:00 Can we post a write event instead of this "trick"?
Anders Johnsen 2014/02/19 09:43:03 It's extremely custom how we post such an event. I
+ Dart_SetReturnValue(args, Dart_NewInteger(-bytes_written));
+ } else {
+ Dart_SetReturnValue(args, Dart_NewInteger(bytes_written));
+ }
} else {
// Extract OSError before we release data, as it may override the error.
OSError os_error;

Powered by Google App Engine
This is Rietveld 408576698