diff options
author | rvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-23 19:15:01 +0000 |
---|---|---|
committer | rvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-23 19:15:01 +0000 |
commit | 9dd90e58cb52161989caf7fcba35ceada332a05c (patch) | |
tree | ba131fb74c13f8a823b40215ac3f02754900edd4 /net/url_request | |
parent | cfaed54dc81da7803620b184a9837fed43130e5c (diff) | |
download | chromium_src-9dd90e58cb52161989caf7fcba35ceada332a05c.zip chromium_src-9dd90e58cb52161989caf7fcba35ceada332a05c.tar.gz chromium_src-9dd90e58cb52161989caf7fcba35ceada332a05c.tar.bz2 |
Add APIs to expose http cache's metadata and the
the ability to stop caching a given request.
BUG=32406, 22900
TEST=none
Review URL: http://codereview.chromium.org/600167
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@39751 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/url_request')
-rw-r--r-- | net/url_request/url_request.cc | 5 | ||||
-rw-r--r-- | net/url_request/url_request.h | 7 | ||||
-rw-r--r-- | net/url_request/url_request_http_job.cc | 5 | ||||
-rw-r--r-- | net/url_request/url_request_http_job.h | 1 | ||||
-rw-r--r-- | net/url_request/url_request_job.cc | 4 | ||||
-rw-r--r-- | net/url_request/url_request_job.h | 6 |
6 files changed, 27 insertions, 1 deletions
diff --git a/net/url_request/url_request.cc b/net/url_request/url_request.cc index 7a09123..5c4566e 100644 --- a/net/url_request/url_request.cc +++ b/net/url_request/url_request.cc @@ -347,6 +347,11 @@ bool URLRequest::Read(net::IOBuffer* dest, int dest_size, int *bytes_read) { return job_->Read(dest, dest_size, bytes_read); } +void URLRequest::StopCaching() { + DCHECK(job_); + job_->StopCaching(); +} + void URLRequest::ReceivedRedirect(const GURL& location, bool* defer_redirect) { URLRequestJob* job = GetJobManager()->MaybeInterceptRedirect(this, location); if (job) { diff --git a/net/url_request/url_request.h b/net/url_request/url_request.h index b420cf8..c8bc2bf 100644 --- a/net/url_request/url_request.h +++ b/net/url_request/url_request.h @@ -464,6 +464,13 @@ class URLRequest { // will be set to an error. bool Read(net::IOBuffer* buf, int max_bytes, int *bytes_read); + // If this request is being cached by the HTTP cache, stop subsequent caching. + // Note that this method has no effect on other (simultaneous or not) requests + // for the same resource. The typical example is a request that results in + // the data being stored to disk (downloaded instead of rendered) so we don't + // want to store it twice. + void StopCaching(); + // This method may be called to follow a redirect that was deferred in // response to an OnReceivedRedirect call. void FollowDeferredRedirect(); diff --git a/net/url_request/url_request_http_job.cc b/net/url_request/url_request_http_job.cc index ef17774..1b11817 100644 --- a/net/url_request/url_request_http_job.cc +++ b/net/url_request/url_request_http_job.cc @@ -429,6 +429,11 @@ bool URLRequestHttpJob::ReadRawData(net::IOBuffer* buf, int buf_size, return false; } +void URLRequestHttpJob::StopCaching() { + if (transaction_.get()) + transaction_->StopCaching(); +} + void URLRequestHttpJob::OnCanGetCookiesCompleted(int policy) { // If the request was destroyed, then there is no more work to do. if (request_ && request_->delegate()) { diff --git a/net/url_request/url_request_http_job.h b/net/url_request/url_request_http_job.h index e00e3c4..4233c6e 100644 --- a/net/url_request/url_request_http_job.h +++ b/net/url_request/url_request_http_job.h @@ -55,6 +55,7 @@ class URLRequestHttpJob : public URLRequestJob { virtual void ContinueWithCertificate(net::X509Certificate* client_cert); virtual void ContinueDespiteLastError(); virtual bool ReadRawData(net::IOBuffer* buf, int buf_size, int *bytes_read); + virtual void StopCaching(); // Shadows URLRequestJob's version of this method so we can grab cookies. void NotifyHeadersComplete(); diff --git a/net/url_request/url_request_job.cc b/net/url_request/url_request_job.cc index 63611fd..75f357b 100644 --- a/net/url_request/url_request_job.cc +++ b/net/url_request/url_request_job.cc @@ -190,6 +190,10 @@ bool URLRequestJob::Read(net::IOBuffer* buf, int buf_size, int *bytes_read) { return rv; } +void URLRequestJob::StopCaching() { + // Nothing to do here. +} + bool URLRequestJob::ReadRawDataForFilter(int *bytes_read) { bool rv = false; diff --git a/net/url_request/url_request_job.h b/net/url_request/url_request_job.h index 2aeb8ff..0131428 100644 --- a/net/url_request/url_request_job.h +++ b/net/url_request/url_request_job.h @@ -90,7 +90,11 @@ class URLRequestJob : public base::RefCountedThreadSafe<URLRequestJob>, // bytes read, 0 when there is no more data, or -1 if there was an error. // This is just the backend for URLRequest::Read, see that function for more // info. - bool Read(net::IOBuffer* buf, int buf_size, int *bytes_read); + bool Read(net::IOBuffer* buf, int buf_size, int* bytes_read); + + // Stops further caching of this request, if any. For more info, see + // URLRequest::StopCaching(). + virtual void StopCaching(); // Called to fetch the current load state for the job. virtual net::LoadState GetLoadState() const { return net::LOAD_STATE_IDLE; } |