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-02-10 23:40:27 +0000
committerrvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-02-10 23:40:27 +0000
commitc12519fb92c4e6ae39b20376badc19c825d62d2c (patch)
tree659e1f599702c63ef54dcf4c262ea1995fc01b20 /net/http/http_cache.cc
parent0b9803cdd8e63251ad6485608dc7c00d439c0729 (diff)
downloadchromium_src-c12519fb92c4e6ae39b20376badc19c825d62d2c.zip
chromium_src-c12519fb92c4e6ae39b20376badc19c825d62d2c.tar.gz
chromium_src-c12519fb92c4e6ae39b20376badc19c825d62d2c.tar.bz2
Revert cl 9528 to fix mac test_shell_tests
Review URL: http://codereview.chromium.org/21236 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@9532 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/http/http_cache.cc')
-rw-r--r--net/http/http_cache.cc33
1 files changed, 19 insertions, 14 deletions
diff --git a/net/http/http_cache.cc b/net/http/http_cache.cc
index f1132fc..accd7da 100644
--- a/net/http/http_cache.cc
+++ b/net/http/http_cache.cc
@@ -12,7 +12,6 @@
#include "base/ref_counted.h"
#include "base/string_util.h"
#include "base/time.h"
-#include "net/base/io_buffer.h"
#include "net/base/load_flags.h"
#include "net/base/net_errors.h"
#include "net/disk_cache/disk_cache.h"
@@ -169,6 +168,7 @@ class HttpCache::Transaction : public HttpTransaction {
network_trans_(NULL),
callback_(NULL),
mode_(NONE),
+ read_buf_(NULL),
read_offset_(0),
effective_load_flags_(0),
final_upload_progress_(0),
@@ -278,13 +278,13 @@ class HttpCache::Transaction : public HttpTransaction {
// Called to write data to the cache entry. If the write fails, then the
// cache entry is destroyed. Future calls to this function will just do
// nothing without side-effect.
- void WriteToEntry(int index, int offset, IOBuffer* data, int data_len);
+ void WriteToEntry(int index, int offset, const char* data, int data_len);
// Called to write response_ to the cache entry.
void WriteResponseInfoToEntry();
// Called to append response data to the cache entry.
- void AppendResponseDataToEntry(IOBuffer* data, int data_len);
+ void AppendResponseDataToEntry(const char* data, int data_len);
// Called when we are done writing to the cache entry.
void DoneWritingToEntry(bool success);
@@ -308,7 +308,7 @@ class HttpCache::Transaction : public HttpTransaction {
HttpResponseInfo auth_response_;
std::string cache_key_;
Mode mode_;
- scoped_refptr<IOBuffer> read_buf_;
+ char* read_buf_;
int read_offset_;
int effective_load_flags_;
uint64 final_upload_progress_;
@@ -435,20 +435,23 @@ int HttpCache::Transaction::Read(IOBuffer* 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_->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:
@@ -774,7 +777,7 @@ int HttpCache::Transaction::ReadResponseInfoFromEntry() {
}
void HttpCache::Transaction::WriteToEntry(int index, int offset,
- IOBuffer* data, int data_len) {
+ const char* data, int data_len) {
if (!entry_)
return;
@@ -817,7 +820,7 @@ void HttpCache::Transaction::WriteResponseInfoToEntry() {
}
}
-void HttpCache::Transaction::AppendResponseDataToEntry(IOBuffer* data,
+void HttpCache::Transaction::AppendResponseDataToEntry(const char* data,
int data_len) {
if (!entry_)
return;
@@ -906,6 +909,7 @@ 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_->ReleaseBuffer();
if (result > 0) {
read_offset_ += result;
@@ -997,14 +1001,16 @@ bool HttpCache::ReadResponseInfo(disk_cache::Entry* disk_entry,
HttpResponseInfo* response_info) {
int size = disk_entry->GetDataSize(kResponseInfoIndex);
- scoped_refptr<IOBuffer> buffer = new IOBuffer(size);
- int rv = disk_entry->ReadData(kResponseInfoIndex, 0, buffer, size, NULL);
+ std::string data;
+ int rv = disk_entry->ReadData(kResponseInfoIndex, 0,
+ WriteInto(&data, size + 1),
+ size, NULL);
if (rv != size) {
DLOG(ERROR) << "ReadData failed: " << rv;
return false;
}
- Pickle pickle(buffer->data(), size);
+ Pickle pickle(data.data(), static_cast<int>(data.size()));
void* iter = NULL;
// read flags and verify version
@@ -1102,8 +1108,7 @@ bool HttpCache::WriteResponseInfo(disk_cache::Entry* disk_entry,
if (response_info->vary_data.is_valid())
response_info->vary_data.Persist(&pickle);
- scoped_refptr<WrappedIOBuffer> data = new WrappedIOBuffer(
- reinterpret_cast<const char*>(pickle.data()));
+ const char* data = static_cast<const char*>(pickle.data());
int len = static_cast<int>(pickle.size());
return disk_entry->WriteData(kResponseInfoIndex, 0, data, len, NULL,