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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_NET_SPDYPROXY_DATA_REDUCTION_PROXY_SETTINGS_ANDROID_H_
6 #define CHROME_BROWSER_NET_SPDYPROXY_DATA_REDUCTION_PROXY_SETTINGS_ANDROID_H_
8 #include "base/android/jni_string.h"
9 #include "base/android/jni_weak_ref.h"
10 #include "base/android/scoped_java_ref.h"
11 #include "base/basictypes.h"
12 #include "base/compiler_specific.h"
13 #include "base/gtest_prod_util.h"
14 #include "base/memory/scoped_ptr.h"
15 #include "base/prefs/pref_member.h"
17 using base::android::ScopedJavaLocalRef
;
21 namespace data_reduction_proxy
{
22 class DataReductionProxySettings
;
25 // Central point for configuring the data reduction proxy on Android.
26 // This object lives on the UI thread and all of its methods are expected to
27 // be called from there.
28 class DataReductionProxySettingsAndroid
{
30 DataReductionProxySettingsAndroid();
32 virtual ~DataReductionProxySettingsAndroid();
34 void InitDataReductionProxySettings(Profile
* profile
);
36 // JNI wrapper interfaces to the indentically-named superclass methods.
37 jboolean
IsDataReductionProxyAllowed(JNIEnv
* env
, jobject obj
);
38 jboolean
IsDataReductionProxyPromoAllowed(JNIEnv
* env
, jobject obj
);
39 jboolean
IsIncludedInAltFieldTrial(JNIEnv
* env
, jobject obj
);
40 jboolean
IsDataReductionProxyEnabled(JNIEnv
* env
, jobject obj
);
41 jboolean
IsDataReductionProxyManaged(JNIEnv
* env
, jobject obj
);
42 void SetDataReductionProxyEnabled(JNIEnv
* env
, jobject obj
, jboolean enabled
);
44 jlong
GetDataReductionLastUpdateTime(JNIEnv
* env
, jobject obj
);
45 ScopedJavaLocalRef
<jlongArray
> GetDailyOriginalContentLengths(JNIEnv
* env
,
47 ScopedJavaLocalRef
<jlongArray
> GetDailyReceivedContentLengths(JNIEnv
* env
,
50 // Return a Java |ContentLengths| object wrapping the results of a call to
51 // DataReductionProxySettings::GetContentLengths.
52 base::android::ScopedJavaLocalRef
<jobject
> GetContentLengths(JNIEnv
* env
,
55 // Determines whether the data reduction proxy is unreachable. This is
56 // done by keeping a count of requests which go through proxy vs those
57 // which should have gone through the proxy based on the config.
58 jboolean
IsDataReductionProxyUnreachable(JNIEnv
* env
, jobject obj
);
60 ScopedJavaLocalRef
<jstring
> GetTokenForAuthChallenge(JNIEnv
* env
,
65 // Registers the native methods to be call from Java.
66 static bool Register(JNIEnv
* env
);
69 friend class DataReductionProxySettingsAndroidTest
;
70 FRIEND_TEST_ALL_PREFIXES(DataReductionProxySettingsAndroidTest
,
71 TestGetDailyContentLengths
);
74 ScopedJavaLocalRef
<jlongArray
> GetDailyContentLengths(JNIEnv
* env
,
75 const char* pref_name
);
77 virtual data_reduction_proxy::DataReductionProxySettings
* Settings();
79 DISALLOW_COPY_AND_ASSIGN(DataReductionProxySettingsAndroid
);
82 #endif // CHROME_BROWSER_NET_SPDYPROXY_DATA_REDUCTION_PROXY_SETTINGS_ANDROID_H_