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

Side by Side Diff: net/disk_cache/mem_entry_impl.cc

Issue 119072: Disk cache: Interface for the sparse cache support.... (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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/disk_cache/mem_entry_impl.h" 5 #include "net/disk_cache/mem_entry_impl.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "net/base/io_buffer.h" 8 #include "net/base/io_buffer.h"
9 #include "net/base/net_errors.h" 9 #include "net/base/net_errors.h"
10 #include "net/disk_cache/mem_backend_impl.h" 10 #include "net/disk_cache/mem_backend_impl.h"
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 143
144 UpdateRank(true); 144 UpdateRank(true);
145 145
146 if (!buf_len) 146 if (!buf_len)
147 return 0; 147 return 0;
148 148
149 memcpy(&(data_[index])[offset], buf->data(), buf_len); 149 memcpy(&(data_[index])[offset], buf->data(), buf_len);
150 return buf_len; 150 return buf_len;
151 } 151 }
152 152
153 int MemEntryImpl::ReadSparseData(int64 offset, net::IOBuffer* buf, int buf_len,
154 net::CompletionCallback* completion_callback) {
155 return net::ERR_CACHE_OPERATION_NOT_SUPPORTED;
156 }
157
158 int MemEntryImpl::WriteSparseData(int64 offset, net::IOBuffer* buf, int buf_len,
159 net::CompletionCallback* completion_callback) {
160 return net::ERR_CACHE_OPERATION_NOT_SUPPORTED;
161 }
162
163 int MemEntryImpl::GetAvailableRange(int64 offset, int len, int64* start) {
164 return net::ERR_CACHE_OPERATION_NOT_SUPPORTED;
165 }
166
153 void MemEntryImpl::PrepareTarget(int index, int offset, int buf_len) { 167 void MemEntryImpl::PrepareTarget(int index, int offset, int buf_len) {
154 int entry_size = GetDataSize(index); 168 int entry_size = GetDataSize(index);
155 169
156 if (entry_size >= offset + buf_len) 170 if (entry_size >= offset + buf_len)
157 return; // Not growing the stored data. 171 return; // Not growing the stored data.
158 172
159 if (static_cast<int>(data_[index].size()) < offset + buf_len) 173 if (static_cast<int>(data_[index].size()) < offset + buf_len)
160 data_[index].resize(offset + buf_len); 174 data_[index].resize(offset + buf_len);
161 175
162 if (offset <= entry_size) 176 if (offset <= entry_size)
163 return; // There is no "hole" on the stored data. 177 return; // There is no "hole" on the stored data.
164 178
165 // Cleanup the hole not written by the user. The point is to avoid returning 179 // Cleanup the hole not written by the user. The point is to avoid returning
166 // random stuff later on. 180 // random stuff later on.
167 memset(&(data_[index])[entry_size], 0, offset - entry_size); 181 memset(&(data_[index])[entry_size], 0, offset - entry_size);
168 } 182 }
169 183
170 void MemEntryImpl::UpdateRank(bool modified) { 184 void MemEntryImpl::UpdateRank(bool modified) {
171 Time current = Time::Now(); 185 Time current = Time::Now();
172 last_used_ = current; 186 last_used_ = current;
173 187
174 if (modified) 188 if (modified)
175 last_modified_ = current; 189 last_modified_ = current;
176 190
177 if (!doomed_) 191 if (!doomed_)
178 backend_->UpdateRank(this); 192 backend_->UpdateRank(this);
179 } 193 }
180 194
181 } // namespace disk_cache 195 } // namespace disk_cache
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698