summaryrefslogtreecommitdiffstats
path: root/net/http
diff options
context:
space:
mode:
authormbelshe@google.com <mbelshe@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-25 21:04:45 +0000
committermbelshe@google.com <mbelshe@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-25 21:04:45 +0000
commitf533387862c3b2c8148cfac88ecee15d7c88804d (patch)
tree7f3f88c2c3cf1b4122b0f327cc55a6c4333ed500 /net/http
parente11ad233f8c0d4c7ce78ae994a3a440730d4a28c (diff)
downloadchromium_src-f533387862c3b2c8148cfac88ecee15d7c88804d.zip
chromium_src-f533387862c3b2c8148cfac88ecee15d7c88804d.tar.gz
chromium_src-f533387862c3b2c8148cfac88ecee15d7c88804d.tar.bz2
Refactor function to unpack an Entry from its pickle to a HttpResponseInfo.
This will be used for some dump_cache modifications which are coming. BUG=none TEST=none Review URL: http://codereview.chromium.org/174388 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@24319 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/http')
-rw-r--r--net/http/http_cache.cc30
-rw-r--r--net/http/http_cache.h4
2 files changed, 22 insertions, 12 deletions
diff --git a/net/http/http_cache.cc b/net/http/http_cache.cc
index 338a323..73e1ffa 100644
--- a/net/http/http_cache.cc
+++ b/net/http/http_cache.cc
@@ -1634,18 +1634,9 @@ void HttpCache::Suspend(bool suspend) {
}
// static
-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);
- if (rv != size) {
- DLOG(ERROR) << "ReadData failed: " << rv;
- return false;
- }
-
- Pickle pickle(buffer->data(), size);
+bool HttpCache::ParseResponseInfo(const char* data, int len,
+ HttpResponseInfo* response_info) {
+ Pickle pickle(data, len);
void* iter = NULL;
// read flags and verify version
@@ -1702,6 +1693,21 @@ bool HttpCache::ReadResponseInfo(disk_cache::Entry* disk_entry,
}
// static
+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);
+ if (rv != size) {
+ DLOG(ERROR) << "ReadData failed: " << rv;
+ return false;
+ }
+
+ return ParseResponseInfo(buffer->data(), size, response_info);
+}
+
+// static
bool HttpCache::WriteResponseInfo(disk_cache::Entry* disk_entry,
const HttpResponseInfo* response_info,
bool skip_transient_headers) {
diff --git a/net/http/http_cache.h b/net/http/http_cache.h
index af5c55e..5036e6a 100644
--- a/net/http/http_cache.h
+++ b/net/http/http_cache.h
@@ -106,6 +106,10 @@ class HttpCache : public HttpTransactionFactory {
const HttpResponseInfo* response_info,
bool skip_transient_headers);
+ // Given a header data blob, convert it to a response info object.
+ static bool ParseResponseInfo(const char* data, int len,
+ HttpResponseInfo* response_info);
+
// Get/Set the cache's mode.
void set_mode(Mode value) { mode_ = value; }
Mode mode() { return mode_; }