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

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 "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 DCHECK(net_log); 33 DCHECK(net_log);
34 DCHECK(prefs); 34 DCHECK(prefs);
35 DCHECK(browser_context);
36 DataReductionProxyChromeSettings* settings =
37 DataReductionProxyChromeSettingsFactory::GetForBrowserContext(
38 browser_context);
39 35
40 #if defined(OS_ANDROID) || defined(OS_IOS) 36 int flags = DataReductionProxyParams::kAllowed;
bengr 2015/02/20 00:00:36 nit: Combine with lines 37 and 38 to OR three flag
jeremyim 2015/02/20 02:17:16 Done.
41 // On mobile we write data reduction proxy prefs directly to the pref service. 37 flags |= DataReductionProxyParams::kFallbackAllowed |
42 // On desktop we store data reduction proxy prefs in memory, writing to disk 38 DataReductionProxyParams::kAlternativeAllowed;
43 // every 60 minutes and on termination. Shutdown hooks must be added for 39 if (DataReductionProxyParams::IsIncludedInPromoFieldTrial())
44 // Android and iOS in order for non-zero delays to be supported. 40 flags |= DataReductionProxyParams::kPromoAllowed;
45 // (http://crbug.com/408264) 41 if (DataReductionProxyParams::IsIncludedInHoldbackFieldTrial())
46 base::TimeDelta commit_delay = base::TimeDelta(); 42 flags |= DataReductionProxyParams::kHoldback;
47 #else 43 #if defined(OS_ANDROID)
48 base::TimeDelta commit_delay = base::TimeDelta::FromMinutes(60); 44 if (DataReductionProxyParams::IsIncludedInAndroidOnePromoFieldTrial(
45 base::android::BuildInfo::GetInstance()->android_build_fp())) {
46 flags |= DataReductionProxyParams::kPromoAllowed;
47 }
49 #endif 48 #endif
50 49
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> 50 scoped_ptr<data_reduction_proxy::DataReductionProxyIOData>
57 data_reduction_proxy_io_data( 51 data_reduction_proxy_io_data(
58 new data_reduction_proxy::DataReductionProxyIOData( 52 new data_reduction_proxy::DataReductionProxyIOData(
59 DataReductionProxyChromeSettings::GetClient(), 53 DataReductionProxyChromeSettings::GetClient(), flags, net_log,
60 make_scoped_ptr(data_reduction_proxy_statistics_prefs), 54 io_task_runner, ui_task_runner));
61 settings,
62 net_log,
63 io_task_runner,
64 ui_task_runner));
65 data_reduction_proxy_io_data->InitOnUIThread(prefs); 55 data_reduction_proxy_io_data->InitOnUIThread(prefs);
66 56
67 #if defined(ENABLE_DATA_REDUCTION_PROXY_DEBUGGING) 57 #if defined(ENABLE_DATA_REDUCTION_PROXY_DEBUGGING)
68 scoped_ptr<data_reduction_proxy::ContentDataReductionProxyDebugUIService> 58 scoped_ptr<data_reduction_proxy::ContentDataReductionProxyDebugUIService>
69 data_reduction_proxy_ui_service( 59 data_reduction_proxy_ui_service(
70 new data_reduction_proxy::ContentDataReductionProxyDebugUIService( 60 new data_reduction_proxy::ContentDataReductionProxyDebugUIService(
71 base::Bind(&data_reduction_proxy::DataReductionProxyConfigurator:: 61 base::Bind(&data_reduction_proxy::DataReductionProxyConfigurator::
72 GetProxyConfigOnIOThread, 62 GetProxyConfigOnIOThread,
73 base::Unretained( 63 base::Unretained(
74 data_reduction_proxy_io_data->configurator())), 64 data_reduction_proxy_io_data->configurator())),
75 ui_task_runner, io_task_runner, 65 ui_task_runner, io_task_runner,
76 g_browser_process->GetApplicationLocale())); 66 g_browser_process->GetApplicationLocale()));
77 data_reduction_proxy_io_data->set_debug_ui_service( 67 data_reduction_proxy_io_data->set_debug_ui_service(
78 data_reduction_proxy_ui_service.Pass()); 68 data_reduction_proxy_ui_service.Pass());
79 #endif 69 #endif
80 70
81 return data_reduction_proxy_io_data.Pass(); 71 return data_reduction_proxy_io_data.Pass();
82 } 72 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698