| 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 "chrome/browser/browsing_data/autofill_counter.h" | 5 #include "chrome/browser/browsing_data/autofill_counter.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <utility> |
| 8 #include <vector> | 9 #include <vector> |
| 9 | 10 |
| 10 #include "base/memory/scoped_vector.h" | 11 #include "base/memory/scoped_vector.h" |
| 11 #include "chrome/browser/web_data_service_factory.h" | 12 #include "chrome/browser/web_data_service_factory.h" |
| 12 #include "chrome/common/pref_names.h" | 13 #include "chrome/common/pref_names.h" |
| 13 #include "components/autofill/core/browser/autofill_profile.h" | 14 #include "components/autofill/core/browser/autofill_profile.h" |
| 14 #include "components/autofill/core/browser/credit_card.h" | 15 #include "components/autofill/core/browser/credit_card.h" |
| 15 #include "components/autofill/core/browser/webdata/autofill_webdata_service.h" | 16 #include "components/autofill/core/browser/webdata/autofill_webdata_service.h" |
| 16 | 17 |
| 17 AutofillCounter::AutofillCounter() : pref_name_(prefs::kDeleteFormData), | 18 AutofillCounter::AutofillCounter() : pref_name_(prefs::kDeleteFormData), |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 } else { | 138 } else { |
| 138 NOTREACHED() << "No such query: " << handle; | 139 NOTREACHED() << "No such query: " << handle; |
| 139 } | 140 } |
| 140 | 141 |
| 141 // If we still have pending queries, do not report data yet. | 142 // If we still have pending queries, do not report data yet. |
| 142 if (HasPendingQuery()) | 143 if (HasPendingQuery()) |
| 143 return; | 144 return; |
| 144 | 145 |
| 145 scoped_ptr<Result> reported_result(new AutofillResult( | 146 scoped_ptr<Result> reported_result(new AutofillResult( |
| 146 this, num_suggestions_, num_credit_cards_, num_addresses_)); | 147 this, num_suggestions_, num_credit_cards_, num_addresses_)); |
| 147 ReportResult(reported_result.Pass()); | 148 ReportResult(std::move(reported_result)); |
| 148 } | 149 } |
| 149 | 150 |
| 150 void AutofillCounter::CancelAllRequests() { | 151 void AutofillCounter::CancelAllRequests() { |
| 151 if (suggestions_query_) | 152 if (suggestions_query_) |
| 152 web_data_service_->CancelRequest(suggestions_query_); | 153 web_data_service_->CancelRequest(suggestions_query_); |
| 153 if (credit_cards_query_) | 154 if (credit_cards_query_) |
| 154 web_data_service_->CancelRequest(credit_cards_query_); | 155 web_data_service_->CancelRequest(credit_cards_query_); |
| 155 if (addresses_query_) | 156 if (addresses_query_) |
| 156 web_data_service_->CancelRequest(addresses_query_); | 157 web_data_service_->CancelRequest(addresses_query_); |
| 157 } | 158 } |
| 158 | 159 |
| 159 // AutofillCounter::AutofillResult --------------------------------------------- | 160 // AutofillCounter::AutofillResult --------------------------------------------- |
| 160 | 161 |
| 161 AutofillCounter::AutofillResult::AutofillResult( | 162 AutofillCounter::AutofillResult::AutofillResult( |
| 162 const AutofillCounter* source, | 163 const AutofillCounter* source, |
| 163 ResultInt num_suggestions, | 164 ResultInt num_suggestions, |
| 164 ResultInt num_credit_cards, | 165 ResultInt num_credit_cards, |
| 165 ResultInt num_addresses) | 166 ResultInt num_addresses) |
| 166 : FinishedResult(source, num_suggestions), | 167 : FinishedResult(source, num_suggestions), |
| 167 num_credit_cards_(num_credit_cards), | 168 num_credit_cards_(num_credit_cards), |
| 168 num_addresses_(num_addresses) { | 169 num_addresses_(num_addresses) { |
| 169 } | 170 } |
| 170 | 171 |
| 171 AutofillCounter::AutofillResult::~AutofillResult() { | 172 AutofillCounter::AutofillResult::~AutofillResult() { |
| 172 } | 173 } |
| OLD | NEW |