OLD | NEW |
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 <process.h> // NOLINT | 10 #include <process.h> // NOLINT |
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
336 int fd = _open("NUL", _O_WRONLY); | 336 int fd = _open("NUL", _O_WRONLY); |
337 ASSERT(fd >= 0); | 337 ASSERT(fd >= 0); |
338 _dup2(fd, _fileno(stdout)); | 338 _dup2(fd, _fileno(stdout)); |
339 close(fd); | 339 close(fd); |
340 } else { | 340 } else { |
341 Handle::DoClose(); | 341 Handle::DoClose(); |
342 } | 342 } |
343 } | 343 } |
344 | 344 |
345 | 345 |
| 346 void DirectoryWatchHandle::EnsureInitialized( |
| 347 EventHandlerImplementation* event_handler) { |
| 348 ScopedLock lock(this); |
| 349 event_handler_ = event_handler; |
| 350 if (completion_port_ == INVALID_HANDLE_VALUE) { |
| 351 CreateCompletionPort(event_handler_->completion_port()); |
| 352 } |
| 353 } |
| 354 |
| 355 |
| 356 bool DirectoryWatchHandle::IsClosed() { |
| 357 return IsClosing() && pending_read_ == NULL; |
| 358 } |
| 359 |
| 360 |
| 361 void DirectoryWatchHandle::DoClose() { |
| 362 Handle::DoClose(); |
| 363 } |
| 364 |
| 365 bool DirectoryWatchHandle::IssueRead() { |
| 366 ScopedLock lock(this); |
| 367 OverlappedBuffer* buffer = OverlappedBuffer::AllocateReadBuffer(kBufferSize); |
| 368 |
| 369 ASSERT(completion_port_ != INVALID_HANDLE_VALUE); |
| 370 |
| 371 BOOL ok = ReadDirectoryChangesW(handle_, |
| 372 buffer->GetBufferStart(), |
| 373 buffer->GetBufferSize(), |
| 374 recursive_, |
| 375 events_, |
| 376 NULL, |
| 377 buffer->GetCleanOverlapped(), |
| 378 NULL); |
| 379 if (ok || GetLastError() == ERROR_IO_PENDING) { |
| 380 // Completing asynchronously. |
| 381 pending_read_ = buffer; |
| 382 return true; |
| 383 } |
| 384 OverlappedBuffer::DisposeBuffer(buffer); |
| 385 return false; |
| 386 } |
| 387 |
| 388 |
346 void SocketHandle::HandleIssueError() { | 389 void SocketHandle::HandleIssueError() { |
347 int error = WSAGetLastError(); | 390 int error = WSAGetLastError(); |
348 if (error == WSAECONNRESET) { | 391 if (error == WSAECONNRESET) { |
349 event_handler_->HandleClosed(this); | 392 event_handler_->HandleClosed(this); |
350 } else { | 393 } else { |
351 event_handler_->HandleError(this); | 394 event_handler_->HandleError(this); |
352 } | 395 } |
353 WSASetLastError(error); | 396 WSASetLastError(error); |
354 } | 397 } |
355 | 398 |
(...skipping 660 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1016 | 1059 |
1017 | 1060 |
1018 void EventHandlerImplementation::Shutdown() { | 1061 void EventHandlerImplementation::Shutdown() { |
1019 SendData(kShutdownId, 0, 0); | 1062 SendData(kShutdownId, 0, 0); |
1020 } | 1063 } |
1021 | 1064 |
1022 } // namespace bin | 1065 } // namespace bin |
1023 } // namespace dart | 1066 } // namespace dart |
1024 | 1067 |
1025 #endif // defined(TARGET_OS_WINDOWS) | 1068 #endif // defined(TARGET_OS_WINDOWS) |
OLD | NEW |