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() {} |