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/directory.h" | 5 #include "bin/directory.h" |
6 | 6 |
7 #include "bin/dartutils.h" | 7 #include "bin/dartutils.h" |
8 #include "bin/thread.h" | 8 #include "bin/thread.h" |
9 #include "include/dart_api.h" | 9 #include "include/dart_api.h" |
10 #include "platform/assert.h" | 10 #include "platform/assert.h" |
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 | 252 |
253 | 253 |
254 Dart_Port Directory::GetServicePort() { | 254 Dart_Port Directory::GetServicePort() { |
255 MutexLocker lock(&mutex_); | 255 MutexLocker lock(&mutex_); |
256 if (service_ports_size_ == 0) { | 256 if (service_ports_size_ == 0) { |
257 ASSERT(service_ports_ == NULL); | 257 ASSERT(service_ports_ == NULL); |
258 service_ports_size_ = 16; | 258 service_ports_size_ = 16; |
259 service_ports_ = new Dart_Port[service_ports_size_]; | 259 service_ports_ = new Dart_Port[service_ports_size_]; |
260 service_ports_index_ = 0; | 260 service_ports_index_ = 0; |
261 for (int i = 0; i < service_ports_size_; i++) { | 261 for (int i = 0; i < service_ports_size_; i++) { |
262 service_ports_[i] = kIllegalPort; | 262 service_ports_[i] = ILLEGAL_PORT; |
263 } | 263 } |
264 } | 264 } |
265 | 265 |
266 Dart_Port result = service_ports_[service_ports_index_]; | 266 Dart_Port result = service_ports_[service_ports_index_]; |
267 if (result == kIllegalPort) { | 267 if (result == ILLEGAL_PORT) { |
268 result = Dart_NewNativePort("DirectoryService", | 268 result = Dart_NewNativePort("DirectoryService", |
269 DirectoryService, | 269 DirectoryService, |
270 true); | 270 true); |
271 ASSERT(result != kIllegalPort); | 271 ASSERT(result != ILLEGAL_PORT); |
272 service_ports_[service_ports_index_] = result; | 272 service_ports_[service_ports_index_] = result; |
273 } | 273 } |
274 service_ports_index_ = (service_ports_index_ + 1) % service_ports_size_; | 274 service_ports_index_ = (service_ports_index_ + 1) % service_ports_size_; |
275 return result; | 275 return result; |
276 } | 276 } |
277 | 277 |
278 | 278 |
279 void FUNCTION_NAME(Directory_NewServicePort)(Dart_NativeArguments args) { | 279 void FUNCTION_NAME(Directory_NewServicePort)(Dart_NativeArguments args) { |
280 Dart_EnterScope(); | 280 Dart_EnterScope(); |
281 Dart_SetReturnValue(args, Dart_Null()); | 281 Dart_SetReturnValue(args, Dart_Null()); |
282 Dart_Port service_port = Directory::GetServicePort(); | 282 Dart_Port service_port = Directory::GetServicePort(); |
283 if (service_port != kIllegalPort) { | 283 if (service_port != ILLEGAL_PORT) { |
284 // Return a send port for the service port. | 284 // Return a send port for the service port. |
285 Dart_Handle send_port = Dart_NewSendPort(service_port); | 285 Dart_Handle send_port = Dart_NewSendPort(service_port); |
286 Dart_SetReturnValue(args, send_port); | 286 Dart_SetReturnValue(args, send_port); |
287 } | 287 } |
288 Dart_ExitScope(); | 288 Dart_ExitScope(); |
289 } | 289 } |
290 | 290 |
291 | 291 |
292 CObjectArray* DirectoryListing::NewResponse(Response type, char* arg) { | 292 CObjectArray* DirectoryListing::NewResponse(Response type, char* arg) { |
293 CObjectArray* response = new CObjectArray(CObject::NewArray(2)); | 293 CObjectArray* response = new CObjectArray(CObject::NewArray(2)); |
(...skipping 22 matching lines...) Expand all Loading... |
316 bool DirectoryListing::HandleError(const char* dir_name) { | 316 bool DirectoryListing::HandleError(const char* dir_name) { |
317 // TODO(sgjesse): Pass flags to indicate whether error | 317 // TODO(sgjesse): Pass flags to indicate whether error |
318 // responses are needed. | 318 // responses are needed. |
319 CObject* err = CObject::NewOSError(); | 319 CObject* err = CObject::NewOSError(); |
320 CObjectArray* response = new CObjectArray(CObject::NewArray(3)); | 320 CObjectArray* response = new CObjectArray(CObject::NewArray(3)); |
321 response->SetAt(0, new CObjectInt32(CObject::NewInt32(kListError))); | 321 response->SetAt(0, new CObjectInt32(CObject::NewInt32(kListError))); |
322 response->SetAt(1, new CObjectString(CObject::NewString(dir_name))); | 322 response->SetAt(1, new CObjectString(CObject::NewString(dir_name))); |
323 response->SetAt(2, err); | 323 response->SetAt(2, err); |
324 return Dart_PostCObject(response_port_, response->AsApiCObject()); | 324 return Dart_PostCObject(response_port_, response->AsApiCObject()); |
325 } | 325 } |
OLD | NEW |