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

Unified Diff: webrtc/base/networkmonitor.h

Issue 1556743002: Bind a socket to a network if the network handle is set. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Fix a compiling issue for Windows Created 4 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: webrtc/base/networkmonitor.h
diff --git a/webrtc/base/networkmonitor.h b/webrtc/base/networkmonitor.h
index c45c81704072774497facdbf7821121dbd5a76d9..ab654408a04ec219b3dae84742b9dd13f4bbf300 100644
--- a/webrtc/base/networkmonitor.h
+++ b/webrtc/base/networkmonitor.h
@@ -17,6 +17,27 @@
#include "webrtc/base/thread.h"
namespace rtc {
+
+typedef uint32_t NetworkHandle;
pthatcher1 2016/01/14 20:07:24 Is this ever used?
honghaiz3 2016/01/15 01:00:38 Good catch. Move this androidnetworkmonitor_jni.h
+
+class IPAddress;
+
+// Error values are negative.
+enum NetworkBindingResults {
+ OK = 0, // No error
+ ERR_FAILED = -1, // Generic error
+ ERR_NOT_IMPLEMENTED = -2,
+ ERR_ADDRESS_NOT_FOUND = -3,
+ ERR_NETWORK_CHANGED = -4
+};
+
+class NetworkBinderInterface {
+ public:
+ // Binds a socket to the network that is attached to |address| so that all
+ // packets on the socket |socket_fd| will be sent via that network.
pthatcher1 2016/01/14 20:07:24 Can you explain why we need this (because some ope
honghaiz3 2016/01/15 01:00:38 Done.
+ virtual int BindSocketToNetwork(int socket_fd, const IPAddress& address) = 0;
+};
+
/*
* Receives network-change events via |OnNetworksChanged| and signals the
* networks changed event.
@@ -36,7 +57,7 @@ namespace rtc {
*/
// Generic network monitor interface. It starts and stops monitoring network
// changes, and fires the SignalNetworksChanged event when networks change.
-class NetworkMonitorInterface {
+class NetworkMonitorInterface : public NetworkBinderInterface {
public:
NetworkMonitorInterface();
virtual ~NetworkMonitorInterface();
@@ -58,6 +79,7 @@ class NetworkMonitorBase : public NetworkMonitorInterface,
NetworkMonitorBase();
~NetworkMonitorBase() override;
+ void Start() override;
void OnNetworksChanged() override;
void OnMessage(Message* msg) override;
@@ -78,7 +100,7 @@ class NetworkMonitorFactory {
static void ReleaseFactory(NetworkMonitorFactory* factory);
static NetworkMonitorFactory* GetFactory();
- virtual NetworkMonitorInterface* CreateNetworkMonitor() = 0;
+ virtual NetworkMonitorInterface* GetOrCreateNetworkMonitor() = 0;
virtual ~NetworkMonitorFactory();

Powered by Google App Engine
This is Rietveld 408576698