| 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 BIN_SOCKET_H_ | 5 #ifndef BIN_SOCKET_H_ |
| 6 #define BIN_SOCKET_H_ | 6 #define BIN_SOCKET_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 | 9 |
| 10 #include "platform/globals.h" | 10 #include "platform/globals.h" |
| (...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 388 // This should be called from the event handler for every kCloseEvent it gets | 388 // This should be called from the event handler for every kCloseEvent it gets |
| 389 // on listening sockets. | 389 // on listening sockets. |
| 390 // | 390 // |
| 391 // Returns `true` if the last reference has been dropped and the underlying | 391 // Returns `true` if the last reference has been dropped and the underlying |
| 392 // socket can be closed. | 392 // socket can be closed. |
| 393 // | 393 // |
| 394 // The caller is responsible for obtaining the mutex first, before calling | 394 // The caller is responsible for obtaining the mutex first, before calling |
| 395 // this function. | 395 // this function. |
| 396 bool CloseSafe(intptr_t socketfd); | 396 bool CloseSafe(intptr_t socketfd); |
| 397 | 397 |
| 398 // Mark an existing socket as sharable if it is not already marked as | |
| 399 // sharable. | |
| 400 // | |
| 401 // NOTE: This is a temporary measure until ServerSocketReference's are | |
| 402 // removed. | |
| 403 Dart_Handle MarkSocketFdAsSharableHack(intptr_t socketfd); | |
| 404 | |
| 405 Mutex *mutex() { return mutex_; } | 398 Mutex *mutex() { return mutex_; } |
| 406 | 399 |
| 407 private: | 400 private: |
| 408 OSSocket *findOSSocketWithAddress(OSSocket *current, const RawAddr& addr) { | 401 OSSocket *findOSSocketWithAddress(OSSocket *current, const RawAddr& addr) { |
| 409 while (current != NULL) { | 402 while (current != NULL) { |
| 410 if (SocketAddress::AreAddressesEqual(current->address, addr)) { | 403 if (SocketAddress::AreAddressesEqual(current->address, addr)) { |
| 411 return current; | 404 return current; |
| 412 } | 405 } |
| 413 current = current->next; | 406 current = current->next; |
| 414 } | 407 } |
| 415 return NULL; | 408 return NULL; |
| 416 } | 409 } |
| 417 | 410 |
| 418 std::map<intptr_t, OSSocket*> sockets_by_port_; | 411 std::map<intptr_t, OSSocket*> sockets_by_port_; |
| 419 std::map<intptr_t, OSSocket*> sockets_by_fd_; | 412 std::map<intptr_t, OSSocket*> sockets_by_fd_; |
| 420 Mutex *mutex_; | 413 Mutex *mutex_; |
| 421 | 414 |
| 422 typedef std::map<intptr_t, OSSocket*>::iterator SocketsIterator; | 415 typedef std::map<intptr_t, OSSocket*>::iterator SocketsIterator; |
| 423 | 416 |
| 424 private: | 417 private: |
| 425 DISALLOW_COPY_AND_ASSIGN(ListeningSocketRegistry); | 418 DISALLOW_COPY_AND_ASSIGN(ListeningSocketRegistry); |
| 426 }; | 419 }; |
| 427 | 420 |
| 428 | 421 |
| 429 } // namespace bin | 422 } // namespace bin |
| 430 } // namespace dart | 423 } // namespace dart |
| 431 | 424 |
| 432 #endif // BIN_SOCKET_H_ | 425 #endif // BIN_SOCKET_H_ |
| OLD | NEW |