Chromium Code Reviews| 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/browsing_data/core/counters/autofill_counter.h" | 5 #include "components/browsing_data/core/counters/autofill_counter.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <utility> | 8 #include <utility> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 74 credit_cards_query_ = web_data_service_->GetCreditCards(this); | 74 credit_cards_query_ = web_data_service_->GetCreditCards(this); |
| 75 | 75 |
| 76 // Count the addresses. | 76 // Count the addresses. |
| 77 addresses_query_ = web_data_service_->GetAutofillProfiles(this); | 77 addresses_query_ = web_data_service_->GetAutofillProfiles(this); |
| 78 } | 78 } |
| 79 | 79 |
| 80 void AutofillCounter::OnWebDataServiceRequestDone( | 80 void AutofillCounter::OnWebDataServiceRequestDone( |
| 81 WebDataServiceBase::Handle handle, | 81 WebDataServiceBase::Handle handle, |
| 82 std::unique_ptr<WDTypedResult> result) { | 82 std::unique_ptr<WDTypedResult> result) { |
| 83 DCHECK(thread_checker_.CalledOnValidThread()); | 83 DCHECK(thread_checker_.CalledOnValidThread()); |
| 84 | |
| 84 if (!result) { | 85 if (!result) { |
| 86 // CancelAllRequests will cancel all queries that are active; the query that | |
| 87 // just failed is complete and cannot be canceled so zero it out. | |
| 88 if (handle == suggestions_query_) { | |
| 89 suggestions_query_ = 0; | |
| 90 } else if (handle == credit_cards_query_) { | |
| 91 credit_cards_query_ = 0; | |
| 92 } else if (handle == addresses_query_) { | |
| 93 addresses_query_ = 0; | |
| 94 } | |
|
Bernhard Bauer
2016/12/12 14:56:26
Maybe add an else { NOTREACHED(); } just for compl
Avi (use Gerrit)
2016/12/12 15:16:48
Done.
| |
| 95 | |
| 85 CancelAllRequests(); | 96 CancelAllRequests(); |
| 86 return; | 97 return; |
| 87 } | 98 } |
| 88 | 99 |
| 89 const base::Time start = period_start_for_testing_.is_null() | 100 const base::Time start = period_start_for_testing_.is_null() |
| 90 ? GetPeriodStart() | 101 ? GetPeriodStart() |
| 91 : period_start_for_testing_; | 102 : period_start_for_testing_; |
| 92 | 103 |
| 93 if (handle == suggestions_query_) { | 104 if (handle == suggestions_query_) { |
| 94 // Autocomplete suggestions. | 105 // Autocomplete suggestions. |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 157 ResultInt num_suggestions, | 168 ResultInt num_suggestions, |
| 158 ResultInt num_credit_cards, | 169 ResultInt num_credit_cards, |
| 159 ResultInt num_addresses) | 170 ResultInt num_addresses) |
| 160 : FinishedResult(source, num_suggestions), | 171 : FinishedResult(source, num_suggestions), |
| 161 num_credit_cards_(num_credit_cards), | 172 num_credit_cards_(num_credit_cards), |
| 162 num_addresses_(num_addresses) {} | 173 num_addresses_(num_addresses) {} |
| 163 | 174 |
| 164 AutofillCounter::AutofillResult::~AutofillResult() {} | 175 AutofillCounter::AutofillResult::~AutofillResult() {} |
| 165 | 176 |
| 166 } // namespace browsing_data | 177 } // namespace browsing_data |
| OLD | NEW |