OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/autofill/browser/autofill_download.h" | 5 #include "components/autofill/browser/autofill_download.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <ostream> | 8 #include <ostream> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 Observer* observer) | 73 Observer* observer) |
74 : browser_context_(context), | 74 : browser_context_(context), |
75 observer_(observer), | 75 observer_(observer), |
76 max_form_cache_size_(kMaxFormCacheSize), | 76 max_form_cache_size_(kMaxFormCacheSize), |
77 next_query_request_(base::Time::Now()), | 77 next_query_request_(base::Time::Now()), |
78 next_upload_request_(base::Time::Now()), | 78 next_upload_request_(base::Time::Now()), |
79 positive_upload_rate_(0), | 79 positive_upload_rate_(0), |
80 negative_upload_rate_(0), | 80 negative_upload_rate_(0), |
81 fetcher_id_for_unittest_(0) { | 81 fetcher_id_for_unittest_(0) { |
82 DCHECK(observer_); | 82 DCHECK(observer_); |
83 PrefService* preferences = components::UserPrefs::Get(browser_context_); | 83 PrefService* preferences = user_prefs::UserPrefs::Get(browser_context_); |
84 positive_upload_rate_ = | 84 positive_upload_rate_ = |
85 preferences->GetDouble(prefs::kAutofillPositiveUploadRate); | 85 preferences->GetDouble(prefs::kAutofillPositiveUploadRate); |
86 negative_upload_rate_ = | 86 negative_upload_rate_ = |
87 preferences->GetDouble(prefs::kAutofillNegativeUploadRate); | 87 preferences->GetDouble(prefs::kAutofillNegativeUploadRate); |
88 } | 88 } |
89 | 89 |
90 AutofillDownloadManager::~AutofillDownloadManager() { | 90 AutofillDownloadManager::~AutofillDownloadManager() { |
91 STLDeleteContainerPairFirstPointers(url_fetchers_.begin(), | 91 STLDeleteContainerPairFirstPointers(url_fetchers_.begin(), |
92 url_fetchers_.end()); | 92 url_fetchers_.end()); |
93 } | 93 } |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 double AutofillDownloadManager::GetNegativeUploadRate() const { | 163 double AutofillDownloadManager::GetNegativeUploadRate() const { |
164 return negative_upload_rate_; | 164 return negative_upload_rate_; |
165 } | 165 } |
166 | 166 |
167 void AutofillDownloadManager::SetPositiveUploadRate(double rate) { | 167 void AutofillDownloadManager::SetPositiveUploadRate(double rate) { |
168 if (rate == positive_upload_rate_) | 168 if (rate == positive_upload_rate_) |
169 return; | 169 return; |
170 positive_upload_rate_ = rate; | 170 positive_upload_rate_ = rate; |
171 DCHECK_GE(rate, 0.0); | 171 DCHECK_GE(rate, 0.0); |
172 DCHECK_LE(rate, 1.0); | 172 DCHECK_LE(rate, 1.0); |
173 PrefService* preferences = components::UserPrefs::Get(browser_context_); | 173 PrefService* preferences = user_prefs::UserPrefs::Get(browser_context_); |
174 preferences->SetDouble(prefs::kAutofillPositiveUploadRate, rate); | 174 preferences->SetDouble(prefs::kAutofillPositiveUploadRate, rate); |
175 } | 175 } |
176 | 176 |
177 void AutofillDownloadManager::SetNegativeUploadRate(double rate) { | 177 void AutofillDownloadManager::SetNegativeUploadRate(double rate) { |
178 if (rate == negative_upload_rate_) | 178 if (rate == negative_upload_rate_) |
179 return; | 179 return; |
180 negative_upload_rate_ = rate; | 180 negative_upload_rate_ = rate; |
181 DCHECK_GE(rate, 0.0); | 181 DCHECK_GE(rate, 0.0); |
182 DCHECK_LE(rate, 1.0); | 182 DCHECK_LE(rate, 1.0); |
183 PrefService* preferences = components::UserPrefs::Get(browser_context_); | 183 PrefService* preferences = user_prefs::UserPrefs::Get(browser_context_); |
184 preferences->SetDouble(prefs::kAutofillNegativeUploadRate, rate); | 184 preferences->SetDouble(prefs::kAutofillNegativeUploadRate, rate); |
185 } | 185 } |
186 | 186 |
187 bool AutofillDownloadManager::StartRequest( | 187 bool AutofillDownloadManager::StartRequest( |
188 const std::string& form_xml, | 188 const std::string& form_xml, |
189 const FormRequestData& request_data) { | 189 const FormRequestData& request_data) { |
190 net::URLRequestContextGetter* request_context = | 190 net::URLRequestContextGetter* request_context = |
191 browser_context_->GetRequestContext(); | 191 browser_context_->GetRequestContext(); |
192 DCHECK(request_context); | 192 DCHECK(request_context); |
193 GURL request_url; | 193 GURL request_url; |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
343 } | 343 } |
344 | 344 |
345 observer_->OnUploadedPossibleFieldTypes(); | 345 observer_->OnUploadedPossibleFieldTypes(); |
346 } | 346 } |
347 } | 347 } |
348 delete it->first; | 348 delete it->first; |
349 url_fetchers_.erase(it); | 349 url_fetchers_.erase(it); |
350 } | 350 } |
351 | 351 |
352 } // namespace autofill | 352 } // namespace autofill |
OLD | NEW |