| 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/password_manager/core/browser/fake_affiliation_api.h" | 5 #include "components/password_manager/core/browser/fake_affiliation_api.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <utility> |
| 8 | 9 |
| 9 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
| 11 | 12 |
| 12 namespace password_manager { | 13 namespace password_manager { |
| 13 | 14 |
| 14 ScopedFakeAffiliationAPI::ScopedFakeAffiliationAPI() { | 15 ScopedFakeAffiliationAPI::ScopedFakeAffiliationAPI() { |
| 15 } | 16 } |
| 16 | 17 |
| 17 ScopedFakeAffiliationAPI::~ScopedFakeAffiliationAPI() { | 18 ScopedFakeAffiliationAPI::~ScopedFakeAffiliationAPI() { |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 if (std::find(preset_equivalence_class.begin(), | 51 if (std::find(preset_equivalence_class.begin(), |
| 51 preset_equivalence_class.end(), | 52 preset_equivalence_class.end(), |
| 52 requested_facet_uri) != preset_equivalence_class.end()) { | 53 requested_facet_uri) != preset_equivalence_class.end()) { |
| 53 had_intersection_with_request = true; | 54 had_intersection_with_request = true; |
| 54 break; | 55 break; |
| 55 } | 56 } |
| 56 } | 57 } |
| 57 if (had_intersection_with_request) | 58 if (had_intersection_with_request) |
| 58 fake_response->push_back(preset_equivalence_class); | 59 fake_response->push_back(preset_equivalence_class); |
| 59 } | 60 } |
| 60 fetcher->SimulateSuccess(fake_response.Pass()); | 61 fetcher->SimulateSuccess(std::move(fake_response)); |
| 61 } | 62 } |
| 62 | 63 |
| 63 void ScopedFakeAffiliationAPI::FailNextRequest() { | 64 void ScopedFakeAffiliationAPI::FailNextRequest() { |
| 64 if (!fake_fetcher_factory_.has_pending_fetchers()) | 65 if (!fake_fetcher_factory_.has_pending_fetchers()) |
| 65 return; | 66 return; |
| 66 | 67 |
| 67 FakeAffiliationFetcher* fetcher = fake_fetcher_factory_.PopNextFetcher(); | 68 FakeAffiliationFetcher* fetcher = fake_fetcher_factory_.PopNextFetcher(); |
| 68 fetcher->SimulateFailure(); | 69 fetcher->SimulateFailure(); |
| 69 } | 70 } |
| 70 | 71 |
| 71 void ScopedFakeAffiliationAPI::IgnoreNextRequest() { | 72 void ScopedFakeAffiliationAPI::IgnoreNextRequest() { |
| 72 if (!fake_fetcher_factory_.has_pending_fetchers()) | 73 if (!fake_fetcher_factory_.has_pending_fetchers()) |
| 73 return; | 74 return; |
| 74 ignore_result(fake_fetcher_factory_.PopNextFetcher()); | 75 ignore_result(fake_fetcher_factory_.PopNextFetcher()); |
| 75 } | 76 } |
| 76 | 77 |
| 77 } // namespace password_manager | 78 } // namespace password_manager |
| OLD | NEW |