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

Unified Diff: net/disk_cache/entry_impl.cc

Issue 132031: Disk cache: First pass to add support for sparse entries.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 6 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/entry_impl.h ('k') | net/disk_cache/entry_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/disk_cache/entry_impl.cc
===================================================================
--- net/disk_cache/entry_impl.cc (revision 18726)
+++ net/disk_cache/entry_impl.cc (working copy)
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// Copyright (c) 2006-2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -10,8 +10,10 @@
#include "net/base/io_buffer.h"
#include "net/base/net_errors.h"
#include "net/disk_cache/backend_impl.h"
+#include "net/disk_cache/bitmap.h"
#include "net/disk_cache/cache_util.h"
#include "net/disk_cache/histogram_macros.h"
+#include "net/disk_cache/sparse_control.h"
using base::Time;
using base::TimeDelta;
@@ -91,6 +93,9 @@
// data related to a previous cache entry because the range was not fully
// written before).
EntryImpl::~EntryImpl() {
+ // Save the sparse info to disk before deleting this entry.
+ sparse_.reset();
+
if (doomed_) {
DeleteEntryData(true);
} else {
@@ -353,16 +358,32 @@
int EntryImpl::ReadSparseData(int64 offset, net::IOBuffer* buf, int buf_len,
net::CompletionCallback* completion_callback) {
- return net::ERR_CACHE_OPERATION_NOT_SUPPORTED;
+ DCHECK(node_.Data()->dirty);
+ int result = InitSparseData();
+ if (net::OK != result)
+ return result;
+
+ return sparse_->StartIO(SparseControl::kReadOperation, offset, buf, buf_len,
+ completion_callback);
}
int EntryImpl::WriteSparseData(int64 offset, net::IOBuffer* buf, int buf_len,
net::CompletionCallback* completion_callback) {
- return net::ERR_CACHE_OPERATION_NOT_SUPPORTED;
+ DCHECK(node_.Data()->dirty);
+ int result = InitSparseData();
+ if (net::OK != result)
+ return result;
+
+ return sparse_->StartIO(SparseControl::kWriteOperation, offset, buf, buf_len,
+ completion_callback);
}
int EntryImpl::GetAvailableRange(int64 offset, int len, int64* start) {
- return net::ERR_CACHE_OPERATION_NOT_SUPPORTED;
+ int result = InitSparseData();
+ if (net::OK != result)
+ return result;
+
+ return sparse_->GetAvailableRange(offset, len, start);
}
uint32 EntryImpl::GetHash() {
@@ -813,6 +834,17 @@
return true;
}
+int EntryImpl::InitSparseData() {
+ if (sparse_.get())
+ return net::OK;
+
+ sparse_.reset(new SparseControl(this));
+ int result = sparse_->Init();
+ if (net::OK != result)
+ sparse_.reset();
+ return result;
+}
+
void EntryImpl::Log(const char* msg) {
void* pointer = NULL;
int dirty = 0;
« no previous file with comments | « net/disk_cache/entry_impl.h ('k') | net/disk_cache/entry_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698