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

Unified Diff: dart/runtime/bin/eventhandler_win.cc

Issue 900363004: Introduce a kSetEventMaskCommand, some cleanups in windows eventhandler (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed comments Created 5 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
« no previous file with comments | « dart/runtime/bin/eventhandler_macos.cc ('k') | dart/runtime/bin/socket_patch.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dart/runtime/bin/eventhandler_win.cc
diff --git a/dart/runtime/bin/eventhandler_win.cc b/dart/runtime/bin/eventhandler_win.cc
index a4528b3b4112b58c1538381db770b8448d9c0f74..61b6f44578d74ac274c63aee63e380759c9a2bcb 100644
--- a/dart/runtime/bin/eventhandler_win.cc
+++ b/dart/runtime/bin/eventhandler_win.cc
@@ -1014,82 +1014,102 @@ void EventHandlerImplementation::HandleInterrupt(InterruptMessage* msg) {
} else if (msg->id == kShutdownId) {
shutdown_ = true;
} else {
- // No tokens to return on Windows.
- if ((msg->data & (1 << kReturnTokenCommand)) != 0) return;
Handle* handle = reinterpret_cast<Handle*>(msg->id);
ASSERT(handle != NULL);
if (handle->is_listen_socket()) {
ListenSocket* listen_socket =
reinterpret_cast<ListenSocket*>(handle);
listen_socket->EnsureInitialized(this);
- listen_socket->SetPortAndMask(msg->dart_port, msg->data);
Handle::ScopedLock lock(listen_socket);
- // If incoming connections are requested make sure to post already
- // accepted connections.
- if ((msg->data & (1 << kInEvent)) != 0) {
- if (listen_socket->CanAccept()) {
- int event_mask = (1 << kInEvent);
- handle->set_mask(handle->mask() & ~event_mask);
- DartUtils::PostInt32(handle->port(), event_mask);
+ if (IS_COMMAND(msg->data, kReturnTokenCommand)) {
+ // No tokens to return on Windows.
+ } else if (IS_COMMAND(msg->data, kSetEventMaskCommand)) {
+ // `events` can only have kInEvent/kOutEvent flags set.
+ intptr_t events = msg->data & EVENT_MASK;
+ ASSERT(0 == (events & ~(1 << kInEvent | 1 << kOutEvent)));
+
+ listen_socket->SetPortAndMask(msg->dart_port, msg->data);
+
+ // If incoming connections are requested make sure to post already
+ // accepted connections.
+ if ((events & (1 << kInEvent)) != 0) {
+ if (listen_socket->CanAccept()) {
+ int event_mask = (1 << kInEvent);
+ handle->set_mask(handle->mask() & ~event_mask);
+ DartUtils::PostInt32(handle->port(), event_mask);
+ }
}
+ } else if (IS_COMMAND(msg->data, kCloseCommand)) {
+ handle->SetPortAndMask(msg->dart_port, msg->data);
+ handle->Close();
+ } else {
+ UNREACHABLE();
}
} else {
handle->EnsureInitialized(this);
Handle::ScopedLock lock(handle);
- // Only set mask if we turned on kInEvent or kOutEvent.
- if ((msg->data & ((1 << kInEvent) | (1 << kOutEvent))) != 0) {
+ if (IS_COMMAND(msg->data, kReturnTokenCommand)) {
+ // No tokens to return on Windows.
+ } else if (IS_COMMAND(msg->data, kSetEventMaskCommand)) {
+ // `events` can only have kInEvent/kOutEvent flags set.
+ intptr_t events = msg->data & EVENT_MASK;
+ ASSERT(0 == (events & ~(1 << kInEvent | 1 << kOutEvent)));
+
handle->SetPortAndMask(msg->dart_port, msg->data);
- }
- // Issue a read.
- if ((msg->data & (1 << kInEvent)) != 0) {
- if (handle->is_datagram_socket()) {
- handle->IssueRecvFrom();
- } else if (handle->is_client_socket()) {
- if (reinterpret_cast<ClientSocket*>(handle)->is_connected()) {
+ // Issue a read.
+ if ((msg->data & (1 << kInEvent)) != 0) {
+ if (handle->is_datagram_socket()) {
+ handle->IssueRecvFrom();
+ } else if (handle->is_client_socket()) {
+ if (reinterpret_cast<ClientSocket*>(handle)->is_connected()) {
+ handle->IssueRead();
+ }
+ } else {
handle->IssueRead();
}
- } else {
- handle->IssueRead();
}
- }
- // If out events (can write events) have been requested, and there
- // are no pending writes, meaning any writes are already complete,
- // post an out event immediately.
- if ((msg->data & (1 << kOutEvent)) != 0) {
- if (!handle->HasPendingWrite()) {
- if (handle->is_client_socket()) {
- if (reinterpret_cast<ClientSocket*>(handle)->is_connected()) {
+ // If out events (can write events) have been requested, and there
+ // are no pending writes, meaning any writes are already complete,
+ // post an out event immediately.
+ if ((msg->data & (1 << kOutEvent)) != 0) {
+ if (!handle->HasPendingWrite()) {
+ if (handle->is_client_socket()) {
+ if (reinterpret_cast<ClientSocket*>(handle)->is_connected()) {
+ DartUtils::PostInt32(handle->port(), 1 << kOutEvent);
+ }
+ } else {
DartUtils::PostInt32(handle->port(), 1 << kOutEvent);
}
- } else {
- DartUtils::PostInt32(handle->port(), 1 << kOutEvent);
}
}
- }
+ } else if (IS_COMMAND(msg->data, kShutdownReadCommand)) {
+ ASSERT(handle->is_client_socket());
- if (handle->is_client_socket()) {
ClientSocket* client_socket = reinterpret_cast<ClientSocket*>(handle);
if ((msg->data & (1 << kShutdownReadCommand)) != 0) {
client_socket->Shutdown(SD_RECEIVE);
}
+ } else if (IS_COMMAND(msg->data, kShutdownWriteCommand)) {
+ ASSERT(handle->is_client_socket());
+ ClientSocket* client_socket = reinterpret_cast<ClientSocket*>(handle);
if ((msg->data & (1 << kShutdownWriteCommand)) != 0) {
client_socket->Shutdown(SD_SEND);
}
+ } else if (IS_COMMAND(msg->data, kCloseCommand)) {
+ handle->SetPortAndMask(msg->dart_port, msg->data);
+ handle->Close();
+ } else {
+ UNREACHABLE();
}
}
- if ((msg->data & (1 << kCloseCommand)) != 0) {
- handle->SetPortAndMask(msg->dart_port, msg->data);
- handle->Close();
- }
-
DeleteIfClosed(handle);
}
}
« no previous file with comments | « dart/runtime/bin/eventhandler_macos.cc ('k') | dart/runtime/bin/socket_patch.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698