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

Side by Side Diff: runtime/bin/eventhandler_win.cc

Issue 313083004: Don't use same value for socket() and handle(), as they are different concepts. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « runtime/bin/eventhandler_win.h ('k') | no next file » | 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 "platform/globals.h" 5 #include "platform/globals.h"
6 #if defined(TARGET_OS_WINDOWS) 6 #if defined(TARGET_OS_WINDOWS)
7 7
8 #include "bin/eventhandler.h" 8 #include "bin/eventhandler.h"
9 9
10 #include <winsock2.h> // NOLINT 10 #include <winsock2.h> // NOLINT
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 void Handle::Lock() { 152 void Handle::Lock() {
153 EnterCriticalSection(&cs_); 153 EnterCriticalSection(&cs_);
154 } 154 }
155 155
156 156
157 void Handle::Unlock() { 157 void Handle::Unlock() {
158 LeaveCriticalSection(&cs_); 158 LeaveCriticalSection(&cs_);
159 } 159 }
160 160
161 161
162 bool Handle::CreateCompletionPort(HANDLE completion_port) { 162 bool Handle::DoCreateCompletionPort(HANDLE handle, HANDLE completion_port) {
163 completion_port_ = CreateIoCompletionPort(handle_, 163 completion_port_ = CreateIoCompletionPort(handle,
164 completion_port, 164 completion_port,
165 reinterpret_cast<ULONG_PTR>(this), 165 reinterpret_cast<ULONG_PTR>(this),
166 0); 166 0);
167 if (completion_port_ == NULL) { 167 if (completion_port_ == NULL) {
168 return false; 168 return false;
169 } 169 }
170 return true; 170 return true;
171 } 171 }
172 172
173 173
174 bool Handle::CreateCompletionPort(HANDLE completion_port) {
175 return DoCreateCompletionPort(handle_, completion_port_);
176 }
177
178
174 void Handle::Close() { 179 void Handle::Close() {
175 ScopedLock lock(this); 180 ScopedLock lock(this);
176 if (!IsClosing()) { 181 if (!IsClosing()) {
177 // Close the socket and set the closing state. This close method can be 182 // Close the socket and set the closing state. This close method can be
178 // called again if this socket has pending IO operations in flight. 183 // called again if this socket has pending IO operations in flight.
179 MarkClosing(); 184 MarkClosing();
180 // Perform handle type specific closing. 185 // Perform handle type specific closing.
181 DoClose(); 186 DoClose();
182 } 187 }
183 ASSERT(IsHandleClosed()); 188 ASSERT(IsHandleClosed());
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
425 430
426 if (pending_read_ != NULL) { 431 if (pending_read_ != NULL) {
427 CancelIoEx(handle(), pending_read_->GetCleanOverlapped()); 432 CancelIoEx(handle(), pending_read_->GetCleanOverlapped());
428 // Don't dispose of the buffer, as it will still complete (with length 0). 433 // Don't dispose of the buffer, as it will still complete (with length 0).
429 } 434 }
430 435
431 DoClose(); 436 DoClose();
432 } 437 }
433 438
434 439
440 bool SocketHandle::CreateCompletionPort(HANDLE completion_port) {
441 HANDLE handle = reinterpret_cast<HANDLE>(socket());
442 return DoCreateCompletionPort(handle, completion_port);
443 }
444
445
435 void SocketHandle::HandleIssueError() { 446 void SocketHandle::HandleIssueError() {
436 int error = WSAGetLastError(); 447 int error = WSAGetLastError();
437 if (error == WSAECONNRESET) { 448 if (error == WSAECONNRESET) {
438 HandleClosed(this); 449 HandleClosed(this);
439 } else { 450 } else {
440 HandleError(this); 451 HandleError(this);
441 } 452 }
442 WSASetLastError(error); 453 WSASetLastError(error);
443 } 454 }
444 455
(...skipping 918 matching lines...) Expand 10 before | Expand all | Expand 10 after
1363 1374
1364 1375
1365 void EventHandlerImplementation::Shutdown() { 1376 void EventHandlerImplementation::Shutdown() {
1366 SendData(kShutdownId, 0, 0); 1377 SendData(kShutdownId, 0, 0);
1367 } 1378 }
1368 1379
1369 } // namespace bin 1380 } // namespace bin
1370 } // namespace dart 1381 } // namespace dart
1371 1382
1372 #endif // defined(TARGET_OS_WINDOWS) 1383 #endif // defined(TARGET_OS_WINDOWS)
OLDNEW
« no previous file with comments | « runtime/bin/eventhandler_win.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698