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

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

Issue 1072783003: Remove server socket references (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Rebased Created 5 years, 2 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/socket.h ('k') | runtime/bin/socket_patch.dart » ('j') | 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 "bin/io_buffer.h" 5 #include "bin/io_buffer.h"
6 #include "bin/isolate_data.h" 6 #include "bin/isolate_data.h"
7 #include "bin/dartutils.h" 7 #include "bin/dartutils.h"
8 #include "bin/socket.h" 8 #include "bin/socket.h"
9 #include "bin/thread.h" 9 #include "bin/thread.h"
10 #include "bin/lockers.h" 10 #include "bin/lockers.h"
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 return false; 163 return false;
164 } else { 164 } else {
165 // It should be impossible for the event handler to close something that 165 // It should be impossible for the event handler to close something that
166 // hasn't been created before. 166 // hasn't been created before.
167 UNREACHABLE(); 167 UNREACHABLE();
168 return false; 168 return false;
169 } 169 }
170 } 170 }
171 171
172 172
173 Dart_Handle ListeningSocketRegistry::MarkSocketFdAsSharableHack(
174 intptr_t socketfd) {
175 MutexLocker ml(ListeningSocketRegistry::mutex_);
176
177 SocketsIterator it = sockets_by_fd_.find(socketfd);
178 if (it != sockets_by_fd_.end()) {
179 it->second->shared = true;
180 return Dart_True();
181 } else {
182 return Dart_False();
183 }
184 }
185
186
187 void FUNCTION_NAME(InternetAddress_Parse)(Dart_NativeArguments args) { 173 void FUNCTION_NAME(InternetAddress_Parse)(Dart_NativeArguments args) {
188 const char* address = 174 const char* address =
189 DartUtils::GetStringValue(Dart_GetNativeArgument(args, 0)); 175 DartUtils::GetStringValue(Dart_GetNativeArgument(args, 0));
190 ASSERT(address != NULL); 176 ASSERT(address != NULL);
191 RawAddr raw; 177 RawAddr raw;
192 memset(&raw, 0, sizeof(raw)); 178 memset(&raw, 0, sizeof(raw));
193 int type = strchr(address, ':') == NULL ? SocketAddress::TYPE_IPV4 179 int type = strchr(address, ':') == NULL ? SocketAddress::TYPE_IPV4
194 : SocketAddress::TYPE_IPV6; 180 : SocketAddress::TYPE_IPV6;
195 if (type == SocketAddress::TYPE_IPV4) { 181 if (type == SocketAddress::TYPE_IPV4) {
196 raw.addr.sa_family = AF_INET; 182 raw.addr.sa_family = AF_INET;
(...skipping 651 matching lines...) Expand 10 before | Expand all | Expand 10 after
848 int interfaceIndex = 834 int interfaceIndex =
849 DartUtils::GetIntegerValue(Dart_GetNativeArgument(args, 3)); 835 DartUtils::GetIntegerValue(Dart_GetNativeArgument(args, 3));
850 if (Socket::LeaveMulticast(socket, addr, interface, interfaceIndex)) { 836 if (Socket::LeaveMulticast(socket, addr, interface, interfaceIndex)) {
851 Dart_SetReturnValue(args, Dart_Null()); 837 Dart_SetReturnValue(args, Dart_Null());
852 } else { 838 } else {
853 Dart_SetReturnValue(args, DartUtils::NewDartOSError()); 839 Dart_SetReturnValue(args, DartUtils::NewDartOSError());
854 } 840 }
855 } 841 }
856 842
857 843
858 void FUNCTION_NAME(Socket_MarkSocketAsSharedHack)(Dart_NativeArguments args) {
859 intptr_t socketfd =
860 Socket::GetSocketIdNativeField(Dart_GetNativeArgument(args, 0));
861
862 ListeningSocketRegistry *registry = ListeningSocketRegistry::Instance();
863 Dart_SetReturnValue(args, registry->MarkSocketFdAsSharableHack(socketfd));
864 }
865
866
867 void Socket::SetSocketIdNativeField(Dart_Handle socket, intptr_t id) { 844 void Socket::SetSocketIdNativeField(Dart_Handle socket, intptr_t id) {
868 Dart_Handle err = 845 Dart_Handle err =
869 Dart_SetNativeInstanceField(socket, kSocketIdNativeField, id); 846 Dart_SetNativeInstanceField(socket, kSocketIdNativeField, id);
870 if (Dart_IsError(err)) Dart_PropagateError(err); 847 if (Dart_IsError(err)) Dart_PropagateError(err);
871 } 848 }
872 849
873 850
874 intptr_t Socket::GetSocketIdNativeField(Dart_Handle socket_obj) { 851 intptr_t Socket::GetSocketIdNativeField(Dart_Handle socket_obj) {
875 intptr_t socket = 0; 852 intptr_t socket = 0;
876 Dart_Handle err = 853 Dart_Handle err =
877 Dart_GetNativeInstanceField(socket_obj, kSocketIdNativeField, &socket); 854 Dart_GetNativeInstanceField(socket_obj, kSocketIdNativeField, &socket);
878 if (Dart_IsError(err)) Dart_PropagateError(err); 855 if (Dart_IsError(err)) Dart_PropagateError(err);
879 return socket; 856 return socket;
880 } 857 }
881 858
882 } // namespace bin 859 } // namespace bin
883 } // namespace dart 860 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/bin/socket.h ('k') | runtime/bin/socket_patch.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698