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 #ifndef RUNTIME_BIN_SOCKET_H_ | 5 #ifndef RUNTIME_BIN_SOCKET_H_ |
6 #define RUNTIME_BIN_SOCKET_H_ | 6 #define RUNTIME_BIN_SOCKET_H_ |
7 | 7 |
8 #if defined(DART_IO_DISABLED) | 8 #if defined(DART_IO_DISABLED) |
9 #error "socket.h can only be included on builds with IO enabled" | 9 #error "socket.h can only be included on builds with IO enabled" |
10 #endif | 10 #endif |
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 // deallocated either from the finalizer attached to _NativeSockets there, or | 253 // deallocated either from the finalizer attached to _NativeSockets there, or |
254 // from the eventhandler, whichever drops the last reference. | 254 // from the eventhandler, whichever drops the last reference. |
255 class Socket : public ReferenceCounted<Socket> { | 255 class Socket : public ReferenceCounted<Socket> { |
256 public: | 256 public: |
257 enum SocketRequest { | 257 enum SocketRequest { |
258 kLookupRequest = 0, | 258 kLookupRequest = 0, |
259 kListInterfacesRequest = 1, | 259 kListInterfacesRequest = 1, |
260 kReverseLookupRequest = 2, | 260 kReverseLookupRequest = 2, |
261 }; | 261 }; |
262 | 262 |
| 263 enum SocketFinalizer { |
| 264 kFinalizerNormal, |
| 265 kFinalizerListening, |
| 266 kFinalizerStdio, |
| 267 }; |
| 268 |
263 explicit Socket(intptr_t fd); | 269 explicit Socket(intptr_t fd); |
264 | 270 |
265 intptr_t fd() const { return fd_; } | 271 intptr_t fd() const { return fd_; } |
266 void SetClosedFd(); | 272 void SetClosedFd(); |
267 | 273 |
268 Dart_Port port() const { return port_; } | 274 Dart_Port port() const { return port_; } |
269 void set_port(Dart_Port port) { port_ = port; } | 275 void set_port(Dart_Port port) { port_ = port; } |
270 | 276 |
271 // TODO(dart:io): Convert these to instance methods where possible. | 277 // TODO(dart:io): Convert these to instance methods where possible. |
272 static bool Initialize(); | 278 static bool Initialize(); |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
342 OSError** os_error); | 348 OSError** os_error); |
343 | 349 |
344 static CObject* LookupRequest(const CObjectArray& request); | 350 static CObject* LookupRequest(const CObjectArray& request); |
345 static CObject* ListInterfacesRequest(const CObjectArray& request); | 351 static CObject* ListInterfacesRequest(const CObjectArray& request); |
346 static CObject* ReverseLookupRequest(const CObjectArray& request); | 352 static CObject* ReverseLookupRequest(const CObjectArray& request); |
347 | 353 |
348 static Dart_Port GetServicePort(); | 354 static Dart_Port GetServicePort(); |
349 | 355 |
350 static void SetSocketIdNativeField(Dart_Handle handle, | 356 static void SetSocketIdNativeField(Dart_Handle handle, |
351 intptr_t id, | 357 intptr_t id, |
352 bool listening); | 358 SocketFinalizer finalizer); |
353 static void ReuseSocketIdNativeField(Dart_Handle handle, | 359 static void ReuseSocketIdNativeField(Dart_Handle handle, |
354 Socket* socket, | 360 Socket* socket, |
355 bool listening); | 361 SocketFinalizer finalizer); |
356 static Socket* GetSocketIdNativeField(Dart_Handle socket); | 362 static Socket* GetSocketIdNativeField(Dart_Handle socket); |
357 | 363 |
358 private: | 364 private: |
359 ~Socket() { ASSERT(fd_ == kClosedFd); } | 365 ~Socket() { ASSERT(fd_ == kClosedFd); } |
360 | 366 |
361 static const int kClosedFd = -1; | 367 static const int kClosedFd = -1; |
362 | 368 |
363 intptr_t fd_; | 369 intptr_t fd_; |
364 Dart_Port port_; | 370 Dart_Port port_; |
365 | 371 |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
503 | 509 |
504 Mutex* mutex_; | 510 Mutex* mutex_; |
505 | 511 |
506 DISALLOW_COPY_AND_ASSIGN(ListeningSocketRegistry); | 512 DISALLOW_COPY_AND_ASSIGN(ListeningSocketRegistry); |
507 }; | 513 }; |
508 | 514 |
509 } // namespace bin | 515 } // namespace bin |
510 } // namespace dart | 516 } // namespace dart |
511 | 517 |
512 #endif // RUNTIME_BIN_SOCKET_H_ | 518 #endif // RUNTIME_BIN_SOCKET_H_ |
OLD | NEW |