Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(338)

Unified Diff: net/http/http_cache.cc

Issue 21236: Revert cl 9528 to fix mac test_shell_tests (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/disk_cache/stress_cache.cc ('k') | net/http/http_cache_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/http/http_cache.cc
===================================================================
--- net/http/http_cache.cc (revision 9528)
+++ net/http/http_cache.cc (working copy)
@@ -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 @@
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 @@
// 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 @@
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 @@
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 @@
}
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::AppendResponseDataToEntry(IOBuffer* data,
+void HttpCache::Transaction::AppendResponseDataToEntry(const char* data,
int data_len) {
if (!entry_)
return;
@@ -906,6 +909,7 @@
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 @@
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 @@
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,
« no previous file with comments | « net/disk_cache/stress_cache.cc ('k') | net/http/http_cache_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698