summaryrefslogtreecommitdiffstats
path: root/net/http/http_cache.cc
diff options
context:
space:
mode:
authorrvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-01-24 01:54:05 +0000
committerrvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-01-24 01:54:05 +0000
commit1f8859ad6ec7ea807c0330ddf5559e13be5fb26c (patch)
tree68887107d0d40f1b22c7a7a07ccd9d7e4caf157a /net/http/http_cache.cc
parent13dc122db24457653d57ff07791043d518eb05e7 (diff)
downloadchromium_src-1f8859ad6ec7ea807c0330ddf5559e13be5fb26c.zip
chromium_src-1f8859ad6ec7ea807c0330ddf5559e13be5fb26c.tar.gz
chromium_src-1f8859ad6ec7ea807c0330ddf5559e13be5fb26c.tar.bz2
Change URLRequest to use a ref-counted buffer for actual IO.The ref-counting will prevent the deletion / reuse of memorywhile the buffer is actually being used by pending IO.This seems a very intrusive change, but at least we will be ableto make sure that it works without having to chase every singledestruction of an URLRequest to make sure that any pending IOwas cancelled, and also allows us to avoid blocking onthe object destruction.BUG=5325
Review URL: http://codereview.chromium.org/18390 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@8603 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/http/http_cache.cc')
-rw-r--r--net/http/http_cache.cc18
1 files changed, 11 insertions, 7 deletions
diff --git a/net/http/http_cache.cc b/net/http/http_cache.cc
index 7edc0a8..fe0a130 100644
--- a/net/http/http_cache.cc
+++ b/net/http/http_cache.cc
@@ -190,7 +190,7 @@ class HttpCache::Transaction : public HttpTransaction {
virtual int RestartWithAuth(const std::wstring& username,
const std::wstring& password,
CompletionCallback* callback);
- virtual int Read(char* buf, int buf_len, CompletionCallback*);
+ virtual int Read(IOBuffer* buf, int buf_len, CompletionCallback*);
virtual const HttpResponseInfo* GetResponseInfo() const;
virtual LoadState GetLoadState() const;
virtual uint64 GetUploadProgress(void) const;
@@ -411,7 +411,7 @@ int HttpCache::Transaction::RestartWithAuth(
return rv;
}
-int HttpCache::Transaction::Read(char* buf, int buf_len,
+int HttpCache::Transaction::Read(IOBuffer* buf, int buf_len,
CompletionCallback* callback) {
DCHECK(buf);
DCHECK(buf_len > 0);
@@ -435,20 +435,23 @@ int HttpCache::Transaction::Read(char* buf, int buf_len,
case WRITE:
DCHECK(network_trans_.get());
rv = network_trans_->Read(buf, buf_len, &network_read_callback_);
- read_buf_ = buf;
+ read_buf_ = buf->data();
if (rv >= 0)
OnNetworkReadCompleted(rv);
break;
case READ:
DCHECK(entry_);
- cache_read_callback_->AddRef(); // Balanced in OnCacheReadCompleted
+ cache_read_callback_->AddRef(); // Balanced in OnCacheReadCompleted.
+ cache_read_callback_->UseBuffer(buf);
rv = entry_->disk_entry->ReadData(kResponseContentIndex, read_offset_,
- buf, buf_len, cache_read_callback_);
- read_buf_ = buf;
+ buf->data(), buf_len,
+ cache_read_callback_);
+ read_buf_ = buf->data();
if (rv >= 0) {
OnCacheReadCompleted(rv);
} else if (rv != ERR_IO_PENDING) {
cache_read_callback_->Release();
+ cache_read_callback_->ReleaseBuffer();
}
break;
default:
@@ -903,7 +906,8 @@ void HttpCache::Transaction::OnNetworkReadCompleted(int result) {
void HttpCache::Transaction::OnCacheReadCompleted(int result) {
DCHECK(cache_);
- cache_read_callback_->Release(); // Balance the AddRef() from Start()
+ cache_read_callback_->Release(); // Balance the AddRef() from Start().
+ cache_read_callback_->ReleaseBuffer();
if (result > 0) {
read_offset_ += result;