Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(908)

Side by Side Diff: components/browsing_data/core/counters/autofill_counter.cc

Issue 2555373007: In case of an error in AutofillCounter's queries, do not crash. (Closed)
Patch Set: rev Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 } else {
95 NOTREACHED();
96 }
97
85 CancelAllRequests(); 98 CancelAllRequests();
86 return; 99 return;
87 } 100 }
88 101
89 const base::Time start = period_start_for_testing_.is_null() 102 const base::Time start = period_start_for_testing_.is_null()
90 ? GetPeriodStart() 103 ? GetPeriodStart()
91 : period_start_for_testing_; 104 : period_start_for_testing_;
92 105
93 if (handle == suggestions_query_) { 106 if (handle == suggestions_query_) {
94 // Autocomplete suggestions. 107 // Autocomplete suggestions.
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 ResultInt num_suggestions, 170 ResultInt num_suggestions,
158 ResultInt num_credit_cards, 171 ResultInt num_credit_cards,
159 ResultInt num_addresses) 172 ResultInt num_addresses)
160 : FinishedResult(source, num_suggestions), 173 : FinishedResult(source, num_suggestions),
161 num_credit_cards_(num_credit_cards), 174 num_credit_cards_(num_credit_cards),
162 num_addresses_(num_addresses) {} 175 num_addresses_(num_addresses) {}
163 176
164 AutofillCounter::AutofillResult::~AutofillResult() {} 177 AutofillCounter::AutofillResult::~AutofillResult() {}
165 178
166 } // namespace browsing_data 179 } // namespace browsing_data
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698