| 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 <winsock2.h> // NOLINT | 10 #include <winsock2.h> // NOLINT |
| (...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 366 return IsClosing() && pending_read_ == NULL; | 366 return IsClosing() && pending_read_ == NULL; |
| 367 } | 367 } |
| 368 | 368 |
| 369 | 369 |
| 370 bool DirectoryWatchHandle::IssueRead() { | 370 bool DirectoryWatchHandle::IssueRead() { |
| 371 ScopedLock lock(this); | 371 ScopedLock lock(this); |
| 372 // It may have been started before, as we start the directory-handler when | 372 // It may have been started before, as we start the directory-handler when |
| 373 // we create it. | 373 // we create it. |
| 374 if (pending_read_ != NULL) return true; | 374 if (pending_read_ != NULL) return true; |
| 375 OverlappedBuffer* buffer = OverlappedBuffer::AllocateReadBuffer(kBufferSize); | 375 OverlappedBuffer* buffer = OverlappedBuffer::AllocateReadBuffer(kBufferSize); |
| 376 | |
| 377 ASSERT(completion_port_ != INVALID_HANDLE_VALUE); | 376 ASSERT(completion_port_ != INVALID_HANDLE_VALUE); |
| 378 | |
| 379 BOOL ok = ReadDirectoryChangesW(handle_, | 377 BOOL ok = ReadDirectoryChangesW(handle_, |
| 380 buffer->GetBufferStart(), | 378 buffer->GetBufferStart(), |
| 381 buffer->GetBufferSize(), | 379 buffer->GetBufferSize(), |
| 382 recursive_, | 380 recursive_, |
| 383 events_, | 381 events_, |
| 384 NULL, | 382 NULL, |
| 385 buffer->GetCleanOverlapped(), | 383 buffer->GetCleanOverlapped(), |
| 386 NULL); | 384 NULL); |
| 387 if (ok || GetLastError() == ERROR_IO_PENDING) { | 385 if (ok || GetLastError() == ERROR_IO_PENDING) { |
| 388 // Completing asynchronously. | 386 // Completing asynchronously. |
| (...skipping 807 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1196 int64_t EventHandlerImplementation::GetTimeout() { | 1194 int64_t EventHandlerImplementation::GetTimeout() { |
| 1197 if (!timeout_queue_.HasTimeout()) { | 1195 if (!timeout_queue_.HasTimeout()) { |
| 1198 return kInfinityTimeout; | 1196 return kInfinityTimeout; |
| 1199 } | 1197 } |
| 1200 int64_t millis = timeout_queue_.CurrentTimeout() - | 1198 int64_t millis = timeout_queue_.CurrentTimeout() - |
| 1201 TimerUtils::GetCurrentTimeMilliseconds(); | 1199 TimerUtils::GetCurrentTimeMilliseconds(); |
| 1202 return (millis < 0) ? 0 : millis; | 1200 return (millis < 0) ? 0 : millis; |
| 1203 } | 1201 } |
| 1204 | 1202 |
| 1205 | 1203 |
| 1206 void EventHandlerImplementation::Notify(intptr_t id, | 1204 void EventHandlerImplementation::SendData(intptr_t id, |
| 1207 Dart_Port dart_port, | 1205 Dart_Port dart_port, |
| 1208 int64_t data) { | 1206 int64_t data) { |
| 1209 InterruptMessage* msg = new InterruptMessage; | 1207 InterruptMessage* msg = new InterruptMessage; |
| 1210 msg->id = id; | 1208 msg->id = id; |
| 1211 msg->dart_port = dart_port; | 1209 msg->dart_port = dart_port; |
| 1212 msg->data = data; | 1210 msg->data = data; |
| 1213 BOOL ok = PostQueuedCompletionStatus( | 1211 BOOL ok = PostQueuedCompletionStatus( |
| 1214 completion_port_, 0, NULL, reinterpret_cast<OVERLAPPED*>(msg)); | 1212 completion_port_, 0, NULL, reinterpret_cast<OVERLAPPED*>(msg)); |
| 1215 if (!ok) { | 1213 if (!ok) { |
| 1216 FATAL("PostQueuedCompletionStatus failed"); | 1214 FATAL("PostQueuedCompletionStatus failed"); |
| 1217 } | 1215 } |
| 1218 } | 1216 } |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1282 } | 1280 } |
| 1283 | 1281 |
| 1284 // Initialize Winsock32 | 1282 // Initialize Winsock32 |
| 1285 if (!Socket::Initialize()) { | 1283 if (!Socket::Initialize()) { |
| 1286 FATAL("Failed to initialized Windows sockets"); | 1284 FATAL("Failed to initialized Windows sockets"); |
| 1287 } | 1285 } |
| 1288 } | 1286 } |
| 1289 | 1287 |
| 1290 | 1288 |
| 1291 void EventHandlerImplementation::Shutdown() { | 1289 void EventHandlerImplementation::Shutdown() { |
| 1292 Notify(kShutdownId, 0, 0); | 1290 SendData(kShutdownId, 0, 0); |
| 1293 } | 1291 } |
| 1294 | 1292 |
| 1295 } // namespace bin | 1293 } // namespace bin |
| 1296 } // namespace dart | 1294 } // namespace dart |
| 1297 | 1295 |
| 1298 #endif // defined(TARGET_OS_WINDOWS) | 1296 #endif // defined(TARGET_OS_WINDOWS) |
| OLD | NEW |