summaryrefslogtreecommitdiffstats
path: root/chrome/browser/net/url_fetcher.cc
diff options
context:
space:
mode:
authorsky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-21 21:58:45 +0000
committersky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-21 21:58:45 +0000
commitb6c911a716816238f5155ef1522622d76d4665a2 (patch)
tree75fc5d30b0d421aafab8ae04737f4c867d26d917 /chrome/browser/net/url_fetcher.cc
parente23fced69f230fa3b1f8368722b7a308e8668077 (diff)
downloadchromium_src-b6c911a716816238f5155ef1522622d76d4665a2.zip
chromium_src-b6c911a716816238f5155ef1522622d76d4665a2.tar.gz
chromium_src-b6c911a716816238f5155ef1522622d76d4665a2.tar.bz2
Makes it possible to mock URLFetcher.
BUG=none TEST=none Review URL: http://codereview.chromium.org/87035 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@14141 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/net/url_fetcher.cc')
-rw-r--r--chrome/browser/net/url_fetcher.cc18
1 files changed, 17 insertions, 1 deletions
diff --git a/chrome/browser/net/url_fetcher.cc b/chrome/browser/net/url_fetcher.cc
index dcec935..425cc73 100644
--- a/chrome/browser/net/url_fetcher.cc
+++ b/chrome/browser/net/url_fetcher.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// Copyright (c) 2009 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.
@@ -49,6 +49,8 @@ class URLFetcher::Core
virtual void OnResponseStarted(URLRequest* request);
virtual void OnReadCompleted(URLRequest* request, int bytes_read);
+ URLFetcher::Delegate* delegate() const { return delegate_; }
+
private:
// Wrapper functions that allow us to ensure actions happen on the right
// thread.
@@ -93,6 +95,9 @@ class URLFetcher::Core
DISALLOW_COPY_AND_ASSIGN(Core);
};
+// static
+URLFetcher::Factory* URLFetcher::factory_ = NULL;
+
URLFetcher::URLFetcher(const GURL& url,
RequestType request_type,
Delegate* d)
@@ -104,6 +109,13 @@ URLFetcher::~URLFetcher() {
core_->Stop();
}
+// static
+URLFetcher* URLFetcher::Create(int id, const GURL& url,
+ RequestType request_type, Delegate* d) {
+ return factory_ ? factory_->CreateURLFetcher(id, url, request_type, d) :
+ new URLFetcher(url, request_type, d);
+}
+
URLFetcher::Core::Core(URLFetcher* fetcher,
const GURL& original_url,
RequestType request_type,
@@ -297,3 +309,7 @@ void URLFetcher::Start() {
const GURL& URLFetcher::url() const {
return core_->url_;
}
+
+URLFetcher::Delegate* URLFetcher::delegate() const {
+ return core_->delegate();
+}