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

Unified Diff: components/password_manager/core/browser/affiliation_fetcher.cc

Issue 866733002: Add FakeAffiliationFetcher and factory. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix missing virtual and wrong type in CreateInstance(). 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/affiliation_fetcher.cc
diff --git a/components/password_manager/core/browser/affiliation_fetcher.cc b/components/password_manager/core/browser/affiliation_fetcher.cc
index 89139e54f18812295c626c52fb11a50f98f3a23c..a7643fa8d7be28149545f87557715c489bd47bee 100644
--- a/components/password_manager/core/browser/affiliation_fetcher.cc
+++ b/components/password_manager/core/browser/affiliation_fetcher.cc
@@ -5,6 +5,7 @@
#include "components/password_manager/core/browser/affiliation_fetcher.h"
#include "components/password_manager/core/browser/affiliation_api.pb.h"
+#include "components/password_manager/core/browser/affiliation_fetcher_factory.h"
#include "components/password_manager/core/browser/affiliation_utils.h"
#include "google_apis/google_api_keys.h"
#include "net/base/load_flags.h"
@@ -16,6 +17,8 @@
namespace password_manager {
+static AffiliationFetcherFactory* g_factory = nullptr;
vabr (Chromium) 2015/01/22 14:27:04 I suggest renaming to g_testing_factory, to emphas
engedy 2015/01/22 14:41:14 Done.
+
AffiliationFetcher::AffiliationFetcher(
net::URLRequestContextGetter* request_context_getter,
const std::vector<FacetURI>& facet_uris,
@@ -36,9 +39,17 @@ AffiliationFetcher* AffiliationFetcher::Create(
net::URLRequestContextGetter* context_getter,
const std::vector<FacetURI>& facet_uris,
AffiliationFetcherDelegate* delegate) {
+ if (g_factory)
+ return g_factory->CreateInstance(context_getter, facet_uris, delegate);
return new AffiliationFetcher(context_getter, facet_uris, delegate);
}
+// static
+void AffiliationFetcher::SetFactoryForTesting(
+ AffiliationFetcherFactory* factory) {
+ g_factory = factory;
+}
+
void AffiliationFetcher::StartRequest() {
DCHECK(!fetcher_);

Powered by Google App Engine
This is Rietveld 408576698