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 if (data_reduction_proxy::params::IsIncludedInPromoFieldTrial())
45 flags
|= DataReductionProxyParams::kPromoAllowed
;
46 if (data_reduction_proxy::params::IsIncludedInHoldbackFieldTrial())
47 flags
|= DataReductionProxyParams::kHoldback
;
48 #if defined(OS_ANDROID)
49 if (data_reduction_proxy::params::IsIncludedInAndroidOnePromoFieldTrial(
50 base::android::BuildInfo::GetInstance()->android_build_fp())) {
51 flags
|= DataReductionProxyParams::kPromoAllowed
;
57 data_reduction_proxy::prefs::kDataReductionProxyEnabled
) ||
58 data_reduction_proxy::params::ShouldForceEnableDataReductionProxy();
59 scoped_ptr
<data_reduction_proxy::DataReductionProxyIOData
>
60 data_reduction_proxy_io_data(
61 new data_reduction_proxy::DataReductionProxyIOData(
62 DataReductionProxyChromeSettings::GetClient(), flags
, net_log
,
63 io_task_runner
, ui_task_runner
, enabled
, enable_quic
,
65 data_reduction_proxy_io_data
->experiments_stats()->InitializeOnUIThread(
66 data_reduction_proxy::DataReductionProxyConfigRetrievalParams::Create(
69 #if defined(ENABLE_DATA_REDUCTION_PROXY_DEBUGGING)
70 scoped_ptr
<data_reduction_proxy::ContentDataReductionProxyDebugUIService
>
71 data_reduction_proxy_ui_service(
72 new data_reduction_proxy::ContentDataReductionProxyDebugUIService(
73 base::Bind(&data_reduction_proxy::DataReductionProxyConfigurator::
76 data_reduction_proxy_io_data
->configurator())),
77 ui_task_runner
, io_task_runner
,
78 g_browser_process
->GetApplicationLocale()));
79 data_reduction_proxy_io_data
->set_debug_ui_service(
80 data_reduction_proxy_ui_service
.Pass());
83 return data_reduction_proxy_io_data
.Pass();