| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/autofill/autofill_download.h" | 5 #include "chrome/browser/autofill/autofill_download.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 &form_xml)) | 79 &form_xml)) |
| 80 return false; | 80 return false; |
| 81 | 81 |
| 82 request_data.request_type = AutoFillDownloadManager::REQUEST_QUERY; | 82 request_data.request_type = AutoFillDownloadManager::REQUEST_QUERY; |
| 83 metric_logger.Log(AutoFillMetrics::QUERY_SENT); | 83 metric_logger.Log(AutoFillMetrics::QUERY_SENT); |
| 84 | 84 |
| 85 return StartRequest(form_xml, request_data); | 85 return StartRequest(form_xml, request_data); |
| 86 } | 86 } |
| 87 | 87 |
| 88 bool AutoFillDownloadManager::StartUploadRequest( | 88 bool AutoFillDownloadManager::StartUploadRequest( |
| 89 const FormStructure& form, bool form_was_matched) { | 89 const FormStructure& form, bool form_was_matched, |
| 90 char const* present_data) { |
| 90 if (next_upload_request_ > base::Time::Now()) { | 91 if (next_upload_request_ > base::Time::Now()) { |
| 91 // We are in back-off mode: do not do the request. | 92 // We are in back-off mode: do not do the request. |
| 92 return false; | 93 return false; |
| 93 } | 94 } |
| 94 | 95 |
| 95 // Check if we need to upload form. | 96 // Check if we need to upload form. |
| 96 double upload_rate = form_was_matched ? GetPositiveUploadRate() : | 97 double upload_rate = form_was_matched ? GetPositiveUploadRate() : |
| 97 GetNegativeUploadRate(); | 98 GetNegativeUploadRate(); |
| 98 if (base::RandDouble() > upload_rate) { | 99 if (base::RandDouble() > upload_rate) { |
| 99 VLOG(1) << "AutoFillDownloadManager: Upload request is ignored"; | 100 VLOG(1) << "AutoFillDownloadManager: Upload request is ignored"; |
| 100 // If we ever need notification that upload was skipped, add it here. | 101 // If we ever need notification that upload was skipped, add it here. |
| 101 return false; | 102 return false; |
| 102 } | 103 } |
| 103 std::string form_xml; | 104 std::string form_xml; |
| 104 if (!form.EncodeUploadRequest(form_was_matched, &form_xml)) | 105 if (!form.EncodeUploadRequest(form_was_matched, present_data, &form_xml)) |
| 105 return false; | 106 return false; |
| 106 | 107 |
| 107 FormRequestData request_data; | 108 FormRequestData request_data; |
| 108 request_data.form_signatures.push_back(form.FormSignature()); | 109 request_data.form_signatures.push_back(form.FormSignature()); |
| 109 request_data.request_type = AutoFillDownloadManager::REQUEST_UPLOAD; | 110 request_data.request_type = AutoFillDownloadManager::REQUEST_UPLOAD; |
| 110 | 111 |
| 111 return StartRequest(form_xml, request_data); | 112 return StartRequest(form_xml, request_data); |
| 112 } | 113 } |
| 113 | 114 |
| 114 bool AutoFillDownloadManager::CancelRequest( | 115 bool AutoFillDownloadManager::CancelRequest( |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 264 SetNegativeUploadRate(new_negative_upload_rate); | 265 SetNegativeUploadRate(new_negative_upload_rate); |
| 265 } | 266 } |
| 266 | 267 |
| 267 if (observer_) | 268 if (observer_) |
| 268 observer_->OnUploadedAutoFillHeuristics(it->second.form_signatures[0]); | 269 observer_->OnUploadedAutoFillHeuristics(it->second.form_signatures[0]); |
| 269 } | 270 } |
| 270 } | 271 } |
| 271 delete it->first; | 272 delete it->first; |
| 272 url_fetchers_.erase(it); | 273 url_fetchers_.erase(it); |
| 273 } | 274 } |
| OLD | NEW |