| OLD | NEW |
| 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/socket.h" | 6 #include "bin/socket.h" |
| 7 #include "bin/dartutils.h" | 7 #include "bin/dartutils.h" |
| 8 #include "bin/thread.h" | 8 #include "bin/thread.h" |
| 9 #include "bin/utils.h" | 9 #include "bin/utils.h" |
| 10 | 10 |
| 11 #include "platform/globals.h" | 11 #include "platform/globals.h" |
| 12 #include "platform/thread.h" | 12 #include "platform/thread.h" |
| 13 #include "platform/utils.h" | 13 #include "platform/utils.h" |
| 14 | 14 |
| 15 #include "include/dart_api.h" | 15 #include "include/dart_api.h" |
| 16 | 16 |
| 17 | 17 |
| 18 namespace dart { | 18 namespace dart { |
| 19 namespace bin { | 19 namespace bin { |
| 20 | 20 |
| 21 static const int kSocketIdNativeField = 0; | 21 static const int kSocketIdNativeField = 0; |
| 22 | 22 |
| 23 dart::Mutex Socket::mutex_; | 23 dart::Mutex* Socket::mutex_ = new dart::Mutex(); |
| 24 int Socket::service_ports_size_ = 0; | 24 int Socket::service_ports_size_ = 0; |
| 25 Dart_Port* Socket::service_ports_ = NULL; | 25 Dart_Port* Socket::service_ports_ = NULL; |
| 26 int Socket::service_ports_index_ = 0; | 26 int Socket::service_ports_index_ = 0; |
| 27 | 27 |
| 28 | 28 |
| 29 static Dart_Handle GetSockAddr(Dart_Handle obj, RawAddr* addr) { | 29 static Dart_Handle GetSockAddr(Dart_Handle obj, RawAddr* addr) { |
| 30 Dart_TypedData_Type data_type; | 30 Dart_TypedData_Type data_type; |
| 31 uint8_t* data = NULL; | 31 uint8_t* data = NULL; |
| 32 intptr_t len; | 32 intptr_t len; |
| 33 Dart_Handle result = Dart_TypedDataAcquireData( | 33 Dart_Handle result = Dart_TypedDataAcquireData( |
| (...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 543 UNREACHABLE(); | 543 UNREACHABLE(); |
| 544 } | 544 } |
| 545 } | 545 } |
| 546 } | 546 } |
| 547 | 547 |
| 548 Dart_PostCObject(reply_port_id, response->AsApiCObject()); | 548 Dart_PostCObject(reply_port_id, response->AsApiCObject()); |
| 549 } | 549 } |
| 550 | 550 |
| 551 | 551 |
| 552 Dart_Port Socket::GetServicePort() { | 552 Dart_Port Socket::GetServicePort() { |
| 553 MutexLocker lock(&mutex_); | 553 MutexLocker lock(mutex_); |
| 554 if (service_ports_size_ == 0) { | 554 if (service_ports_size_ == 0) { |
| 555 ASSERT(service_ports_ == NULL); | 555 ASSERT(service_ports_ == NULL); |
| 556 service_ports_size_ = 16; | 556 service_ports_size_ = 16; |
| 557 service_ports_ = new Dart_Port[service_ports_size_]; | 557 service_ports_ = new Dart_Port[service_ports_size_]; |
| 558 service_ports_index_ = 0; | 558 service_ports_index_ = 0; |
| 559 for (int i = 0; i < service_ports_size_; i++) { | 559 for (int i = 0; i < service_ports_size_; i++) { |
| 560 service_ports_[i] = ILLEGAL_PORT; | 560 service_ports_[i] = ILLEGAL_PORT; |
| 561 } | 561 } |
| 562 } | 562 } |
| 563 | 563 |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 618 return Dart_SetNativeInstanceField(socket, kSocketIdNativeField, id); | 618 return Dart_SetNativeInstanceField(socket, kSocketIdNativeField, id); |
| 619 } | 619 } |
| 620 | 620 |
| 621 | 621 |
| 622 Dart_Handle Socket::GetSocketIdNativeField(Dart_Handle socket, intptr_t* id) { | 622 Dart_Handle Socket::GetSocketIdNativeField(Dart_Handle socket, intptr_t* id) { |
| 623 return Dart_GetNativeInstanceField(socket, kSocketIdNativeField, id); | 623 return Dart_GetNativeInstanceField(socket, kSocketIdNativeField, id); |
| 624 } | 624 } |
| 625 | 625 |
| 626 } // namespace bin | 626 } // namespace bin |
| 627 } // namespace dart | 627 } // namespace dart |
| OLD | NEW |