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

Unified Diff: components/password_manager/core/browser/fake_affiliation_api.h

Issue 868253005: AffiliationBackend: Implement the better part of on-demand fetching. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Missing override. Created 5 years, 11 months 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 side-by-side diff with in-line comments
Download patch
Index: components/password_manager/core/browser/fake_affiliation_api.h
diff --git a/components/password_manager/core/browser/fake_affiliation_api.h b/components/password_manager/core/browser/fake_affiliation_api.h
new file mode 100644
index 0000000000000000000000000000000000000000..f24c4a381144f2ed04c956846199520b2aade54d
--- /dev/null
+++ b/components/password_manager/core/browser/fake_affiliation_api.h
@@ -0,0 +1,50 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_FAKE_AFFILIATION_API_H_
+#define COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_FAKE_AFFILIATION_API_H_
+
+#include <vector>
+
+#include "base/macros.h"
+#include "components/password_manager/core/browser/affiliation_utils.h"
+#include "components/password_manager/core/browser/fake_affiliation_fetcher.h"
+
+namespace password_manager {
+
+// Intercepts all AffiliationFetcher requests while in scope, and manufactures
+// API responses based on a set of equivalence classes predefined by the tests.
+class ScopedFakeAffiliationAPI {
+ public:
+ ScopedFakeAffiliationAPI();
+ ~ScopedFakeAffiliationAPI();
+
+ // Adds |affiliated_facets| to the set of equivalence classes that will form
+ // the basis for calculating the fake API responses.
+ void AddTestEquivalenceClass(const AffiliatedFacets& affiliated_facets);
+
+ // Returns whether or not there is at least one pending fetch.
+ bool HasPendingRequest();
+
+ // Returns the list of facet URIs being looked up by the next pending fetch;
+ // or an empty list if there are no pending fetches.
+ std::vector<FacetURI> GetNextRequestedFacets();
+
+ // Calculates the response to, and completes the next pending fetch, if any,
+ // with success.
+ void ServeNextRequest();
+
+ // Ignores the next pending request, if any, without completing it.
+ void IgnoreNextRequest();
+
+ private:
+ ScopedFakeAffiliationFetcherFactory fake_fetcher_factory_;
+ std::vector<AffiliatedFacets> preset_equivalence_relation_;
+
+ DISALLOW_COPY_AND_ASSIGN(ScopedFakeAffiliationAPI);
+};
+
+} // namespace password_manager
+
+#endif // COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_FAKE_AFFILIATION_API_H_

Powered by Google App Engine
This is Rietveld 408576698