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

Side by Side Diff: webrtc/api/java/jni/androidnetworkmonitor_jni.h

Issue 2111823002: Combine webrtc/api/java/android and webrtc/api/java/src. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 5 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
OLDNEW
(Empty)
1 /*
2 * Copyright 2015 The WebRTC project authors. All Rights Reserved.
3 *
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
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11 #ifndef WEBRTC_API_JAVA_JNI_ANDROIDNETWORKMONITOR_JNI_H_
12 #define WEBRTC_API_JAVA_JNI_ANDROIDNETWORKMONITOR_JNI_H_
13
14 #include "webrtc/base/networkmonitor.h"
15
16 #include <map>
17
18 #include "webrtc/api/java/jni/jni_helpers.h"
19 #include "webrtc/base/basictypes.h"
20 #include "webrtc/base/thread_checker.h"
21
22 namespace webrtc_jni {
23
24 typedef uint32_t NetworkHandle;
25
26 // c++ equivalent of java NetworkMonitorAutoDetect.ConnectionType.
27 enum NetworkType {
28 NETWORK_UNKNOWN,
29 NETWORK_ETHERNET,
30 NETWORK_WIFI,
31 NETWORK_4G,
32 NETWORK_3G,
33 NETWORK_2G,
34 NETWORK_BLUETOOTH,
35 NETWORK_NONE
36 };
37
38 // The information is collected from Android OS so that the native code can get
39 // the network type and handle (Android network ID) for each interface.
40 struct NetworkInformation {
41 std::string interface_name;
42 NetworkHandle handle;
43 NetworkType type;
44 std::vector<rtc::IPAddress> ip_addresses;
45
46 std::string ToString() const;
47 };
48
49 class AndroidNetworkMonitor : public rtc::NetworkMonitorBase,
50 public rtc::NetworkBinderInterface {
51 public:
52 AndroidNetworkMonitor();
53
54 static void SetAndroidContext(JNIEnv* jni, jobject context);
55
56 void Start() override;
57 void Stop() override;
58
59 int BindSocketToNetwork(int socket_fd,
60 const rtc::IPAddress& address) override;
61 rtc::AdapterType GetAdapterType(const std::string& if_name) override;
62 void OnNetworkConnected(const NetworkInformation& network_info);
63 void OnNetworkDisconnected(NetworkHandle network_handle);
64 void SetNetworkInfos(const std::vector<NetworkInformation>& network_infos);
65
66 private:
67 JNIEnv* jni() { return AttachCurrentThreadIfNeeded(); }
68
69 void OnNetworkConnected_w(const NetworkInformation& network_info);
70 void OnNetworkDisconnected_w(NetworkHandle network_handle);
71
72 ScopedGlobalRef<jclass> j_network_monitor_class_;
73 ScopedGlobalRef<jobject> j_network_monitor_;
74 rtc::ThreadChecker thread_checker_;
75 static jobject application_context_;
76 bool started_ = false;
77 std::map<std::string, rtc::AdapterType> adapter_type_by_name_;
78 std::map<rtc::IPAddress, NetworkHandle> network_handle_by_address_;
79 std::map<NetworkHandle, NetworkInformation> network_info_by_handle_;
80 };
81
82 class AndroidNetworkMonitorFactory : public rtc::NetworkMonitorFactory {
83 public:
84 AndroidNetworkMonitorFactory() {}
85
86 rtc::NetworkMonitorInterface* CreateNetworkMonitor() override;
87 };
88
89 } // namespace webrtc_jni
90
91 #endif // WEBRTC_API_JAVA_JNI_ANDROIDNETWORKMONITOR_JNI_H_
OLDNEW
« no previous file with comments | « webrtc/api/java/jni/androidmetrics_jni.cc ('k') | webrtc/api/java/jni/androidnetworkmonitor_jni.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698