| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/test/test_url_fetcher_factory.h" | 5 #include "content/test/test_url_fetcher_factory.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| 11 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
| 12 #include "base/message_loop.h" | 12 #include "base/message_loop.h" |
| 13 #include "content/common/net/url_fetcher_impl.h" | 13 #include "content/common/net/url_fetcher_impl.h" |
| 14 #include "content/public/common/content_url_request_user_data.h" |
| 14 #include "content/public/common/url_fetcher_delegate.h" | 15 #include "content/public/common/url_fetcher_delegate.h" |
| 15 #include "net/base/host_port_pair.h" | 16 #include "net/base/host_port_pair.h" |
| 16 #include "net/http/http_response_headers.h" | 17 #include "net/http/http_response_headers.h" |
| 17 #include "net/url_request/url_request_status.h" | 18 #include "net/url_request/url_request_status.h" |
| 18 | 19 |
| 19 ScopedURLFetcherFactory::ScopedURLFetcherFactory( | 20 ScopedURLFetcherFactory::ScopedURLFetcherFactory( |
| 20 content::URLFetcherFactory* factory) { | 21 content::URLFetcherFactory* factory) { |
| 21 DCHECK(!URLFetcherImpl::factory()); | 22 DCHECK(!URLFetcherImpl::factory()); |
| 22 URLFetcherImpl::set_factory(factory); | 23 URLFetcherImpl::set_factory(factory); |
| 23 } | 24 } |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 } | 82 } |
| 82 | 83 |
| 83 void TestURLFetcher::GetExtraRequestHeaders(net::HttpRequestHeaders* headers) { | 84 void TestURLFetcher::GetExtraRequestHeaders(net::HttpRequestHeaders* headers) { |
| 84 *headers = fake_extra_request_headers_; | 85 *headers = fake_extra_request_headers_; |
| 85 } | 86 } |
| 86 | 87 |
| 87 void TestURLFetcher::SetRequestContext( | 88 void TestURLFetcher::SetRequestContext( |
| 88 net::URLRequestContextGetter* request_context_getter) { | 89 net::URLRequestContextGetter* request_context_getter) { |
| 89 } | 90 } |
| 90 | 91 |
| 92 void TestURLFetcher::SetContentURLRequestUserData( |
| 93 content::ContentURLRequestUserData* user_data) { |
| 94 delete user_data; |
| 95 } |
| 96 |
| 91 void TestURLFetcher::SetAutomaticallyRetryOn5xx(bool retry) { | 97 void TestURLFetcher::SetAutomaticallyRetryOn5xx(bool retry) { |
| 92 } | 98 } |
| 93 | 99 |
| 94 void TestURLFetcher::SetMaxRetries(int max_retries) { | 100 void TestURLFetcher::SetMaxRetries(int max_retries) { |
| 95 fake_max_retries_ = max_retries; | 101 fake_max_retries_ = max_retries; |
| 96 } | 102 } |
| 97 | 103 |
| 98 int TestURLFetcher::GetMaxRetries() const { | 104 int TestURLFetcher::GetMaxRetries() const { |
| 99 return fake_max_retries_; | 105 return fake_max_retries_; |
| 100 } | 106 } |
| (...skipping 16 matching lines...) Expand all Loading... |
| 117 } | 123 } |
| 118 | 124 |
| 119 bool TestURLFetcher::WasFetchedViaProxy() const { | 125 bool TestURLFetcher::WasFetchedViaProxy() const { |
| 120 return fake_was_fetched_via_proxy_; | 126 return fake_was_fetched_via_proxy_; |
| 121 } | 127 } |
| 122 | 128 |
| 123 void TestURLFetcher::Start() { | 129 void TestURLFetcher::Start() { |
| 124 // Overriden to do nothing. It is assumed the caller will notify the delegate. | 130 // Overriden to do nothing. It is assumed the caller will notify the delegate. |
| 125 } | 131 } |
| 126 | 132 |
| 127 void TestURLFetcher::StartWithRequestContextGetter( | 133 void TestURLFetcher::StartWithRequestContextGetterAndUserData( |
| 128 net::URLRequestContextGetter* request_context_getter) { | 134 net::URLRequestContextGetter* request_context_getter, |
| 135 content::ContentURLRequestUserData* user_data) { |
| 129 NOTIMPLEMENTED(); | 136 NOTIMPLEMENTED(); |
| 130 } | 137 } |
| 131 | 138 |
| 132 const GURL& TestURLFetcher::GetOriginalURL() const { | 139 const GURL& TestURLFetcher::GetOriginalURL() const { |
| 133 return original_url_; | 140 return original_url_; |
| 134 } | 141 } |
| 135 | 142 |
| 136 const GURL& TestURLFetcher::GetURL() const { | 143 const GURL& TestURLFetcher::GetURL() const { |
| 137 return fake_url_; | 144 return fake_url_; |
| 138 } | 145 } |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 320 | 327 |
| 321 URLFetcherImplFactory::~URLFetcherImplFactory() {} | 328 URLFetcherImplFactory::~URLFetcherImplFactory() {} |
| 322 | 329 |
| 323 content::URLFetcher* URLFetcherImplFactory::CreateURLFetcher( | 330 content::URLFetcher* URLFetcherImplFactory::CreateURLFetcher( |
| 324 int id, | 331 int id, |
| 325 const GURL& url, | 332 const GURL& url, |
| 326 content::URLFetcher::RequestType request_type, | 333 content::URLFetcher::RequestType request_type, |
| 327 content::URLFetcherDelegate* d) { | 334 content::URLFetcherDelegate* d) { |
| 328 return new URLFetcherImpl(url, request_type, d); | 335 return new URLFetcherImpl(url, request_type, d); |
| 329 } | 336 } |
| OLD | NEW |