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 "components/data_reduction_proxy/core/browser/data_reduction_proxy_muta
ble_config_values.h" | 5 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_muta
ble_config_values.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_param
s.h" | 9 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_param
s.h" |
10 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_serve
r.h" | 10 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_serve
r.h" |
11 | 11 |
12 namespace data_reduction_proxy { | 12 namespace data_reduction_proxy { |
13 | 13 |
14 std::unique_ptr<DataReductionProxyMutableConfigValues> | 14 std::unique_ptr<DataReductionProxyMutableConfigValues> |
15 DataReductionProxyMutableConfigValues::CreateFromParams( | 15 DataReductionProxyMutableConfigValues::CreateFromParams( |
16 const DataReductionProxyParams* params) { | 16 const DataReductionProxyParams* params) { |
17 std::unique_ptr<DataReductionProxyMutableConfigValues> config_values( | 17 std::unique_ptr<DataReductionProxyMutableConfigValues> config_values( |
18 new DataReductionProxyMutableConfigValues()); | 18 new DataReductionProxyMutableConfigValues()); |
19 config_values->promo_allowed_ = params->promo_allowed(); | |
20 config_values->holdback_ = params->holdback(); | |
21 config_values->secure_proxy_check_url_ = params->secure_proxy_check_url(); | 19 config_values->secure_proxy_check_url_ = params->secure_proxy_check_url(); |
22 return config_values; | 20 return config_values; |
23 } | 21 } |
24 | 22 |
25 DataReductionProxyMutableConfigValues::DataReductionProxyMutableConfigValues() | 23 DataReductionProxyMutableConfigValues::DataReductionProxyMutableConfigValues() |
26 : promo_allowed_(false), | 24 : use_override_proxies_for_http_(false) { |
27 holdback_(false), | |
28 use_override_proxies_for_http_(false) { | |
29 use_override_proxies_for_http_ = | 25 use_override_proxies_for_http_ = |
30 params::GetOverrideProxiesForHttpFromCommandLine( | 26 params::GetOverrideProxiesForHttpFromCommandLine( |
31 &override_proxies_for_http_); | 27 &override_proxies_for_http_); |
32 | 28 |
33 // Constructed on the UI thread, but should be checked on the IO thread. | 29 // Constructed on the UI thread, but should be checked on the IO thread. |
34 thread_checker_.DetachFromThread(); | 30 thread_checker_.DetachFromThread(); |
35 } | 31 } |
36 | 32 |
37 DataReductionProxyMutableConfigValues:: | 33 DataReductionProxyMutableConfigValues:: |
38 ~DataReductionProxyMutableConfigValues() { | 34 ~DataReductionProxyMutableConfigValues() { |
39 } | 35 } |
40 | 36 |
41 bool DataReductionProxyMutableConfigValues::promo_allowed() const { | |
42 return promo_allowed_; | |
43 } | |
44 | |
45 bool DataReductionProxyMutableConfigValues::holdback() const { | |
46 return holdback_; | |
47 } | |
48 | |
49 const std::vector<DataReductionProxyServer>& | 37 const std::vector<DataReductionProxyServer>& |
50 DataReductionProxyMutableConfigValues::proxies_for_http() const { | 38 DataReductionProxyMutableConfigValues::proxies_for_http() const { |
51 DCHECK(thread_checker_.CalledOnValidThread()); | 39 DCHECK(thread_checker_.CalledOnValidThread()); |
52 if (use_override_proxies_for_http_ && !proxies_for_http_.empty()) { | 40 if (use_override_proxies_for_http_ && !proxies_for_http_.empty()) { |
53 // Only override the proxies if a non-empty list of proxies would have been | 41 // Only override the proxies if a non-empty list of proxies would have been |
54 // returned otherwise. This is to prevent use of the proxies when the config | 42 // returned otherwise. This is to prevent use of the proxies when the config |
55 // has been invalidated, since attempting to use a Data Reduction Proxy | 43 // has been invalidated, since attempting to use a Data Reduction Proxy |
56 // without valid credentials could cause a proxy bypass. | 44 // without valid credentials could cause a proxy bypass. |
57 return override_proxies_for_http_; | 45 return override_proxies_for_http_; |
58 } | 46 } |
(...skipping 13 matching lines...) Expand all Loading... |
72 DCHECK(thread_checker_.CalledOnValidThread()); | 60 DCHECK(thread_checker_.CalledOnValidThread()); |
73 proxies_for_http_ = proxies_for_http; | 61 proxies_for_http_ = proxies_for_http; |
74 } | 62 } |
75 | 63 |
76 void DataReductionProxyMutableConfigValues::Invalidate() { | 64 void DataReductionProxyMutableConfigValues::Invalidate() { |
77 DCHECK(thread_checker_.CalledOnValidThread()); | 65 DCHECK(thread_checker_.CalledOnValidThread()); |
78 proxies_for_http_.clear(); | 66 proxies_for_http_.clear(); |
79 } | 67 } |
80 | 68 |
81 } // namespace data_reduction_proxy | 69 } // namespace data_reduction_proxy |
OLD | NEW |