summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbengr <bengr@chromium.org>2015-05-14 19:06:57 -0700
committerCommit bot <commit-bot@chromium.org>2015-05-15 02:07:10 +0000
commit319828dc0983cac3a7c77eb9dc1fdf6c4bf1e569 (patch)
tree85bbc684af129461ad87cbc15d3e80777764315b
parenta20d1d5f8a763eed8adbe080811e7b4777578f9d (diff)
downloadchromium_src-319828dc0983cac3a7c77eb9dc1fdf6c4bf1e569.zip
chromium_src-319828dc0983cac3a7c77eb9dc1fdf6c4bf1e569.tar.gz
chromium_src-319828dc0983cac3a7c77eb9dc1fdf6c4bf1e569.tar.bz2
Put Data Reduction Proxy support in Cronet behind a gyp flag
Compile the Data Reduction Proxy into Cronet only if the gyp variable enable_data_reduction_proxy_support is set to 1. By default, it is set to 0. BUG=461910 Review URL: https://codereview.chromium.org/1112513003 Cr-Commit-Position: refs/heads/master@{#330021}
-rw-r--r--components/cronet.gypi32
-rw-r--r--components/cronet/android/cronet_url_request_context_adapter.cc9
-rw-r--r--components/cronet/android/cronet_url_request_context_adapter.h6
-rw-r--r--components/cronet/android/test/javatests/src/org/chromium/net/CronetUrlRequestContextTest.java4
-rw-r--r--components/cronet/android/test/native_test_server.cc8
-rw-r--r--components/cronet/android/test/src/org/chromium/net/NativeTestServer.java5
-rw-r--r--components/cronet/cronet_static.gypi18
7 files changed, 76 insertions, 6 deletions
diff --git a/components/cronet.gypi b/components/cronet.gypi
index e962ac0..977aa27 100644
--- a/components/cronet.gypi
+++ b/components/cronet.gypi
@@ -108,20 +108,36 @@
'DISABLE_FTP_SUPPORT=1',
],
'dependencies': [
- '../components/components.gyp:data_reduction_proxy_core_browser_small',
'../net/net.gyp:net_small',
],
'includes': [ 'cronet/cronet_static.gypi' ],
+ 'conditions': [
+ ['enable_data_reduction_proxy_support==1',
+ {
+ 'dependencies': [
+ '../components/components.gyp:data_reduction_proxy_core_browser_small',
+ ],
+ },
+ ],
+ ],
},
{
# cronet_static target depends on ICU and includes file and ftp support.
'target_name': 'cronet_static',
'dependencies': [
'../base/base.gyp:base_i18n',
- '../components/components.gyp:data_reduction_proxy_core_browser',
'../net/net.gyp:net',
],
'includes': [ 'cronet/cronet_static.gypi' ],
+ 'conditions': [
+ ['enable_data_reduction_proxy_support==1',
+ {
+ 'dependencies': [
+ '../components/components.gyp:data_reduction_proxy_core_browser',
+ ],
+ },
+ ],
+ ],
},
{
'target_name': 'libcronet',
@@ -303,6 +319,15 @@
'../third_party/icu/icu.gyp:icui18n',
'../third_party/icu/icu.gyp:icuuc',
],
+ 'conditions' : [
+ ['enable_data_reduction_proxy_support==1',
+ {
+ 'defines' : [
+ 'DATA_REDUCTION_PROXY_SUPPORT'
+ ],
+ },
+ ],
+ ],
},
{
'target_name': 'cronet_test_apk',
@@ -473,6 +498,9 @@
],
},
],
+ 'variables': {
+ 'enable_data_reduction_proxy_support%': 0,
+ },
}], # OS=="android"
],
}
diff --git a/components/cronet/android/cronet_url_request_context_adapter.cc b/components/cronet/android/cronet_url_request_context_adapter.cc
index 7863b2b..2f736a9 100644
--- a/components/cronet/android/cronet_url_request_context_adapter.cc
+++ b/components/cronet/android/cronet_url_request_context_adapter.cc
@@ -13,7 +13,6 @@
#include "base/memory/scoped_vector.h"
#include "base/single_thread_task_runner.h"
#include "base/values.h"
-#include "components/cronet/android/cronet_data_reduction_proxy.h"
#include "components/cronet/url_request_context_config.h"
#include "jni/CronetUrlRequestContext_jni.h"
#include "net/base/load_flags.h"
@@ -27,6 +26,10 @@
#include "net/url_request/url_request_context_builder.h"
#include "net/url_request/url_request_interceptor.h"
+#if defined(DATA_REDUCTION_PROXY_SUPPORT)
+#include "components/cronet/android/cronet_data_reduction_proxy.h"
+#endif
+
namespace {
class BasicNetworkDelegate : public net::NetworkDelegateImpl {
@@ -157,6 +160,7 @@ void CronetURLRequestContextAdapter::InitializeOnNetworkThread(
scoped_ptr<net::NetLog> net_log(new net::NetLog);
scoped_ptr<net::NetworkDelegate> network_delegate(new BasicNetworkDelegate());
+#if defined(DATA_REDUCTION_PROXY_SUPPORT)
DCHECK(!data_reduction_proxy_);
// For now, the choice to enable the data reduction proxy happens once,
// at initialization. It cannot be disabled thereafter.
@@ -176,6 +180,7 @@ void CronetURLRequestContextAdapter::InitializeOnNetworkThread(
interceptors.push_back(data_reduction_proxy_->CreateInterceptor());
context_builder.SetInterceptors(interceptors.Pass());
}
+#endif // defined(DATA_REDUCTION_PROXY_SUPPORT)
context_builder.set_network_delegate(network_delegate.release());
context_builder.set_net_log(net_log.release());
context_builder.set_proxy_config_service(proxy_config_service_.release());
@@ -241,8 +246,10 @@ void CronetURLRequestContextAdapter::InitializeOnNetworkThread(
Java_CronetUrlRequestContext_initNetworkThread(
env, jcronet_url_request_context.obj());
+#if defined(DATA_REDUCTION_PROXY_SUPPORT)
if (data_reduction_proxy_)
data_reduction_proxy_->Init(true, GetURLRequestContext());
+#endif
is_context_initialized_ = true;
while (!tasks_waiting_for_context_.empty()) {
tasks_waiting_for_context_.front().Run();
diff --git a/components/cronet/android/cronet_url_request_context_adapter.h b/components/cronet/android/cronet_url_request_context_adapter.h
index e94a782..6366c5d 100644
--- a/components/cronet/android/cronet_url_request_context_adapter.h
+++ b/components/cronet/android/cronet_url_request_context_adapter.h
@@ -30,7 +30,10 @@ class SdchOwner;
namespace cronet {
+#if defined(DATA_REDUCTION_PROXY_SUPPORT)
class CronetDataReductionProxy;
+#endif
+
struct URLRequestContextConfig;
bool CronetUrlRequestContextAdapterRegisterJni(JNIEnv* env);
@@ -104,7 +107,10 @@ class CronetURLRequestContextAdapter {
std::queue<base::Closure> tasks_waiting_for_context_;
bool is_context_initialized_;
int default_load_flags_;
+
+#if defined(DATA_REDUCTION_PROXY_SUPPORT)
scoped_ptr<CronetDataReductionProxy> data_reduction_proxy_;
+#endif
DISALLOW_COPY_AND_ASSIGN(CronetURLRequestContextAdapter);
};
diff --git a/components/cronet/android/test/javatests/src/org/chromium/net/CronetUrlRequestContextTest.java b/components/cronet/android/test/javatests/src/org/chromium/net/CronetUrlRequestContextTest.java
index c69a88a..d4c4a6b 100644
--- a/components/cronet/android/test/javatests/src/org/chromium/net/CronetUrlRequestContextTest.java
+++ b/components/cronet/android/test/javatests/src/org/chromium/net/CronetUrlRequestContextTest.java
@@ -116,7 +116,9 @@ public class CronetUrlRequestContextTest extends CronetTestBase {
assertTrue(NativeTestServer.startNativeTestServer(
getInstrumentation().getTargetContext()));
-
+ if (!NativeTestServer.isDataReductionProxySupported()) {
+ return;
+ }
String serverHostPort = NativeTestServer.getHostPort();
// Enable the Data Reduction Proxy and configure it to use the test
diff --git a/components/cronet/android/test/native_test_server.cc b/components/cronet/android/test/native_test_server.cc
index 88f150f..9003b64 100644
--- a/components/cronet/android/test/native_test_server.cc
+++ b/components/cronet/android/test/native_test_server.cc
@@ -306,6 +306,14 @@ jstring GetHostPort(JNIEnv* env, jclass jcaller) {
return base::android::ConvertUTF8ToJavaString(env, host_port).Release();
}
+jboolean IsDataReductionProxySupported(JNIEnv* env, jclass jcaller) {
+#if defined(DATA_REDUCTION_PROXY_SUPPORT)
+ return JNI_TRUE;
+#else
+ return JNI_FALSE;
+#endif
+}
+
bool RegisterNativeTestServer(JNIEnv* env) {
return RegisterNativesImpl(env);
}
diff --git a/components/cronet/android/test/src/org/chromium/net/NativeTestServer.java b/components/cronet/android/test/src/org/chromium/net/NativeTestServer.java
index 9c80c26..9be7a3b 100644
--- a/components/cronet/android/test/src/org/chromium/net/NativeTestServer.java
+++ b/components/cronet/android/test/src/org/chromium/net/NativeTestServer.java
@@ -95,6 +95,10 @@ public final class NativeTestServer {
return nativeGetHostPort();
}
+ public static boolean isDataReductionProxySupported() {
+ return nativeIsDataReductionProxySupported();
+ }
+
@CalledByNative
private static void onHostResolverProcRegistered() {
sHostResolverBlock.open();
@@ -112,4 +116,5 @@ public final class NativeTestServer {
private static native String nativeGetFileURL(String filePath);
private static native String nativeGetSdchURL();
private static native String nativeGetHostPort();
+ private static native boolean nativeIsDataReductionProxySupported();
}
diff --git a/components/cronet/cronet_static.gypi b/components/cronet/cronet_static.gypi
index fa0d983..bad92fb 100644
--- a/components/cronet/cronet_static.gypi
+++ b/components/cronet/cronet_static.gypi
@@ -21,8 +21,6 @@
'android/chromium_url_request_context.h',
'android/chromium_url_request_error_list.h',
'android/chromium_url_request_priority_list.h',
- 'android/cronet_data_reduction_proxy.cc',
- 'android/cronet_data_reduction_proxy.h',
'android/cronet_histogram_manager.cc',
'android/cronet_histogram_manager.h',
'android/cronet_in_memory_pref_store.cc',
@@ -65,4 +63,20 @@
'-Wl,--gc-sections',
'-Wl,--exclude-libs,ALL'
],
+ 'conditions': [
+ # If Data Reduction Proxy support is enabled, add the following
+ # defines and sources. Dependencies are target-specific and are
+ # not included here.
+ ['enable_data_reduction_proxy_support==1',
+ {
+ 'defines' : [
+ 'DATA_REDUCTION_PROXY_SUPPORT'
+ ],
+ 'sources': [
+ 'android/cronet_data_reduction_proxy.cc',
+ 'android/cronet_data_reduction_proxy.h',
+ ],
+ }
+ ],
+ ],
}