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 "bin/socket.h" | 5 #include "bin/socket.h" |
6 #include "bin/dartutils.h" | 6 #include "bin/dartutils.h" |
7 #include "bin/thread.h" | 7 #include "bin/thread.h" |
8 #include "bin/utils.h" | 8 #include "bin/utils.h" |
9 | 9 |
10 #include "platform/globals.h" | 10 #include "platform/globals.h" |
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
313 | 313 |
314 | 314 |
315 Dart_Port Socket::GetServicePort() { | 315 Dart_Port Socket::GetServicePort() { |
316 MutexLocker lock(&mutex_); | 316 MutexLocker lock(&mutex_); |
317 if (service_ports_size_ == 0) { | 317 if (service_ports_size_ == 0) { |
318 ASSERT(service_ports_ == NULL); | 318 ASSERT(service_ports_ == NULL); |
319 service_ports_size_ = 16; | 319 service_ports_size_ = 16; |
320 service_ports_ = new Dart_Port[service_ports_size_]; | 320 service_ports_ = new Dart_Port[service_ports_size_]; |
321 service_ports_index_ = 0; | 321 service_ports_index_ = 0; |
322 for (int i = 0; i < service_ports_size_; i++) { | 322 for (int i = 0; i < service_ports_size_; i++) { |
323 service_ports_[i] = kIllegalPort; | 323 service_ports_[i] = ILLEGAL_PORT; |
324 } | 324 } |
325 } | 325 } |
326 | 326 |
327 Dart_Port result = service_ports_[service_ports_index_]; | 327 Dart_Port result = service_ports_[service_ports_index_]; |
328 if (result == kIllegalPort) { | 328 if (result == ILLEGAL_PORT) { |
329 result = Dart_NewNativePort("SocketService", | 329 result = Dart_NewNativePort("SocketService", |
330 SocketService, | 330 SocketService, |
331 true); | 331 true); |
332 ASSERT(result != kIllegalPort); | 332 ASSERT(result != ILLEGAL_PORT); |
333 service_ports_[service_ports_index_] = result; | 333 service_ports_[service_ports_index_] = result; |
334 } | 334 } |
335 service_ports_index_ = (service_ports_index_ + 1) % service_ports_size_; | 335 service_ports_index_ = (service_ports_index_ + 1) % service_ports_size_; |
336 return result; | 336 return result; |
337 } | 337 } |
338 | 338 |
339 | 339 |
340 void FUNCTION_NAME(Socket_NewServicePort)(Dart_NativeArguments args) { | 340 void FUNCTION_NAME(Socket_NewServicePort)(Dart_NativeArguments args) { |
341 Dart_EnterScope(); | 341 Dart_EnterScope(); |
342 Dart_SetReturnValue(args, Dart_Null()); | 342 Dart_SetReturnValue(args, Dart_Null()); |
343 Dart_Port service_port = Socket::GetServicePort(); | 343 Dart_Port service_port = Socket::GetServicePort(); |
344 if (service_port != kIllegalPort) { | 344 if (service_port != ILLEGAL_PORT) { |
345 // Return a send port for the service port. | 345 // Return a send port for the service port. |
346 Dart_Handle send_port = Dart_NewSendPort(service_port); | 346 Dart_Handle send_port = Dart_NewSendPort(service_port); |
347 Dart_SetReturnValue(args, send_port); | 347 Dart_SetReturnValue(args, send_port); |
348 } | 348 } |
349 Dart_ExitScope(); | 349 Dart_ExitScope(); |
350 } | 350 } |
OLD | NEW |