OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 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 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_io_data.h" | 5 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_io_data.h" |
6 | 6 |
7 #include "base/bind.h" | |
8 #include "base/prefs/pref_service.h" | |
9 #include "base/time/time.h" | |
10 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings.h" | 7 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings.h" |
11 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings_fact
ory.h" | |
12 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_conf
igurator.h" | |
13 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_io_d
ata.h" | 8 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_io_d
ata.h" |
14 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_stat
istics_prefs.h" | 9 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_param
s.h" |
15 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_event
_store.h" | 10 |
| 11 #if defined(OS_ANDROID) |
| 12 #include "base/android/build_info.h" |
| 13 #endif |
16 | 14 |
17 #if defined(ENABLE_DATA_REDUCTION_PROXY_DEBUGGING) | 15 #if defined(ENABLE_DATA_REDUCTION_PROXY_DEBUGGING) |
18 #include "chrome/browser/browser_process.h" | 16 #include "chrome/browser/browser_process.h" |
19 #include "components/data_reduction_proxy/content/browser/content_data_reduction
_proxy_debug_ui_service.h" | 17 #include "components/data_reduction_proxy/content/browser/content_data_reduction
_proxy_debug_ui_service.h" |
| 18 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_conf
igurator.h" |
20 #endif | 19 #endif |
21 | 20 |
22 namespace content { | 21 namespace content { |
23 class BrowserContext; | 22 class BrowserContext; |
24 } | 23 } |
25 | 24 |
| 25 using data_reduction_proxy::DataReductionProxyParams; |
| 26 |
26 scoped_ptr<data_reduction_proxy::DataReductionProxyIOData> | 27 scoped_ptr<data_reduction_proxy::DataReductionProxyIOData> |
27 CreateDataReductionProxyChromeIOData( | 28 CreateDataReductionProxyChromeIOData( |
28 net::NetLog* net_log, | 29 net::NetLog* net_log, |
29 content::BrowserContext* browser_context, | |
30 PrefService* prefs, | 30 PrefService* prefs, |
31 const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner, | 31 const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner, |
32 const scoped_refptr<base::SingleThreadTaskRunner>& ui_task_runner) { | 32 const scoped_refptr<base::SingleThreadTaskRunner>& ui_task_runner, |
| 33 bool enable_quic) { |
33 DCHECK(net_log); | 34 DCHECK(net_log); |
34 DCHECK(prefs); | 35 DCHECK(prefs); |
35 DCHECK(browser_context); | |
36 DataReductionProxyChromeSettings* settings = | |
37 DataReductionProxyChromeSettingsFactory::GetForBrowserContext( | |
38 browser_context); | |
39 | 36 |
40 #if defined(OS_ANDROID) || defined(OS_IOS) | 37 int flags = DataReductionProxyParams::kAllowed | |
41 // On mobile we write data reduction proxy prefs directly to the pref service. | 38 DataReductionProxyParams::kFallbackAllowed | |
42 // On desktop we store data reduction proxy prefs in memory, writing to disk | 39 DataReductionProxyParams::kAlternativeAllowed; |
43 // every 60 minutes and on termination. Shutdown hooks must be added for | 40 if (DataReductionProxyParams::IsIncludedInPromoFieldTrial()) |
44 // Android and iOS in order for non-zero delays to be supported. | 41 flags |= DataReductionProxyParams::kPromoAllowed; |
45 // (http://crbug.com/408264) | 42 if (DataReductionProxyParams::IsIncludedInHoldbackFieldTrial()) |
46 base::TimeDelta commit_delay = base::TimeDelta(); | 43 flags |= DataReductionProxyParams::kHoldback; |
47 #else | 44 #if defined(OS_ANDROID) |
48 base::TimeDelta commit_delay = base::TimeDelta::FromMinutes(60); | 45 if (DataReductionProxyParams::IsIncludedInAndroidOnePromoFieldTrial( |
| 46 base::android::BuildInfo::GetInstance()->android_build_fp())) { |
| 47 flags |= DataReductionProxyParams::kPromoAllowed; |
| 48 } |
49 #endif | 49 #endif |
50 | 50 |
51 data_reduction_proxy::DataReductionProxyStatisticsPrefs* | |
52 data_reduction_proxy_statistics_prefs = | |
53 new data_reduction_proxy::DataReductionProxyStatisticsPrefs( | |
54 prefs, ui_task_runner, commit_delay); | |
55 | |
56 scoped_ptr<data_reduction_proxy::DataReductionProxyIOData> | 51 scoped_ptr<data_reduction_proxy::DataReductionProxyIOData> |
57 data_reduction_proxy_io_data( | 52 data_reduction_proxy_io_data( |
58 new data_reduction_proxy::DataReductionProxyIOData( | 53 new data_reduction_proxy::DataReductionProxyIOData( |
59 DataReductionProxyChromeSettings::GetClient(), | 54 DataReductionProxyChromeSettings::GetClient(), flags, net_log, |
60 make_scoped_ptr(data_reduction_proxy_statistics_prefs), | 55 io_task_runner, ui_task_runner, enable_quic)); |
61 settings, | |
62 net_log, | |
63 io_task_runner, | |
64 ui_task_runner)); | |
65 data_reduction_proxy_io_data->InitOnUIThread(prefs); | 56 data_reduction_proxy_io_data->InitOnUIThread(prefs); |
66 | 57 |
67 #if defined(ENABLE_DATA_REDUCTION_PROXY_DEBUGGING) | 58 #if defined(ENABLE_DATA_REDUCTION_PROXY_DEBUGGING) |
68 scoped_ptr<data_reduction_proxy::ContentDataReductionProxyDebugUIService> | 59 scoped_ptr<data_reduction_proxy::ContentDataReductionProxyDebugUIService> |
69 data_reduction_proxy_ui_service( | 60 data_reduction_proxy_ui_service( |
70 new data_reduction_proxy::ContentDataReductionProxyDebugUIService( | 61 new data_reduction_proxy::ContentDataReductionProxyDebugUIService( |
71 base::Bind(&data_reduction_proxy::DataReductionProxyConfigurator:: | 62 base::Bind(&data_reduction_proxy::DataReductionProxyConfigurator:: |
72 GetProxyConfigOnIOThread, | 63 GetProxyConfigOnIOThread, |
73 base::Unretained( | 64 base::Unretained( |
74 data_reduction_proxy_io_data->configurator())), | 65 data_reduction_proxy_io_data->configurator())), |
75 ui_task_runner, io_task_runner, | 66 ui_task_runner, io_task_runner, |
76 g_browser_process->GetApplicationLocale())); | 67 g_browser_process->GetApplicationLocale())); |
77 data_reduction_proxy_io_data->set_debug_ui_service( | 68 data_reduction_proxy_io_data->set_debug_ui_service( |
78 data_reduction_proxy_ui_service.Pass()); | 69 data_reduction_proxy_ui_service.Pass()); |
79 #endif | 70 #endif |
80 | 71 |
81 return data_reduction_proxy_io_data.Pass(); | 72 return data_reduction_proxy_io_data.Pass(); |
82 } | 73 } |
OLD | NEW |