Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(501)

Side by Side Diff: chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_io_data.cc

Issue 893003002: Data Reduction Proxy class ownership updates and Settings cleanup (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "components/data_reduction_proxy/content/browser/content_data_reduction _proxy_debug_ui_service.h" 16 #include "components/data_reduction_proxy/content/browser/content_data_reduction _proxy_debug_ui_service.h"
17 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_conf igurator.h"
19 #endif 18 #endif
20 19
21 namespace content { 20 namespace content {
22 class BrowserContext; 21 class BrowserContext;
23 } 22 }
24 23
24 using data_reduction_proxy::DataReductionProxyParams;
25
25 scoped_ptr<data_reduction_proxy::DataReductionProxyIOData> 26 scoped_ptr<data_reduction_proxy::DataReductionProxyIOData>
26 CreateDataReductionProxyChromeIOData( 27 CreateDataReductionProxyChromeIOData(
27 net::NetLog* net_log, 28 net::NetLog* net_log,
28 content::BrowserContext* browser_context,
29 PrefService* prefs, 29 PrefService* prefs,
30 const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner, 30 const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner,
31 const scoped_refptr<base::SingleThreadTaskRunner>& ui_task_runner) { 31 const scoped_refptr<base::SingleThreadTaskRunner>& ui_task_runner) {
32 DCHECK(net_log); 32 DCHECK(net_log);
33 DCHECK(prefs); 33 DCHECK(prefs);
34 DCHECK(browser_context);
35 DataReductionProxyChromeSettings* settings =
36 DataReductionProxyChromeSettingsFactory::GetForBrowserContext(
37 browser_context);
38 34
39 #if defined(OS_ANDROID) || defined(OS_IOS) 35 int flags = DataReductionProxyParams::kAllowed;
40 // On mobile we write data reduction proxy prefs directly to the pref service. 36 flags |= DataReductionProxyParams::kFallbackAllowed |
41 // On desktop we store data reduction proxy prefs in memory, writing to disk 37 DataReductionProxyParams::kAlternativeAllowed;
42 // every 60 minutes and on termination. Shutdown hooks must be added for 38 if (DataReductionProxyParams::IsIncludedInPromoFieldTrial())
43 // Android and iOS in order for non-zero delays to be supported. 39 flags |= DataReductionProxyParams::kPromoAllowed;
44 // (http://crbug.com/408264) 40 if (DataReductionProxyParams::IsIncludedInHoldbackFieldTrial())
45 base::TimeDelta commit_delay = base::TimeDelta(); 41 flags |= DataReductionProxyParams::kHoldback;
46 #else 42 #if defined(OS_ANDROID)
47 base::TimeDelta commit_delay = base::TimeDelta::FromMinutes(60); 43 if (DataReductionProxyParams::IsIncludedInAndroidOnePromoFieldTrial(
44 base::android::BuildInfo::GetInstance()->android_build_fp())) {
45 flags |= DataReductionProxyParams::kPromoAllowed;
46 }
48 #endif 47 #endif
49 48
50 data_reduction_proxy::DataReductionProxyStatisticsPrefs*
51 data_reduction_proxy_statistics_prefs =
52 new data_reduction_proxy::DataReductionProxyStatisticsPrefs(
53 prefs, ui_task_runner, commit_delay);
54
55 scoped_ptr<data_reduction_proxy::DataReductionProxyIOData> 49 scoped_ptr<data_reduction_proxy::DataReductionProxyIOData>
56 data_reduction_proxy_io_data( 50 data_reduction_proxy_io_data(
57 new data_reduction_proxy::DataReductionProxyIOData( 51 new data_reduction_proxy::DataReductionProxyIOData(
58 DataReductionProxyChromeSettings::GetClient(), 52 DataReductionProxyChromeSettings::GetClient(), flags, net_log,
59 make_scoped_ptr(data_reduction_proxy_statistics_prefs), 53 io_task_runner, ui_task_runner));
60 settings,
61 net_log,
62 io_task_runner,
63 ui_task_runner));
64 data_reduction_proxy_io_data->InitOnUIThread(prefs); 54 data_reduction_proxy_io_data->InitOnUIThread(prefs);
65 55
66 #if defined(ENABLE_DATA_REDUCTION_PROXY_DEBUGGING) 56 #if defined(ENABLE_DATA_REDUCTION_PROXY_DEBUGGING)
67 scoped_ptr<data_reduction_proxy::ContentDataReductionProxyDebugUIService> 57 scoped_ptr<data_reduction_proxy::ContentDataReductionProxyDebugUIService>
68 data_reduction_proxy_ui_service( 58 data_reduction_proxy_ui_service(
69 new data_reduction_proxy::ContentDataReductionProxyDebugUIService( 59 new data_reduction_proxy::ContentDataReductionProxyDebugUIService(
70 base::Bind(&data_reduction_proxy::DataReductionProxyConfigurator:: 60 base::Bind(&data_reduction_proxy::DataReductionProxyConfigurator::
71 GetProxyConfigOnIOThread, 61 GetProxyConfigOnIOThread,
72 base::Unretained( 62 base::Unretained(
73 data_reduction_proxy_io_data->configurator())), 63 data_reduction_proxy_io_data->configurator())),
74 ui_task_runner, io_task_runner)); 64 ui_task_runner, io_task_runner));
75 data_reduction_proxy_io_data->set_debug_ui_service( 65 data_reduction_proxy_io_data->set_debug_ui_service(
76 data_reduction_proxy_ui_service.Pass()); 66 data_reduction_proxy_ui_service.Pass());
77 #endif 67 #endif
78 68
79 return data_reduction_proxy_io_data.Pass(); 69 return data_reduction_proxy_io_data.Pass();
80 } 70 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698