| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 614 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 625 } | 625 } |
| 626 | 626 |
| 627 | 627 |
| 628 void ClientSocket::DisconnectComplete(IOBuffer* buffer) { | 628 void ClientSocket::DisconnectComplete(IOBuffer* buffer) { |
| 629 IOBuffer::DisposeBuffer(buffer); | 629 IOBuffer::DisposeBuffer(buffer); |
| 630 closesocket(socket()); | 630 closesocket(socket()); |
| 631 if (data_ready_ != NULL) { | 631 if (data_ready_ != NULL) { |
| 632 IOBuffer::DisposeBuffer(data_ready_); | 632 IOBuffer::DisposeBuffer(data_ready_); |
| 633 } | 633 } |
| 634 // When disconnect is complete get rid of the object. | 634 // When disconnect is complete get rid of the object. |
| 635 Dart_Port port = port(); |
| 635 delete this; | 636 delete this; |
| 637 DartUtils::PostInt32(port, 1 << kDestroyedEvent); |
| 636 } | 638 } |
| 637 | 639 |
| 638 | 640 |
| 639 void ClientSocket::EnsureInitialized( | 641 void ClientSocket::EnsureInitialized( |
| 640 EventHandlerImplementation* event_handler) { | 642 EventHandlerImplementation* event_handler) { |
| 641 ScopedLock lock(this); | 643 ScopedLock lock(this); |
| 642 if (completion_port_ == INVALID_HANDLE_VALUE) { | 644 if (completion_port_ == INVALID_HANDLE_VALUE) { |
| 643 ASSERT(event_handler_ == NULL); | 645 ASSERT(event_handler_ == NULL); |
| 644 event_handler_ = event_handler; | 646 event_handler_ = event_handler; |
| 645 CreateCompletionPort(event_handler_->completion_port()); | 647 CreateCompletionPort(event_handler_->completion_port()); |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 743 } | 745 } |
| 744 | 746 |
| 745 if ((msg->data & (1 << kCloseCommand)) != 0) { | 747 if ((msg->data & (1 << kCloseCommand)) != 0) { |
| 746 handle->Close(); | 748 handle->Close(); |
| 747 if (handle->IsClosed()) { | 749 if (handle->IsClosed()) { |
| 748 delete_handle = true; | 750 delete_handle = true; |
| 749 } | 751 } |
| 750 } | 752 } |
| 751 } | 753 } |
| 752 if (delete_handle) { | 754 if (delete_handle) { |
| 755 Dart_Port port = handle->port(); |
| 753 delete handle; | 756 delete handle; |
| 757 DartUtils::PostInt32(port, 1 << kDestroyedEvent); |
| 754 } | 758 } |
| 755 } | 759 } |
| 756 } | 760 } |
| 757 | 761 |
| 758 | 762 |
| 759 void EventHandlerImplementation::HandleAccept(ListenSocket* listen_socket, | 763 void EventHandlerImplementation::HandleAccept(ListenSocket* listen_socket, |
| 760 IOBuffer* buffer) { | 764 IOBuffer* buffer) { |
| 761 listen_socket->AcceptComplete(buffer, completion_port_); | 765 listen_socket->AcceptComplete(buffer, completion_port_); |
| 762 | 766 |
| 763 if (!listen_socket->IsClosing()) { | 767 if (!listen_socket->IsClosing()) { |
| 764 int event_mask = 1 << kInEvent; | 768 int event_mask = 1 << kInEvent; |
| 765 if ((listen_socket->mask() & event_mask) != 0) { | 769 if ((listen_socket->mask() & event_mask) != 0) { |
| 766 DartUtils::PostInt32(listen_socket->port(), event_mask); | 770 DartUtils::PostInt32(listen_socket->port(), event_mask); |
| 767 } | 771 } |
| 768 } | 772 } |
| 769 | 773 |
| 770 if (listen_socket->IsClosed()) { | 774 if (listen_socket->IsClosed()) { |
| 775 Dart_Port port = listen_socket->port(); |
| 771 delete listen_socket; | 776 delete listen_socket; |
| 777 DartUtils::PostInt32(port, 1 << kDestroyedEvent); |
| 772 } | 778 } |
| 773 } | 779 } |
| 774 | 780 |
| 775 | 781 |
| 776 void EventHandlerImplementation::HandleClosed(Handle* handle) { | 782 void EventHandlerImplementation::HandleClosed(Handle* handle) { |
| 777 if (!handle->IsClosing()) { | 783 if (!handle->IsClosing()) { |
| 778 int event_mask = 1 << kCloseEvent; | 784 int event_mask = 1 << kCloseEvent; |
| 779 DartUtils::PostInt32(handle->port(), event_mask); | 785 DartUtils::PostInt32(handle->port(), event_mask); |
| 780 } | 786 } |
| 781 } | 787 } |
| (...skipping 24 matching lines...) Expand all Loading... |
| 806 } else { | 812 } else { |
| 807 handle->MarkClosedRead(); | 813 handle->MarkClosedRead(); |
| 808 if (bytes == 0) { | 814 if (bytes == 0) { |
| 809 HandleClosed(handle); | 815 HandleClosed(handle); |
| 810 } else { | 816 } else { |
| 811 HandleError(handle); | 817 HandleError(handle); |
| 812 } | 818 } |
| 813 } | 819 } |
| 814 | 820 |
| 815 if (handle->IsClosed()) { | 821 if (handle->IsClosed()) { |
| 822 Dart_Port port = handle->port(); |
| 816 delete handle; | 823 delete handle; |
| 824 DartUtils::PostInt32(port, 1 << kDestroyedEvent); |
| 817 } | 825 } |
| 818 } | 826 } |
| 819 | 827 |
| 820 | 828 |
| 821 void EventHandlerImplementation::HandleWrite(Handle* handle, | 829 void EventHandlerImplementation::HandleWrite(Handle* handle, |
| 822 int bytes, | 830 int bytes, |
| 823 IOBuffer* buffer) { | 831 IOBuffer* buffer) { |
| 824 handle->WriteComplete(buffer); | 832 handle->WriteComplete(buffer); |
| 825 | 833 |
| 826 if (bytes > 0) { | 834 if (bytes > 0) { |
| 827 if (!handle->IsError() && !handle->IsClosing()) { | 835 if (!handle->IsError() && !handle->IsClosing()) { |
| 828 int event_mask = 1 << kOutEvent; | 836 int event_mask = 1 << kOutEvent; |
| 829 if ((handle->mask() & event_mask) != 0) { | 837 if ((handle->mask() & event_mask) != 0) { |
| 830 DartUtils::PostInt32(handle->port(), event_mask); | 838 DartUtils::PostInt32(handle->port(), event_mask); |
| 831 } | 839 } |
| 832 } | 840 } |
| 833 } else if (bytes == 0) { | 841 } else if (bytes == 0) { |
| 834 HandleClosed(handle); | 842 HandleClosed(handle); |
| 835 } else { | 843 } else { |
| 836 HandleError(handle); | 844 HandleError(handle); |
| 837 } | 845 } |
| 838 | 846 |
| 839 if (handle->IsClosed()) { | 847 if (handle->IsClosed()) { |
| 848 Dart_Port port = handle->port(); |
| 840 delete handle; | 849 delete handle; |
| 850 DartUtils::PostInt32(port, 1 << kDestroyedEvent); |
| 841 } | 851 } |
| 842 } | 852 } |
| 843 | 853 |
| 844 | 854 |
| 845 void EventHandlerImplementation::HandleDisconnect( | 855 void EventHandlerImplementation::HandleDisconnect( |
| 846 ClientSocket* client_socket, | 856 ClientSocket* client_socket, |
| 847 int bytes, | 857 int bytes, |
| 848 IOBuffer* buffer) { | 858 IOBuffer* buffer) { |
| 849 client_socket->DisconnectComplete(buffer); | 859 client_socket->DisconnectComplete(buffer); |
| 850 } | 860 } |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 998 | 1008 |
| 999 | 1009 |
| 1000 void EventHandlerImplementation::Shutdown() { | 1010 void EventHandlerImplementation::Shutdown() { |
| 1001 SendData(kShutdownId, 0, 0); | 1011 SendData(kShutdownId, 0, 0); |
| 1002 } | 1012 } |
| 1003 | 1013 |
| 1004 } // namespace bin | 1014 } // namespace bin |
| 1005 } // namespace dart | 1015 } // namespace dart |
| 1006 | 1016 |
| 1007 #endif // defined(TARGET_OS_WINDOWS) | 1017 #endif // defined(TARGET_OS_WINDOWS) |
| OLD | NEW |