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/file.h" | 5 #include "bin/file.h" |
6 | 6 |
7 #include "bin/builtin.h" | 7 #include "bin/builtin.h" |
8 #include "bin/dartutils.h" | 8 #include "bin/dartutils.h" |
9 #include "bin/thread.h" | 9 #include "bin/thread.h" |
10 #include "bin/utils.h" | 10 #include "bin/utils.h" |
(...skipping 946 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
957 | 957 |
958 | 958 |
959 Dart_Port File::GetServicePort() { | 959 Dart_Port File::GetServicePort() { |
960 MutexLocker lock(&mutex_); | 960 MutexLocker lock(&mutex_); |
961 if (service_ports_size_ == 0) { | 961 if (service_ports_size_ == 0) { |
962 ASSERT(service_ports_ == NULL); | 962 ASSERT(service_ports_ == NULL); |
963 service_ports_size_ = 16; | 963 service_ports_size_ = 16; |
964 service_ports_ = new Dart_Port[service_ports_size_]; | 964 service_ports_ = new Dart_Port[service_ports_size_]; |
965 service_ports_index_ = 0; | 965 service_ports_index_ = 0; |
966 for (int i = 0; i < service_ports_size_; i++) { | 966 for (int i = 0; i < service_ports_size_; i++) { |
967 service_ports_[i] = kIllegalPort; | 967 service_ports_[i] = ILLEGAL_PORT; |
968 } | 968 } |
969 } | 969 } |
970 | 970 |
971 Dart_Port result = service_ports_[service_ports_index_]; | 971 Dart_Port result = service_ports_[service_ports_index_]; |
972 if (result == kIllegalPort) { | 972 if (result == ILLEGAL_PORT) { |
973 result = Dart_NewNativePort("FileService", | 973 result = Dart_NewNativePort("FileService", |
974 FileService, | 974 FileService, |
975 true); | 975 true); |
976 ASSERT(result != kIllegalPort); | 976 ASSERT(result != ILLEGAL_PORT); |
977 service_ports_[service_ports_index_] = result; | 977 service_ports_[service_ports_index_] = result; |
978 } | 978 } |
979 service_ports_index_ = (service_ports_index_ + 1) % service_ports_size_; | 979 service_ports_index_ = (service_ports_index_ + 1) % service_ports_size_; |
980 return result; | 980 return result; |
981 } | 981 } |
982 | 982 |
983 | 983 |
984 void FUNCTION_NAME(File_NewServicePort)(Dart_NativeArguments args) { | 984 void FUNCTION_NAME(File_NewServicePort)(Dart_NativeArguments args) { |
985 Dart_EnterScope(); | 985 Dart_EnterScope(); |
986 Dart_SetReturnValue(args, Dart_Null()); | 986 Dart_SetReturnValue(args, Dart_Null()); |
987 Dart_Port service_port = File::GetServicePort(); | 987 Dart_Port service_port = File::GetServicePort(); |
988 if (service_port != kIllegalPort) { | 988 if (service_port != ILLEGAL_PORT) { |
989 // Return a send port for the service port. | 989 // Return a send port for the service port. |
990 Dart_Handle send_port = Dart_NewSendPort(service_port); | 990 Dart_Handle send_port = Dart_NewSendPort(service_port); |
991 Dart_SetReturnValue(args, send_port); | 991 Dart_SetReturnValue(args, send_port); |
992 } | 992 } |
993 Dart_ExitScope(); | 993 Dart_ExitScope(); |
994 } | 994 } |
OLD | NEW |