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

Side by Side Diff: chrome/browser/net/spdyproxy/data_reduction_proxy_settings_android.h

Issue 2781323004: Create a new Data Saver settings page that adds the site breakdown (Closed)
Patch Set: rebase Created 3 years, 8 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
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 #ifndef CHROME_BROWSER_NET_SPDYPROXY_DATA_REDUCTION_PROXY_SETTINGS_ANDROID_H_ 5 #ifndef CHROME_BROWSER_NET_SPDYPROXY_DATA_REDUCTION_PROXY_SETTINGS_ANDROID_H_
6 #define CHROME_BROWSER_NET_SPDYPROXY_DATA_REDUCTION_PROXY_SETTINGS_ANDROID_H_ 6 #define CHROME_BROWSER_NET_SPDYPROXY_DATA_REDUCTION_PROXY_SETTINGS_ANDROID_H_
7 7
8 #include <jni.h>
9
8 #include <memory> 10 #include <memory>
11 #include <vector>
9 12
13 #include "base/android/jni_android.h"
10 #include "base/android/jni_string.h" 14 #include "base/android/jni_string.h"
11 #include "base/android/jni_weak_ref.h" 15 #include "base/android/jni_weak_ref.h"
12 #include "base/android/scoped_java_ref.h" 16 #include "base/android/scoped_java_ref.h"
13 #include "base/compiler_specific.h" 17 #include "base/compiler_specific.h"
14 #include "base/gtest_prod_util.h" 18 #include "base/gtest_prod_util.h"
15 #include "base/macros.h" 19 #include "base/macros.h"
20 #include "base/memory/weak_ptr.h"
21 #include "components/data_reduction_proxy/proto/data_store.pb.h"
16 #include "components/prefs/pref_member.h" 22 #include "components/prefs/pref_member.h"
17 23
18 using base::android::ScopedJavaLocalRef; 24 using base::android::ScopedJavaLocalRef;
19 25
20 class Profile; 26 class Profile;
21 27
22 namespace data_reduction_proxy { 28 namespace data_reduction_proxy {
23 class DataReductionProxySettings; 29 class DataReductionProxySettings;
24 } 30 }
25 31
26 // Central point for configuring the data reduction proxy on Android. 32 // Central point for configuring the data reduction proxy on Android.
27 // This object lives on the UI thread and all of its methods are expected to 33 // This object lives on the UI thread and all of its methods are expected to
28 // be called from there. 34 // be called from there.
29 class DataReductionProxySettingsAndroid { 35 class DataReductionProxySettingsAndroid {
30 public: 36 public:
31 DataReductionProxySettingsAndroid(); 37 DataReductionProxySettingsAndroid(
38 JNIEnv* env,
39 const base::android::JavaParamRef<jobject>& obj);
32 40
33 virtual ~DataReductionProxySettingsAndroid(); 41 virtual ~DataReductionProxySettingsAndroid();
34 42
35 void InitDataReductionProxySettings(Profile* profile); 43 void InitDataReductionProxySettings(Profile* profile);
36 44
37 // JNI wrapper interfaces to the indentically-named superclass methods. 45 // JNI wrapper interfaces to the indentically-named superclass methods.
38 jboolean IsDataReductionProxyPromoAllowed( 46 jboolean IsDataReductionProxyPromoAllowed(
39 JNIEnv* env, 47 JNIEnv* env,
40 const base::android::JavaParamRef<jobject>& obj); 48 const base::android::JavaParamRef<jobject>& obj);
41 jboolean IsDataReductionProxyEnabled( 49 jboolean IsDataReductionProxyEnabled(
42 JNIEnv* env, 50 JNIEnv* env,
43 const base::android::JavaParamRef<jobject>& obj); 51 const base::android::JavaParamRef<jobject>& obj);
44 jboolean IsDataReductionProxyManaged( 52 jboolean IsDataReductionProxyManaged(
45 JNIEnv* env, 53 JNIEnv* env,
46 const base::android::JavaParamRef<jobject>& obj); 54 const base::android::JavaParamRef<jobject>& obj);
47 void SetDataReductionProxyEnabled( 55 void SetDataReductionProxyEnabled(
48 JNIEnv* env, 56 JNIEnv* env,
49 const base::android::JavaParamRef<jobject>& obj, 57 const base::android::JavaParamRef<jobject>& obj,
50 jboolean enabled); 58 jboolean enabled);
51 jlong GetDataReductionLastUpdateTime( 59 jlong GetDataReductionLastUpdateTime(
52 JNIEnv* env, 60 JNIEnv* env,
53 const base::android::JavaParamRef<jobject>& obj); 61 const base::android::JavaParamRef<jobject>& obj);
62 void ClearDataSavingStatistics(
63 JNIEnv* env,
64 const base::android::JavaParamRef<jobject>& obj);
54 jlong GetTotalHttpContentLengthSaved( 65 jlong GetTotalHttpContentLengthSaved(
55 JNIEnv* env, 66 JNIEnv* env,
56 const base::android::JavaParamRef<jobject>& obj); 67 const base::android::JavaParamRef<jobject>& obj);
57 ScopedJavaLocalRef<jlongArray> GetDailyOriginalContentLengths( 68 ScopedJavaLocalRef<jlongArray> GetDailyOriginalContentLengths(
58 JNIEnv* env, 69 JNIEnv* env,
59 const base::android::JavaParamRef<jobject>& obj); 70 const base::android::JavaParamRef<jobject>& obj);
60 ScopedJavaLocalRef<jlongArray> GetDailyReceivedContentLengths( 71 ScopedJavaLocalRef<jlongArray> GetDailyReceivedContentLengths(
61 JNIEnv* env, 72 JNIEnv* env,
62 const base::android::JavaParamRef<jobject>& obj); 73 const base::android::JavaParamRef<jobject>& obj);
63 74
(...skipping 25 matching lines...) Expand all
89 ScopedJavaLocalRef<jstring> GetHttpProxyList( 100 ScopedJavaLocalRef<jstring> GetHttpProxyList(
90 JNIEnv* env, 101 JNIEnv* env,
91 const base::android::JavaParamRef<jobject>& obj); 102 const base::android::JavaParamRef<jobject>& obj);
92 103
93 // Returns a Java string of the last Data Reduction Proxy bypass event as 104 // Returns a Java string of the last Data Reduction Proxy bypass event as
94 // a JSON object. 105 // a JSON object.
95 ScopedJavaLocalRef<jstring> GetLastBypassEvent( 106 ScopedJavaLocalRef<jstring> GetLastBypassEvent(
96 JNIEnv* env, 107 JNIEnv* env,
97 const base::android::JavaParamRef<jobject>& obj); 108 const base::android::JavaParamRef<jobject>& obj);
98 109
110 // Gets the historical data usage for |numDays| and adds them to a list that
111 // groups data use by hostname.
112 void QueryDataUsage(JNIEnv* env,
113 const base::android::JavaParamRef<jobject>& obj,
114 const base::android::JavaParamRef<jobject>& j_result_obj,
115 jint num_days);
116 void OnQueryDataUsageComplete(
117 std::unique_ptr<std::vector<data_reduction_proxy::DataUsageBucket>>
118 data_usage);
119
99 // Registers the native methods to be call from Java. 120 // Registers the native methods to be call from Java.
100 static bool Register(JNIEnv* env); 121 static bool Register(JNIEnv* env);
101 122
123 JavaObjectWeakGlobalRef j_settings_obj_;
124 base::android::ScopedJavaGlobalRef<jobject> j_query_result_obj_;
125 int num_day_for_query_;
126
102 private: 127 private:
103 friend class DataReductionProxySettingsAndroidTest; 128 friend class DataReductionProxySettingsAndroidTest;
129 friend class TestDataReductionProxySettingsAndroid;
104 FRIEND_TEST_ALL_PREFIXES(DataReductionProxySettingsAndroidTest, 130 FRIEND_TEST_ALL_PREFIXES(DataReductionProxySettingsAndroidTest,
105 TestGetDailyContentLengths); 131 TestGetDailyContentLengths);
106 132
133 // For testing purposes.
134 DataReductionProxySettingsAndroid();
135
107 ScopedJavaLocalRef<jlongArray> GetDailyContentLengths(JNIEnv* env, 136 ScopedJavaLocalRef<jlongArray> GetDailyContentLengths(JNIEnv* env,
108 const char* pref_name); 137 const char* pref_name);
109 138
110 virtual data_reduction_proxy::DataReductionProxySettings* Settings(); 139 virtual data_reduction_proxy::DataReductionProxySettings* Settings();
111 140
141 base::WeakPtrFactory<DataReductionProxySettingsAndroid> weak_factory_;
142
112 DISALLOW_COPY_AND_ASSIGN(DataReductionProxySettingsAndroid); 143 DISALLOW_COPY_AND_ASSIGN(DataReductionProxySettingsAndroid);
113 }; 144 };
114 145
115 #endif // CHROME_BROWSER_NET_SPDYPROXY_DATA_REDUCTION_PROXY_SETTINGS_ANDROID_H_ 146 #endif // CHROME_BROWSER_NET_SPDYPROXY_DATA_REDUCTION_PROXY_SETTINGS_ANDROID_H_
OLDNEW
« no previous file with comments | « chrome/browser/android/chrome_feature_list.cc ('k') | chrome/browser/net/spdyproxy/data_reduction_proxy_settings_android.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698