OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "net/udp/udp_socket_posix.h" | 5 #include "net/udp/udp_socket_posix.h" |
6 | 6 |
7 #include <errno.h> | 7 #include <errno.h> |
8 #include <fcntl.h> | 8 #include <fcntl.h> |
9 #include <net/if.h> | 9 #include <net/if.h> |
10 #include <netdb.h> | 10 #include <netdb.h> |
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
343 } | 343 } |
344 // NOTE(pauljensen): This does rely on Android implementation details, but | 344 // NOTE(pauljensen): This does rely on Android implementation details, but |
345 // these details are unlikely to change. | 345 // these details are unlikely to change. |
346 typedef int (*SetNetworkForSocket)(unsigned netId, int socketFd); | 346 typedef int (*SetNetworkForSocket)(unsigned netId, int socketFd); |
347 static SetNetworkForSocket setNetworkForSocket; | 347 static SetNetworkForSocket setNetworkForSocket; |
348 // This is racy, but all racers should come out with the same answer so it | 348 // This is racy, but all racers should come out with the same answer so it |
349 // shouldn't matter. | 349 // shouldn't matter. |
350 if (setNetworkForSocket == nullptr) { | 350 if (setNetworkForSocket == nullptr) { |
351 // Android's netd client library should always be loaded in our address | 351 // Android's netd client library should always be loaded in our address |
352 // space as it shims libc functions like connect(). | 352 // space as it shims libc functions like connect(). |
353 base::FilePath file(base::FilePath::FromUTF16Unsafe( | 353 base::FilePath file(base::FilePath::FromUTF8Unsafe( |
354 base::GetNativeLibraryName(base::ASCIIToUTF16("netd_client")))); | 354 base::GetNativeLibraryName("netd_client"))); |
355 base::NativeLibrary lib = base::LoadNativeLibrary(file, nullptr); | 355 base::NativeLibrary lib = base::LoadNativeLibrary(file, nullptr); |
356 setNetworkForSocket = reinterpret_cast<SetNetworkForSocket>( | 356 setNetworkForSocket = reinterpret_cast<SetNetworkForSocket>( |
357 base::GetFunctionPointerFromNativeLibrary(lib, "setNetworkForSocket")); | 357 base::GetFunctionPointerFromNativeLibrary(lib, "setNetworkForSocket")); |
358 } | 358 } |
359 if (setNetworkForSocket == nullptr) | 359 if (setNetworkForSocket == nullptr) |
360 return ERR_NOT_IMPLEMENTED; | 360 return ERR_NOT_IMPLEMENTED; |
361 int rv = setNetworkForSocket(network, socket_); | 361 int rv = setNetworkForSocket(network, socket_); |
362 // If |network| has since disconnected, |rv| will be ENONET. Surface this as | 362 // If |network| has since disconnected, |rv| will be ENONET. Surface this as |
363 // ERR_NETWORK_CHANGED, rather than MapSystemError(ENONET) which gives back | 363 // ERR_NETWORK_CHANGED, rather than MapSystemError(ENONET) which gives back |
364 // the less descriptive ERR_FAILED. | 364 // the less descriptive ERR_FAILED. |
(...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
803 return MapSystemError(errno); | 803 return MapSystemError(errno); |
804 | 804 |
805 return OK; | 805 return OK; |
806 } | 806 } |
807 | 807 |
808 void UDPSocketPosix::DetachFromThread() { | 808 void UDPSocketPosix::DetachFromThread() { |
809 base::NonThreadSafe::DetachFromThread(); | 809 base::NonThreadSafe::DetachFromThread(); |
810 } | 810 } |
811 | 811 |
812 } // namespace net | 812 } // namespace net |
OLD | NEW |