1 // Copyright 2015 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 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_io_data.h"
7 #include "base/prefs/pref_service.h"
8 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings.h"
9 #include "chrome/common/chrome_content_client.h"
10 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_config_retrieval_params.h"
11 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_experiments_stats.h"
12 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_io_data.h"
13 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_params.h"
14 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_pref_names.h"
16 #if defined(OS_ANDROID)
17 #include "base/android/build_info.h"
20 #if defined(ENABLE_DATA_REDUCTION_PROXY_DEBUGGING)
21 #include "chrome/browser/browser_process.h"
22 #include "components/data_reduction_proxy/content/browser/content_data_reduction_proxy_debug_ui_service.h"
23 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_configurator.h"
30 using data_reduction_proxy::DataReductionProxyParams
;
32 scoped_ptr
<data_reduction_proxy::DataReductionProxyIOData
>
33 CreateDataReductionProxyChromeIOData(
36 const scoped_refptr
<base::SingleThreadTaskRunner
>& io_task_runner
,
37 const scoped_refptr
<base::SingleThreadTaskRunner
>& ui_task_runner
,
42 int flags
= DataReductionProxyParams::kAllowed
|
43 DataReductionProxyParams::kFallbackAllowed
|
44 DataReductionProxyParams::kAlternativeAllowed
;
45 if (data_reduction_proxy::params::IsIncludedInPromoFieldTrial())
46 flags
|= DataReductionProxyParams::kPromoAllowed
;
47 if (data_reduction_proxy::params::IsIncludedInHoldbackFieldTrial())
48 flags
|= DataReductionProxyParams::kHoldback
;
49 #if defined(OS_ANDROID)
50 if (data_reduction_proxy::params::IsIncludedInAndroidOnePromoFieldTrial(
51 base::android::BuildInfo::GetInstance()->android_build_fp())) {
52 flags
|= DataReductionProxyParams::kPromoAllowed
;
58 data_reduction_proxy::prefs::kDataReductionProxyEnabled
) ||
59 data_reduction_proxy::params::ShouldForceEnableDataReductionProxy();
60 scoped_ptr
<data_reduction_proxy::DataReductionProxyIOData
>
61 data_reduction_proxy_io_data(
62 new data_reduction_proxy::DataReductionProxyIOData(
63 DataReductionProxyChromeSettings::GetClient(), flags
, net_log
,
64 io_task_runner
, ui_task_runner
, enabled
, enable_quic
,
66 data_reduction_proxy_io_data
->experiments_stats()->InitializeOnUIThread(
67 data_reduction_proxy::DataReductionProxyConfigRetrievalParams::Create(
70 #if defined(ENABLE_DATA_REDUCTION_PROXY_DEBUGGING)
71 scoped_ptr
<data_reduction_proxy::ContentDataReductionProxyDebugUIService
>
72 data_reduction_proxy_ui_service(
73 new data_reduction_proxy::ContentDataReductionProxyDebugUIService(
74 base::Bind(&data_reduction_proxy::DataReductionProxyConfigurator::
77 data_reduction_proxy_io_data
->configurator())),
78 ui_task_runner
, io_task_runner
,
79 g_browser_process
->GetApplicationLocale()));
80 data_reduction_proxy_io_data
->set_debug_ui_service(
81 data_reduction_proxy_ui_service
.Pass());
84 return data_reduction_proxy_io_data
.Pass();