Chromium Code Reviews| 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 #include "bin/eventhandler_win.h" | 9 #include "bin/eventhandler_win.h" |
| 10 | 10 |
| (...skipping 1000 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1011 | 1011 |
| 1012 if (IS_COMMAND(msg->data, kReturnTokenCommand)) { | 1012 if (IS_COMMAND(msg->data, kReturnTokenCommand)) { |
| 1013 listen_socket->ReturnTokens(msg->dart_port, TOKEN_COUNT(msg->data)); | 1013 listen_socket->ReturnTokens(msg->dart_port, TOKEN_COUNT(msg->data)); |
| 1014 } else if (IS_COMMAND(msg->data, kSetEventMaskCommand)) { | 1014 } else if (IS_COMMAND(msg->data, kSetEventMaskCommand)) { |
| 1015 // `events` can only have kInEvent/kOutEvent flags set. | 1015 // `events` can only have kInEvent/kOutEvent flags set. |
| 1016 intptr_t events = msg->data & EVENT_MASK; | 1016 intptr_t events = msg->data & EVENT_MASK; |
| 1017 ASSERT(0 == (events & ~(1 << kInEvent | 1 << kOutEvent))); | 1017 ASSERT(0 == (events & ~(1 << kInEvent | 1 << kOutEvent))); |
| 1018 listen_socket->SetPortAndMask(msg->dart_port, events); | 1018 listen_socket->SetPortAndMask(msg->dart_port, events); |
| 1019 TryDispatchingPendingAccepts(listen_socket); | 1019 TryDispatchingPendingAccepts(listen_socket); |
| 1020 } else if (IS_COMMAND(msg->data, kCloseCommand)) { | 1020 } else if (IS_COMMAND(msg->data, kCloseCommand)) { |
| 1021 listen_socket->SetPortAndMask(msg->dart_port, 0); | 1021 listen_socket->RemovePort(msg->dart_port); |
| 1022 | |
| 1022 // We only close the socket file descriptor from the operating | 1023 // We only close the socket file descriptor from the operating |
| 1023 // system if there are no other dart socket objects which | 1024 // system if there are no other dart socket objects which |
| 1024 // are listening on the same (address, port) combination. | 1025 // are listening on the same (address, port) combination. |
| 1025 ListeningSocketRegistry *registry = | 1026 ListeningSocketRegistry *registry = |
| 1026 ListeningSocketRegistry::Instance(); | 1027 ListeningSocketRegistry::Instance(); |
| 1027 MutexLocker locker(registry->mutex()); | 1028 MutexLocker locker(registry->mutex()); |
| 1028 if (registry->CloseSafe(reinterpret_cast<intptr_t>(listen_socket))) { | 1029 if (registry->CloseSafe(reinterpret_cast<intptr_t>(listen_socket))) { |
| 1029 ASSERT(listen_socket->Mask() == 0); | 1030 ASSERT(listen_socket->Mask() == 0); |
| 1030 listen_socket->Close(); | 1031 listen_socket->Close(); |
| 1031 DeleteIfClosed(handle); | 1032 DeleteIfClosed(handle); |
| 1032 } | 1033 } |
| 1034 | |
| 1035 DartUtils::PostInt32(msg->dart_port, 1 << kDestroyedEvent); | |
|
Søren Gjesse
2015/02/11 11:31:21
DeleteIfClosed above sends a destroy event when th
kustermann
2015/02/11 11:32:56
No it should not. Since we remove the port with `l
| |
| 1033 } else { | 1036 } else { |
| 1034 UNREACHABLE(); | 1037 UNREACHABLE(); |
| 1035 } | 1038 } |
| 1036 } else { | 1039 } else { |
| 1037 handle->EnsureInitialized(this); | 1040 handle->EnsureInitialized(this); |
| 1038 | 1041 |
| 1039 Handle::ScopedLock lock(handle); | 1042 Handle::ScopedLock lock(handle); |
| 1040 | 1043 |
| 1041 if (IS_COMMAND(msg->data, kReturnTokenCommand)) { | 1044 if (IS_COMMAND(msg->data, kReturnTokenCommand)) { |
| 1042 handle->ReturnTokens(msg->dart_port, TOKEN_COUNT(msg->data)); | 1045 handle->ReturnTokens(msg->dart_port, TOKEN_COUNT(msg->data)); |
| (...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1385 | 1388 |
| 1386 | 1389 |
| 1387 void EventHandlerImplementation::Shutdown() { | 1390 void EventHandlerImplementation::Shutdown() { |
| 1388 SendData(kShutdownId, 0, 0); | 1391 SendData(kShutdownId, 0, 0); |
| 1389 } | 1392 } |
| 1390 | 1393 |
| 1391 } // namespace bin | 1394 } // namespace bin |
| 1392 } // namespace dart | 1395 } // namespace dart |
| 1393 | 1396 |
| 1394 #endif // defined(TARGET_OS_WINDOWS) | 1397 #endif // defined(TARGET_OS_WINDOWS) |
| OLD | NEW |