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

Unified Diff: content/test/test_url_fetcher_factory.cc

Issue 7524033: Add a scoper object for URLFetcher::Factory (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 9 years, 5 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
« no previous file with comments | « content/test/test_url_fetcher_factory.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/test/test_url_fetcher_factory.cc
diff --git a/content/common/test_url_fetcher_factory.cc b/content/test/test_url_fetcher_factory.cc
similarity index 88%
rename from content/common/test_url_fetcher_factory.cc
rename to content/test/test_url_fetcher_factory.cc
index c92ae0f8ad8b0ae944159bc7245c06c965a7b9bb..ad6e512a771ea896acd1c5a285c164da3f69288a 100644
--- a/content/common/test_url_fetcher_factory.cc
+++ b/content/test/test_url_fetcher_factory.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "content/common/test_url_fetcher_factory.h"
+#include "content/test/test_url_fetcher_factory.h"
#include <string>
@@ -10,6 +10,16 @@
#include "base/message_loop.h"
#include "net/url_request/url_request_status.h"
+ScopedURLFetcherFactory::ScopedURLFetcherFactory(URLFetcher::Factory* factory) {
+ DCHECK(!URLFetcher::factory());
+ URLFetcher::set_factory(factory);
+}
+
+ScopedURLFetcherFactory::~ScopedURLFetcherFactory() {
+ DCHECK(URLFetcher::factory());
+ URLFetcher::set_factory(NULL);
+}
+
TestURLFetcher::TestURLFetcher(int id,
const GURL& url,
URLFetcher::RequestType request_type,
@@ -62,7 +72,9 @@ bool TestURLFetcher::GetResponseAsFilePath(
return true;
}
-TestURLFetcherFactory::TestURLFetcherFactory() {}
+TestURLFetcherFactory::TestURLFetcherFactory()
+ : ScopedURLFetcherFactory(ALLOW_THIS_IN_INITIALIZER_LIST(this)) {
+}
TestURLFetcherFactory::~TestURLFetcherFactory() {}
@@ -146,10 +158,15 @@ class FakeURLFetcher : public URLFetcher {
DISALLOW_COPY_AND_ASSIGN(FakeURLFetcher);
};
-FakeURLFetcherFactory::FakeURLFetcherFactory() {}
+FakeURLFetcherFactory::FakeURLFetcherFactory()
+ : ScopedURLFetcherFactory(ALLOW_THIS_IN_INITIALIZER_LIST(this)) {
+}
FakeURLFetcherFactory::FakeURLFetcherFactory(
- URLFetcher::Factory* default_factory) : default_factory_(default_factory) {}
+ URLFetcher::Factory* default_factory)
+ : ScopedURLFetcherFactory(ALLOW_THIS_IN_INITIALIZER_LIST(this)),
+ default_factory_(default_factory) {
+}
FakeURLFetcherFactory::~FakeURLFetcherFactory() {}
« no previous file with comments | « content/test/test_url_fetcher_factory.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698