OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/password_manager/core/browser/affiliation_fetcher.h" | 5 #include "components/password_manager/core/browser/affiliation_fetcher.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <utility> |
8 | 9 |
9 #include "base/metrics/histogram_macros.h" | 10 #include "base/metrics/histogram_macros.h" |
10 #include "base/metrics/sparse_histogram.h" | 11 #include "base/metrics/sparse_histogram.h" |
11 #include "components/password_manager/core/browser/affiliation_api.pb.h" | 12 #include "components/password_manager/core/browser/affiliation_api.pb.h" |
12 #include "components/password_manager/core/browser/affiliation_utils.h" | 13 #include "components/password_manager/core/browser/affiliation_utils.h" |
13 #include "components/password_manager/core/browser/test_affiliation_fetcher_fact
ory.h" | 14 #include "components/password_manager/core/browser/test_affiliation_fetcher_fact
ory.h" |
14 #include "google_apis/google_api_keys.h" | 15 #include "google_apis/google_api_keys.h" |
15 #include "net/base/load_flags.h" | 16 #include "net/base/load_flags.h" |
16 #include "net/base/url_util.h" | 17 #include "net/base/url_util.h" |
17 #include "net/http/http_status_code.h" | 18 #include "net/http/http_status_code.h" |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 DCHECK_EQ(source, fetcher_.get()); | 198 DCHECK_EQ(source, fetcher_.get()); |
198 | 199 |
199 // Note that invoking the |delegate_| may destroy |this| synchronously, so the | 200 // Note that invoking the |delegate_| may destroy |this| synchronously, so the |
200 // invocation must happen last. | 201 // invocation must happen last. |
201 scoped_ptr<AffiliationFetcherDelegate::Result> result_data( | 202 scoped_ptr<AffiliationFetcherDelegate::Result> result_data( |
202 new AffiliationFetcherDelegate::Result); | 203 new AffiliationFetcherDelegate::Result); |
203 if (fetcher_->GetStatus().status() == net::URLRequestStatus::SUCCESS && | 204 if (fetcher_->GetStatus().status() == net::URLRequestStatus::SUCCESS && |
204 fetcher_->GetResponseCode() == net::HTTP_OK) { | 205 fetcher_->GetResponseCode() == net::HTTP_OK) { |
205 if (ParseResponse(result_data.get())) { | 206 if (ParseResponse(result_data.get())) { |
206 ReportStatistics(AFFILIATION_FETCH_RESULT_SUCCESS, nullptr); | 207 ReportStatistics(AFFILIATION_FETCH_RESULT_SUCCESS, nullptr); |
207 delegate_->OnFetchSucceeded(result_data.Pass()); | 208 delegate_->OnFetchSucceeded(std::move(result_data)); |
208 } else { | 209 } else { |
209 ReportStatistics(AFFILIATION_FETCH_RESULT_MALFORMED, nullptr); | 210 ReportStatistics(AFFILIATION_FETCH_RESULT_MALFORMED, nullptr); |
210 delegate_->OnMalformedResponse(); | 211 delegate_->OnMalformedResponse(); |
211 } | 212 } |
212 } else { | 213 } else { |
213 ReportStatistics(AFFILIATION_FETCH_RESULT_FAILURE, fetcher_.get()); | 214 ReportStatistics(AFFILIATION_FETCH_RESULT_FAILURE, fetcher_.get()); |
214 delegate_->OnFetchFailed(); | 215 delegate_->OnFetchFailed(); |
215 } | 216 } |
216 } | 217 } |
217 | 218 |
218 } // namespace password_manager | 219 } // namespace password_manager |
OLD | NEW |