diff options
author | shalev@chromium.org <shalev@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-29 19:07:33 +0000 |
---|---|---|
committer | shalev@chromium.org <shalev@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-29 19:07:33 +0000 |
commit | 180aad7c121d6ad743e639769fc1b6c39b5ad5b5 (patch) | |
tree | 46fea45392cb5f06f0665d853e29638774c37568 /net | |
parent | bd3699e4b9341e8084defefae72284aa36ddcedd (diff) | |
download | chromium_src-180aad7c121d6ad743e639769fc1b6c39b5ad5b5.zip chromium_src-180aad7c121d6ad743e639769fc1b6c39b5ad5b5.tar.gz chromium_src-180aad7c121d6ad743e639769fc1b6c39b5ad5b5.tar.bz2 |
Decouple URLRequestJob from URLRequestContext; access NetworkDelegate as a contructor parameter.
Note: this depends on
http://codereview.chromium.org/10559036/
BUG=None
TEST=None
Review URL: https://chromiumcodereview.appspot.com/10534100
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@144948 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r-- | net/url_request/url_request.cc | 2 | ||||
-rw-r--r-- | net/url_request/url_request_about_job.cc | 6 | ||||
-rw-r--r-- | net/url_request/url_request_error_job.cc | 6 | ||||
-rw-r--r-- | net/url_request/url_request_file_dir_job.cc | 5 | ||||
-rw-r--r-- | net/url_request/url_request_file_job.cc | 2 | ||||
-rw-r--r-- | net/url_request/url_request_ftp_job.cc | 2 | ||||
-rw-r--r-- | net/url_request/url_request_http_job.cc | 2 | ||||
-rw-r--r-- | net/url_request/url_request_job.cc | 10 | ||||
-rw-r--r-- | net/url_request/url_request_job.h | 9 | ||||
-rw-r--r-- | net/url_request/url_request_job_factory_unittest.cc | 4 | ||||
-rw-r--r-- | net/url_request/url_request_redirect_job.cc | 6 | ||||
-rw-r--r-- | net/url_request/url_request_simple_job.cc | 6 | ||||
-rw-r--r-- | net/url_request/url_request_test_job.cc | 7 |
13 files changed, 41 insertions, 26 deletions
diff --git a/net/url_request/url_request.cc b/net/url_request/url_request.cc index 915cd58..51c627a 100644 --- a/net/url_request/url_request.cc +++ b/net/url_request/url_request.cc @@ -411,7 +411,7 @@ void URLRequest::Start() { response_info_.request_time = Time::Now(); // Only notify the delegate for the initial request. - if (context_ && context_->network_delegate()) { + if (context_->network_delegate()) { int error = context_->network_delegate()->NotifyBeforeURLRequest( this, before_request_callback_, &delegate_redirect_url_); if (error == net::ERR_IO_PENDING) { diff --git a/net/url_request/url_request_about_job.cc b/net/url_request/url_request_about_job.cc index f305909..d96f2d4 100644 --- a/net/url_request/url_request_about_job.cc +++ b/net/url_request/url_request_about_job.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 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. @@ -11,11 +11,13 @@ #include "base/bind.h" #include "base/compiler_specific.h" #include "base/message_loop.h" +#include "net/url_request/url_request.h" +#include "net/url_request/url_request_context.h" namespace net { URLRequestAboutJob::URLRequestAboutJob(URLRequest* request) - : URLRequestJob(request), + : URLRequestJob(request, request->context()->network_delegate()), ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) { } diff --git a/net/url_request/url_request_error_job.cc b/net/url_request/url_request_error_job.cc index 4924c01..c3dc95e 100644 --- a/net/url_request/url_request_error_job.cc +++ b/net/url_request/url_request_error_job.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 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. @@ -8,12 +8,14 @@ #include "base/compiler_specific.h" #include "base/message_loop.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_status.h" namespace net { URLRequestErrorJob::URLRequestErrorJob(URLRequest* request, int error) - : URLRequestJob(request), + : URLRequestJob(request, request->context()->network_delegate()), error_(error), ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) {} diff --git a/net/url_request/url_request_file_dir_job.cc b/net/url_request/url_request_file_dir_job.cc index 0b05cbb..796cbf9 100644 --- a/net/url_request/url_request_file_dir_job.cc +++ b/net/url_request/url_request_file_dir_job.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 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. @@ -16,6 +16,7 @@ #include "net/base/net_errors.h" #include "net/base/net_util.h" #include "net/url_request/url_request.h" +#include "net/url_request/url_request_context.h" #if defined(OS_POSIX) #include <sys/stat.h> @@ -25,7 +26,7 @@ namespace net { URLRequestFileDirJob::URLRequestFileDirJob(URLRequest* request, const FilePath& dir_path) - : URLRequestJob(request), + : URLRequestJob(request, request->context()->network_delegate()), ALLOW_THIS_IN_INITIALIZER_LIST(lister_(dir_path, this)), dir_path_(dir_path), canceled_(false), diff --git a/net/url_request/url_request_file_job.cc b/net/url_request/url_request_file_job.cc index 0b64f74..ce0cc8b 100644 --- a/net/url_request/url_request_file_job.cc +++ b/net/url_request/url_request_file_job.cc @@ -85,7 +85,7 @@ class URLRequestFileJob::AsyncResolver URLRequestFileJob::URLRequestFileJob(URLRequest* request, const FilePath& file_path) - : URLRequestJob(request), + : URLRequestJob(request, request->context()->network_delegate()), file_path_(file_path), stream_(NULL), is_directory_(false), diff --git a/net/url_request/url_request_ftp_job.cc b/net/url_request/url_request_ftp_job.cc index 63dcc86..aca1b48 100644 --- a/net/url_request/url_request_ftp_job.cc +++ b/net/url_request/url_request_ftp_job.cc @@ -20,7 +20,7 @@ namespace net { URLRequestFtpJob::URLRequestFtpJob(URLRequest* request) - : URLRequestJob(request), + : URLRequestJob(request, request->context()->network_delegate()), read_in_progress_(false), ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) { } diff --git a/net/url_request/url_request_http_job.cc b/net/url_request/url_request_http_job.cc index 4300d11..bf01635 100644 --- a/net/url_request/url_request_http_job.cc +++ b/net/url_request/url_request_http_job.cc @@ -148,7 +148,7 @@ URLRequestJob* URLRequestHttpJob::Factory(URLRequest* request, URLRequestHttpJob::URLRequestHttpJob(URLRequest* request) - : URLRequestJob(request), + : URLRequestJob(request, request->context()->network_delegate()), response_info_(NULL), response_cookies_save_index_(0), proxy_auth_state_(AUTH_STATE_DONT_NEED_AUTH), diff --git a/net/url_request/url_request_job.cc b/net/url_request/url_request_job.cc index 255e90d..91dc5ba 100644 --- a/net/url_request/url_request_job.cc +++ b/net/url_request/url_request_job.cc @@ -17,11 +17,11 @@ #include "net/base/network_delegate.h" #include "net/http/http_response_headers.h" #include "net/url_request/url_request.h" -#include "net/url_request/url_request_context.h" namespace net { -URLRequestJob::URLRequestJob(URLRequest* request) +URLRequestJob::URLRequestJob(URLRequest* request, + NetworkDelegate* network_delegate) : request_(request), done_(false), prefilter_bytes_read_(0), @@ -32,6 +32,7 @@ URLRequestJob::URLRequestJob(URLRequest* request) has_handled_response_(false), expected_content_size_(-1), deferred_redirect_status_code_(-1), + network_delegate_(network_delegate), ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) { base::SystemMonitor* system_monitor = base::SystemMonitor::Get(); if (system_monitor) @@ -692,9 +693,8 @@ void URLRequestJob::RecordBytesRead(int bytes_read) { << " pre total = " << prefilter_bytes_read_ << " post total = " << postfilter_bytes_read_; UpdatePacketReadTimes(); // Facilitate stats recording if it is active. - const URLRequestContext* context = request_->context(); - if (context && context->network_delegate()) - context->network_delegate()->NotifyRawBytesRead(*request_, bytes_read); + if (network_delegate_) + network_delegate_->NotifyRawBytesRead(*request_, bytes_read); } bool URLRequestJob::FilterHasData() { diff --git a/net/url_request/url_request_job.h b/net/url_request/url_request_job.h index cf98447..41015a8 100644 --- a/net/url_request/url_request_job.h +++ b/net/url_request/url_request_job.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 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. @@ -13,7 +13,6 @@ #include "base/memory/scoped_ptr.h" #include "base/memory/weak_ptr.h" #include "base/system_monitor/system_monitor.h" -#include "base/time.h" #include "googleurl/src/gurl.h" #include "net/base/filter.h" #include "net/base/host_port_pair.h" @@ -29,6 +28,7 @@ class CookieOptions; class HttpRequestHeaders; class HttpResponseInfo; class IOBuffer; +class NetworkDelegate; class SSLCertRequestInfo; class SSLInfo; class URLRequest; @@ -39,7 +39,8 @@ class X509Certificate; class NET_EXPORT URLRequestJob : public base::RefCounted<URLRequestJob>, public base::SystemMonitor::PowerObserver { public: - explicit URLRequestJob(URLRequest* request); + explicit URLRequestJob(URLRequest* request, + NetworkDelegate* network_delegate); // Returns the request that owns this job. THIS POINTER MAY BE NULL if the // request was destroyed. @@ -372,6 +373,8 @@ class NET_EXPORT URLRequestJob : public base::RefCounted<URLRequestJob>, GURL deferred_redirect_url_; int deferred_redirect_status_code_; + NetworkDelegate* network_delegate_; + base::WeakPtrFactory<URLRequestJob> weak_factory_; DISALLOW_COPY_AND_ASSIGN(URLRequestJob); diff --git a/net/url_request/url_request_job_factory_unittest.cc b/net/url_request/url_request_job_factory_unittest.cc index bbb3703..a87c717 100644 --- a/net/url_request/url_request_job_factory_unittest.cc +++ b/net/url_request/url_request_job_factory_unittest.cc @@ -6,6 +6,8 @@ #include "base/bind.h" #include "base/memory/weak_ptr.h" +#include "net/url_request/url_request.h" +#include "net/url_request/url_request_context.h" #include "net/url_request/url_request_job.h" #include "net/url_request/url_request_test_util.h" #include "testing/gtest/include/gtest/gtest.h" @@ -17,7 +19,7 @@ namespace { class MockURLRequestJob : public URLRequestJob { public: MockURLRequestJob(URLRequest* request, const URLRequestStatus& status) - : URLRequestJob(request), + : URLRequestJob(request, request->context()->network_delegate()), status_(status), ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) {} diff --git a/net/url_request/url_request_redirect_job.cc b/net/url_request/url_request_redirect_job.cc index 01b2559..9960ea6 100644 --- a/net/url_request/url_request_redirect_job.cc +++ b/net/url_request/url_request_redirect_job.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 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. @@ -7,12 +7,14 @@ #include "base/bind.h" #include "base/compiler_specific.h" #include "base/message_loop.h" +#include "net/url_request/url_request.h" +#include "net/url_request/url_request_context.h" namespace net { URLRequestRedirectJob::URLRequestRedirectJob(URLRequest* request, const GURL& redirect_destination) - : URLRequestJob(request), + : URLRequestJob(request, request->context()->network_delegate()), redirect_destination_(redirect_destination), http_status_code_(302), ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) {} diff --git a/net/url_request/url_request_simple_job.cc b/net/url_request/url_request_simple_job.cc index 538dcf1..1b81351 100644 --- a/net/url_request/url_request_simple_job.cc +++ b/net/url_request/url_request_simple_job.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 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. @@ -9,12 +9,14 @@ #include "base/message_loop.h" #include "net/base/io_buffer.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_status.h" namespace net { URLRequestSimpleJob::URLRequestSimpleJob(URLRequest* request) - : URLRequestJob(request), + : URLRequestJob(request, request->context()->network_delegate()), data_offset_(0), ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) {} diff --git a/net/url_request/url_request_test_job.cc b/net/url_request/url_request_test_job.cc index 94a6bf5..9ec31fc 100644 --- a/net/url_request/url_request_test_job.cc +++ b/net/url_request/url_request_test_job.cc @@ -16,6 +16,7 @@ #include "net/base/net_errors.h" #include "net/http/http_response_headers.h" #include "net/url_request/url_request.h" +#include "net/url_request/url_request_context.h" namespace net { @@ -85,7 +86,7 @@ URLRequestJob* URLRequestTestJob::Factory(URLRequest* request, } URLRequestTestJob::URLRequestTestJob(URLRequest* request) - : URLRequestJob(request), + : URLRequestJob(request, request->context()->network_delegate()), auto_advance_(false), stage_(WAITING), offset_(0), @@ -96,7 +97,7 @@ URLRequestTestJob::URLRequestTestJob(URLRequest* request) URLRequestTestJob::URLRequestTestJob(URLRequest* request, bool auto_advance) - : URLRequestJob(request), + : URLRequestJob(request, request->context()->network_delegate()), auto_advance_(auto_advance), stage_(WAITING), offset_(0), @@ -109,7 +110,7 @@ URLRequestTestJob::URLRequestTestJob(URLRequest* request, const std::string& response_headers, const std::string& response_data, bool auto_advance) - : URLRequestJob(request), + : URLRequestJob(request, request->context()->network_delegate()), auto_advance_(auto_advance), stage_(WAITING), response_headers_(new HttpResponseHeaders(response_headers)), |