Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(681)

Side by Side Diff: webrtc/base/networkmonitor.h

Issue 2646863005: Fixing logic for using android_setsocknetwork() with bind(). (Closed)
Patch Set: Fixing tests for loopback IP change. Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | webrtc/base/physicalsocketserver.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2015 The WebRTC Project Authors. All rights reserved. 2 * Copyright 2015 The WebRTC Project Authors. All rights reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
11 #ifndef WEBRTC_BASE_NETWORKMONITOR_H_ 11 #ifndef WEBRTC_BASE_NETWORKMONITOR_H_
12 #define WEBRTC_BASE_NETWORKMONITOR_H_ 12 #define WEBRTC_BASE_NETWORKMONITOR_H_
13 13
14 #include "webrtc/base/logging.h" 14 #include "webrtc/base/logging.h"
15 #include "webrtc/base/sigslot.h" 15 #include "webrtc/base/sigslot.h"
16 #include "webrtc/base/thread.h" 16 #include "webrtc/base/thread.h"
17 17
18 namespace rtc { 18 namespace rtc {
19 19
20 class IPAddress; 20 class IPAddress;
21 21
22 // Error values are negative. 22 enum class NetworkBindingResult {
23 enum NetworkBindingResults { 23 SUCCESS = 0, // No error
24 NETWORK_BIND_SUCCESS = 0, // No error 24 FAILURE = -1, // Generic error
25 NETWORK_BIND_FAILURE = -1, // Generic error 25 NOT_IMPLEMENTED = -2,
26 NETWORK_BIND_NOT_IMPLEMENTED = -2, 26 ADDRESS_NOT_FOUND = -3,
27 NETWORK_BIND_ADDRESS_NOT_FOUND = -3, 27 NETWORK_CHANGED = -4
28 NETWORK_BIND_NETWORK_CHANGED = -4
29 }; 28 };
30 29
31 enum AdapterType { 30 enum AdapterType {
32 // This enum resembles the one in Chromium net::ConnectionType. 31 // This enum resembles the one in Chromium net::ConnectionType.
33 ADAPTER_TYPE_UNKNOWN = 0, 32 ADAPTER_TYPE_UNKNOWN = 0,
34 ADAPTER_TYPE_ETHERNET = 1 << 0, 33 ADAPTER_TYPE_ETHERNET = 1 << 0,
35 ADAPTER_TYPE_WIFI = 1 << 1, 34 ADAPTER_TYPE_WIFI = 1 << 1,
36 ADAPTER_TYPE_CELLULAR = 1 << 2, 35 ADAPTER_TYPE_CELLULAR = 1 << 2,
37 ADAPTER_TYPE_VPN = 1 << 3, 36 ADAPTER_TYPE_VPN = 1 << 3,
38 ADAPTER_TYPE_LOOPBACK = 1 << 4 37 ADAPTER_TYPE_LOOPBACK = 1 << 4
39 }; 38 };
40 39
41 class NetworkBinderInterface { 40 class NetworkBinderInterface {
42 public: 41 public:
43 // Binds a socket to the network that is attached to |address| so that all 42 // Binds a socket to the network that is attached to |address| so that all
44 // packets on the socket |socket_fd| will be sent via that network. 43 // packets on the socket |socket_fd| will be sent via that network.
45 // This is needed because some operating systems (like Android) require a 44 // This is needed because some operating systems (like Android) require a
46 // special bind call to put packets on a non-default network interface. 45 // special bind call to put packets on a non-default network interface.
47 virtual int BindSocketToNetwork(int socket_fd, const IPAddress& address) = 0; 46 virtual NetworkBindingResult BindSocketToNetwork(
47 int socket_fd,
48 const IPAddress& address) = 0;
48 virtual ~NetworkBinderInterface() {} 49 virtual ~NetworkBinderInterface() {}
49 }; 50 };
50 51
51 /* 52 /*
52 * Receives network-change events via |OnNetworksChanged| and signals the 53 * Receives network-change events via |OnNetworksChanged| and signals the
53 * networks changed event. 54 * networks changed event.
54 * 55 *
55 * Threading consideration: 56 * Threading consideration:
56 * It is expected that all upstream operations (from native to Java) are 57 * It is expected that all upstream operations (from native to Java) are
57 * performed from the worker thread. This includes creating, starting and 58 * performed from the worker thread. This includes creating, starting and
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 119
119 virtual ~NetworkMonitorFactory(); 120 virtual ~NetworkMonitorFactory();
120 121
121 protected: 122 protected:
122 NetworkMonitorFactory(); 123 NetworkMonitorFactory();
123 }; 124 };
124 125
125 } // namespace rtc 126 } // namespace rtc
126 127
127 #endif // WEBRTC_BASE_NETWORKMONITOR_H_ 128 #endif // WEBRTC_BASE_NETWORKMONITOR_H_
OLDNEW
« no previous file with comments | « no previous file | webrtc/base/physicalsocketserver.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698