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

Unified Diff: chrome/service/cloud_print/cloud_print_url_fetcher.cc

Issue 12208089: Changing CloudPrintURLFetcher instantiation to be more testable (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Modified change to use static factory pattern Created 7 years, 10 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: chrome/service/cloud_print/cloud_print_url_fetcher.cc
diff --git a/chrome/service/cloud_print/cloud_print_url_fetcher.cc b/chrome/service/cloud_print/cloud_print_url_fetcher.cc
index dc2a46869f733f1aac4dce371c4c4520e303c0a5..9f887831a336eb4af8b8b1544d90272bfb623fe8 100644
--- a/chrome/service/cloud_print/cloud_print_url_fetcher.cc
+++ b/chrome/service/cloud_print/cloud_print_url_fetcher.cc
@@ -20,6 +20,36 @@
namespace cloud_print {
+static CloudPrintURLFetcherFactory* g_factory = NULL;
+
+// static
+CloudPrintURLFetcher* CloudPrintURLFetcher::Create() {
+ CloudPrintURLFetcherFactory* factory = CloudPrintURLFetcher::factory();
+ return factory ? factory->CreateCloudPrintURLFetcher() :
+ new CloudPrintURLFetcher;
+}
+
+// static
+CloudPrintURLFetcherFactory* CloudPrintURLFetcher::factory() {
+ return g_factory;
+}
+
+// static
+void CloudPrintURLFetcher::set_factory(
gene 2013/02/11 23:34:05 Does this fit on one line?
+ CloudPrintURLFetcherFactory* factory) {
+ g_factory = factory;
+}
+
+
+CloudPrintURLFetcherFactory::CloudPrintURLFetcherFactory() {
gene 2013/02/11 23:34:05 Can we omit constructor/destructor here, and have
+ CloudPrintURLFetcher::set_factory(this);
+}
+
+CloudPrintURLFetcherFactory::~CloudPrintURLFetcherFactory() {
+ CloudPrintURLFetcher::set_factory(NULL);
+}
+
+
CloudPrintURLFetcher::ResponseAction
CloudPrintURLFetcher::Delegate::HandleRawResponse(
const net::URLFetcher* source,
@@ -53,7 +83,8 @@ CloudPrintURLFetcher::CloudPrintURLFetcher()
num_retries_(0) {
}
-bool CloudPrintURLFetcher::IsSameRequest(const net::URLFetcher* source) {
+bool CloudPrintURLFetcher::IsSameRequest(
gene 2013/02/11 23:34:05 This should fit on one line.
+ const net::URLFetcher* source) {
return (request_.get() == source);
}

Powered by Google App Engine
This is Rietveld 408576698