diff options
author | shalev@chromium.org <shalev@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-08-24 01:06:58 +0000 |
---|---|---|
committer | shalev@chromium.org <shalev@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-08-24 01:06:58 +0000 |
commit | 9f170464e1ab4f1f75802a391db76408bc8998f2 (patch) | |
tree | 50ecf1c9c893ab12c59ee653d57732572128b7ed /content/browser | |
parent | 3dc4019ef862889073cf16e875050a512e93aa3a (diff) | |
download | chromium_src-9f170464e1ab4f1f75802a391db76408bc8998f2.zip chromium_src-9f170464e1ab4f1f75802a391db76408bc8998f2.tar.gz chromium_src-9f170464e1ab4f1f75802a391db76408bc8998f2.tar.bz2 |
Refactoring: ProtocolHandler::MaybeCreateJob and other functions take NetworkDelegate as argument
This change goes a long way to prepare for removing NetworkDelegate from URLRequestContext.
TBR=sky@chromium.org, michaeln@chromium.org, benjhayden@chromium.org, brettw@chromium.org, ben@chromium.org, davemoore@chromium.org, zelidrag@chromium.org, mnissler@chromium.org, thestig@chromium.org, asargent@chromium.org, jhawkins@chromium.org, bulach@chromium.org
BUG=crbug.com/142945
Review URL: https://chromiumcodereview.appspot.com/10855209
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@153133 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/browser')
10 files changed, 75 insertions, 45 deletions
diff --git a/content/browser/histogram_internals_request_job.cc b/content/browser/histogram_internals_request_job.cc index 8989210..ad59f2a 100644 --- a/content/browser/histogram_internals_request_job.cc +++ b/content/browser/histogram_internals_request_job.cc @@ -15,7 +15,8 @@ namespace content { HistogramInternalsRequestJob::HistogramInternalsRequestJob( - net::URLRequest* request) : net::URLRequestSimpleJob(request) { + net::URLRequest* request, net::NetworkDelegate* network_delegate) + : net::URLRequestSimpleJob(request, network_delegate) { const std::string& spec = request->url().possibly_invalid_spec(); const url_parse::Parsed& parsed = request->url().parsed_for_possibly_invalid_spec(); diff --git a/content/browser/histogram_internals_request_job.h b/content/browser/histogram_internals_request_job.h index b5d11ce..4be774b 100644 --- a/content/browser/histogram_internals_request_job.h +++ b/content/browser/histogram_internals_request_job.h @@ -14,7 +14,8 @@ namespace content { class HistogramInternalsRequestJob : public net::URLRequestSimpleJob { public: - explicit HistogramInternalsRequestJob(net::URLRequest* request); + HistogramInternalsRequestJob(net::URLRequest* request, + net::NetworkDelegate* network_delegate); virtual int GetData(std::string* mime_type, std::string* charset, diff --git a/content/browser/net/view_blob_internals_job_factory.cc b/content/browser/net/view_blob_internals_job_factory.cc index 32dbd99..ab98a97 100644 --- a/content/browser/net/view_blob_internals_job_factory.cc +++ b/content/browser/net/view_blob_internals_job_factory.cc @@ -7,7 +7,6 @@ #include "base/memory/scoped_ptr.h" #include "base/string_util.h" #include "content/public/common/url_constants.h" -#include "net/url_request/url_request.h" #include "webkit/blob/view_blob_internals_job.h" // static. @@ -19,7 +18,8 @@ bool ViewBlobInternalsJobFactory::IsSupportedURL(const GURL& url) { // static. net::URLRequestJob* ViewBlobInternalsJobFactory::CreateJobForRequest( net::URLRequest* request, + net::NetworkDelegate* network_delegate, webkit_blob::BlobStorageController* blob_storage_controller) { return new webkit_blob::ViewBlobInternalsJob( - request, blob_storage_controller); + request, network_delegate, blob_storage_controller); } diff --git a/content/browser/net/view_blob_internals_job_factory.h b/content/browser/net/view_blob_internals_job_factory.h index 71ba830..e4c36eb 100644 --- a/content/browser/net/view_blob_internals_job_factory.h +++ b/content/browser/net/view_blob_internals_job_factory.h @@ -6,6 +6,7 @@ #define CONTENT_BROWSER_NET_VIEW_BLOB_INTERNALS_JOB_FACTORY_H_ namespace net { +class NetworkDelegate; class URLRequest; class URLRequestJob; } // namespace net @@ -20,6 +21,7 @@ class ViewBlobInternalsJobFactory { static bool IsSupportedURL(const GURL& url); static net::URLRequestJob* CreateJobForRequest( net::URLRequest* request, + net::NetworkDelegate* network_delegate, webkit_blob::BlobStorageController* blob_storage_controller); }; diff --git a/content/browser/net/view_http_cache_job_factory.cc b/content/browser/net/view_http_cache_job_factory.cc index dddb9ba..716f4a3 100644 --- a/content/browser/net/view_http_cache_job_factory.cc +++ b/content/browser/net/view_http_cache_job_factory.cc @@ -15,7 +15,6 @@ #include "net/base/completion_callback.h" #include "net/base/net_errors.h" #include "net/url_request/url_request.h" -#include "net/url_request/url_request_context.h" #include "net/url_request/url_request_simple_job.h" #include "net/url_request/view_cache_helper.h" @@ -24,8 +23,9 @@ namespace { // A job subclass that dumps an HTTP cache entry. class ViewHttpCacheJob : public net::URLRequestJob { public: - explicit ViewHttpCacheJob(net::URLRequest* request) - : net::URLRequestJob(request, request->context()->network_delegate()), + ViewHttpCacheJob(net::URLRequest* request, + net::NetworkDelegate* network_delegate) + : net::URLRequestJob(request, network_delegate), core_(new Core), ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)), ALLOW_THIS_IN_INITIALIZER_LIST( @@ -197,6 +197,6 @@ bool ViewHttpCacheJobFactory::IsSupportedURL(const GURL& url) { // Static. net::URLRequestJob* ViewHttpCacheJobFactory::CreateJobForRequest( - net::URLRequest* request) { - return new ViewHttpCacheJob(request); + net::URLRequest* request, net::NetworkDelegate* network_delegate) { + return new ViewHttpCacheJob(request, network_delegate); } diff --git a/content/browser/net/view_http_cache_job_factory.h b/content/browser/net/view_http_cache_job_factory.h index abd5777..88c84da 100644 --- a/content/browser/net/view_http_cache_job_factory.h +++ b/content/browser/net/view_http_cache_job_factory.h @@ -6,6 +6,7 @@ #define CONTENT_BROWSER_NET_VIEW_HTTP_CACHE_JOB_FACTORY_H_ namespace net { +class NetworkDelegate; class URLRequest; class URLRequestJob; } // namespace net @@ -15,7 +16,8 @@ class GURL; class ViewHttpCacheJobFactory { public: static bool IsSupportedURL(const GURL& url); - static net::URLRequestJob* CreateJobForRequest(net::URLRequest* request); + static net::URLRequestJob* CreateJobForRequest( + net::URLRequest* request, net::NetworkDelegate* network_delegate); }; #endif // CONTENT_BROWSER_NET_VIEW_HTTP_CACHE_JOB_FACTORY_H_ diff --git a/content/browser/renderer_host/resource_dispatcher_host_unittest.cc b/content/browser/renderer_host/resource_dispatcher_host_unittest.cc index d22181d..6d96949 100644 --- a/content/browser/renderer_host/resource_dispatcher_host_unittest.cc +++ b/content/browser/renderer_host/resource_dispatcher_host_unittest.cc @@ -209,20 +209,27 @@ class ForwardingFilter : public ResourceMessageFilter { // not complete start upon entry, only when specifically told to. class URLRequestTestDelayedStartJob : public net::URLRequestTestJob { public: - URLRequestTestDelayedStartJob(net::URLRequest* request) - : net::URLRequestTestJob(request) { + URLRequestTestDelayedStartJob(net::URLRequest* request, + net::NetworkDelegate* network_delegate) + : net::URLRequestTestJob(request, network_delegate) { Init(); } - URLRequestTestDelayedStartJob(net::URLRequest* request, bool auto_advance) - : net::URLRequestTestJob(request, auto_advance) { + URLRequestTestDelayedStartJob(net::URLRequest* request, + net::NetworkDelegate* network_delegate, + bool auto_advance) + : net::URLRequestTestJob(request, network_delegate, auto_advance) { Init(); } URLRequestTestDelayedStartJob(net::URLRequest* request, + net::NetworkDelegate* network_delegate, const std::string& response_headers, const std::string& response_data, bool auto_advance) - : net::URLRequestTestJob( - request, response_headers, response_data, auto_advance) { + : net::URLRequestTestJob(request, + network_delegate, + response_headers, + response_data, + auto_advance) { Init(); } @@ -286,17 +293,23 @@ URLRequestTestDelayedStartJob::list_head_ = NULL; // returns IO_pending errors before every read, not just the first one. class URLRequestTestDelayedCompletionJob : public net::URLRequestTestJob { public: - explicit URLRequestTestDelayedCompletionJob(net::URLRequest* request) - : net::URLRequestTestJob(request) {} URLRequestTestDelayedCompletionJob(net::URLRequest* request, + net::NetworkDelegate* network_delegate) + : net::URLRequestTestJob(request, network_delegate) {} + URLRequestTestDelayedCompletionJob(net::URLRequest* request, + net::NetworkDelegate* network_delegate, bool auto_advance) - : net::URLRequestTestJob(request, auto_advance) {} + : net::URLRequestTestJob(request, network_delegate, auto_advance) {} URLRequestTestDelayedCompletionJob(net::URLRequest* request, + net::NetworkDelegate* network_delegate, const std::string& response_headers, const std::string& response_data, bool auto_advance) - : net::URLRequestTestJob(request, response_headers, - response_data, auto_advance) {} + : net::URLRequestTestJob(request, + network_delegate, + response_headers, + response_data, + auto_advance) {} protected: ~URLRequestTestDelayedCompletionJob() {} @@ -307,8 +320,9 @@ class URLRequestTestDelayedCompletionJob : public net::URLRequestTestJob { class URLRequestBigJob : public net::URLRequestSimpleJob { public: - URLRequestBigJob(net::URLRequest* request) - : net::URLRequestSimpleJob(request) { + URLRequestBigJob(net::URLRequest* request, + net::NetworkDelegate* network_delegate) + : net::URLRequestSimpleJob(request, network_delegate) { } virtual int GetData(std::string* mime_type, @@ -564,31 +578,35 @@ class ResourceDispatcherHostTest : public testing::Test, // Our own net::URLRequestJob factory. static net::URLRequestJob* Factory(net::URLRequest* request, + net::NetworkDelegate* network_delegate, const std::string& scheme) { if (test_fixture_->response_headers_.empty()) { if (delay_start_) { - return new URLRequestTestDelayedStartJob(request); + return new URLRequestTestDelayedStartJob(request, network_delegate); } else if (delay_complete_) { - return new URLRequestTestDelayedCompletionJob(request); + return new URLRequestTestDelayedCompletionJob(request, + network_delegate); } else if (scheme == "big-job") { - return new URLRequestBigJob(request); + return new URLRequestBigJob(request, network_delegate); } else { - return new net::URLRequestTestJob(request); + return new net::URLRequestTestJob(request, network_delegate); } } else { if (delay_start_) { return new URLRequestTestDelayedStartJob( - request, test_fixture_->response_headers_, - test_fixture_->response_data_, false); + request, network_delegate, + test_fixture_->response_headers_, test_fixture_->response_data_, + false); } else if (delay_complete_) { return new URLRequestTestDelayedCompletionJob( - request, test_fixture_->response_headers_, - test_fixture_->response_data_, false); + request, network_delegate, + test_fixture_->response_headers_, test_fixture_->response_data_, + false); } else { - return new net::URLRequestTestJob(request, - test_fixture_->response_headers_, - test_fixture_->response_data_, - false); + return new net::URLRequestTestJob( + request, network_delegate, + test_fixture_->response_headers_, test_fixture_->response_data_, + false); } } } diff --git a/content/browser/resource_context_impl.cc b/content/browser/resource_context_impl.cc index 8281aea..7e3555d 100644 --- a/content/browser/resource_context_impl.cc +++ b/content/browser/resource_context_impl.cc @@ -94,36 +94,38 @@ class DeveloperProtocolHandler virtual ~DeveloperProtocolHandler() {} virtual net::URLRequestJob* MaybeIntercept( - net::URLRequest* request) const OVERRIDE { + net::URLRequest* request, + net::NetworkDelegate* network_delegate) const OVERRIDE { // Check for chrome://view-http-cache/*, which uses its own job type. if (ViewHttpCacheJobFactory::IsSupportedURL(request->url())) - return ViewHttpCacheJobFactory::CreateJobForRequest(request); + return ViewHttpCacheJobFactory::CreateJobForRequest(request, + network_delegate); // Next check for chrome://appcache-internals/, which uses its own job type. if (request->url().SchemeIs(chrome::kChromeUIScheme) && request->url().host() == chrome::kChromeUIAppCacheInternalsHost) { return appcache::ViewAppCacheInternalsJobFactory::CreateJobForRequest( - request, appcache_service_); + request, network_delegate, appcache_service_); } // Next check for chrome://blob-internals/, which uses its own job type. if (ViewBlobInternalsJobFactory::IsSupportedURL(request->url())) { return ViewBlobInternalsJobFactory::CreateJobForRequest( - request, blob_storage_controller_); + request, network_delegate, blob_storage_controller_); } #if defined(USE_TCMALLOC) // Next check for chrome://tcmalloc/, which uses its own job type. if (request->url().SchemeIs(chrome::kChromeUIScheme) && request->url().host() == chrome::kChromeUITcmallocHost) { - return new TcmallocInternalsRequestJob(request); + return new TcmallocInternalsRequestJob(request, network_delegate); } #endif // Next check for chrome://histograms/, which uses its own job type. if (request->url().SchemeIs(chrome::kChromeUIScheme) && request->url().host() == chrome::kChromeUIHistogramHost) { - return new HistogramInternalsRequestJob(request); + return new HistogramInternalsRequestJob(request, network_delegate); } return NULL; @@ -131,12 +133,14 @@ class DeveloperProtocolHandler virtual net::URLRequestJob* MaybeInterceptRedirect( const GURL& location, - net::URLRequest* request) const OVERRIDE { + net::URLRequest* request, + net::NetworkDelegate* network_delegate) const OVERRIDE { return NULL; } virtual net::URLRequestJob* MaybeInterceptResponse( - net::URLRequest* request) const OVERRIDE { + net::URLRequest* request, + net::NetworkDelegate* network_delegate) const OVERRIDE { return NULL; } diff --git a/content/browser/tcmalloc_internals_request_job.cc b/content/browser/tcmalloc_internals_request_job.cc index 5b0c45b..2c4ef0d 100644 --- a/content/browser/tcmalloc_internals_request_job.cc +++ b/content/browser/tcmalloc_internals_request_job.cc @@ -57,7 +57,8 @@ void AboutTcmallocOutputs::DumpToHTMLTable(std::string* data) { } TcmallocInternalsRequestJob::TcmallocInternalsRequestJob( - net::URLRequest* request) : net::URLRequestSimpleJob(request) { + net::URLRequest* request, net::NetworkDelegate* network_delegate) + : net::URLRequestSimpleJob(request, network_delegate) { } #if defined(USE_TCMALLOC) diff --git a/content/browser/tcmalloc_internals_request_job.h b/content/browser/tcmalloc_internals_request_job.h index e70c274..d74b656 100644 --- a/content/browser/tcmalloc_internals_request_job.h +++ b/content/browser/tcmalloc_internals_request_job.h @@ -48,7 +48,8 @@ class AboutTcmallocOutputs { class TcmallocInternalsRequestJob : public net::URLRequestSimpleJob { public: - explicit TcmallocInternalsRequestJob(net::URLRequest* request); + TcmallocInternalsRequestJob(net::URLRequest* request, + net::NetworkDelegate* network_delegate); virtual int GetData(std::string* mime_type, std::string* charset, |