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 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
345 } | 345 } |
346 // NOTE(pauljensen): This does rely on Android implementation details, but | 346 // NOTE(pauljensen): This does rely on Android implementation details, but |
347 // these details are unlikely to change. | 347 // these details are unlikely to change. |
348 typedef int (*SetNetworkForSocket)(unsigned netId, int socketFd); | 348 typedef int (*SetNetworkForSocket)(unsigned netId, int socketFd); |
349 static SetNetworkForSocket setNetworkForSocket; | 349 static SetNetworkForSocket setNetworkForSocket; |
350 // This is racy, but all racers should come out with the same answer so it | 350 // This is racy, but all racers should come out with the same answer so it |
351 // shouldn't matter. | 351 // shouldn't matter. |
352 if (setNetworkForSocket == nullptr) { | 352 if (setNetworkForSocket == nullptr) { |
353 // Android's netd client library should always be loaded in our address | 353 // Android's netd client library should always be loaded in our address |
354 // space as it shims libc functions like connect(). | 354 // space as it shims libc functions like connect(). |
355 base::FilePath file(base::FilePath::FromUTF16Unsafe( | 355 base::FilePath file(base::FilePath::FromUTF8Unsafe( |
Mark Mentovai
2016/06/13 19:29:03
Is FromUTF8Unsafe() even needed in this Android-on
Lei Zhang
2016/06/13 21:30:34
Nope.
| |
356 base::GetNativeLibraryName(base::ASCIIToUTF16("netd_client")))); | 356 base::GetNativeLibraryName("netd_client"))); |
357 base::NativeLibrary lib = base::LoadNativeLibrary(file, nullptr); | 357 base::NativeLibrary lib = base::LoadNativeLibrary(file, nullptr); |
358 setNetworkForSocket = reinterpret_cast<SetNetworkForSocket>( | 358 setNetworkForSocket = reinterpret_cast<SetNetworkForSocket>( |
359 base::GetFunctionPointerFromNativeLibrary(lib, "setNetworkForSocket")); | 359 base::GetFunctionPointerFromNativeLibrary(lib, "setNetworkForSocket")); |
360 } | 360 } |
361 if (setNetworkForSocket == nullptr) | 361 if (setNetworkForSocket == nullptr) |
362 return ERR_NOT_IMPLEMENTED; | 362 return ERR_NOT_IMPLEMENTED; |
363 int rv = setNetworkForSocket(network, socket_); | 363 int rv = setNetworkForSocket(network, socket_); |
364 // If |network| has since disconnected, |rv| will be ENONET. Surface this as | 364 // If |network| has since disconnected, |rv| will be ENONET. Surface this as |
365 // ERR_NETWORK_CHANGED, rather than MapSystemError(ENONET) which gives back | 365 // ERR_NETWORK_CHANGED, rather than MapSystemError(ENONET) which gives back |
366 // the less descriptive ERR_FAILED. | 366 // the less descriptive ERR_FAILED. |
(...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
807 return MapSystemError(errno); | 807 return MapSystemError(errno); |
808 | 808 |
809 return OK; | 809 return OK; |
810 } | 810 } |
811 | 811 |
812 void UDPSocketPosix::DetachFromThread() { | 812 void UDPSocketPosix::DetachFromThread() { |
813 base::NonThreadSafe::DetachFromThread(); | 813 base::NonThreadSafe::DetachFromThread(); |
814 } | 814 } |
815 | 815 |
816 } // namespace net | 816 } // namespace net |
OLD | NEW |