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

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

Issue 149306: Disk cache: Add explicit support for eviction / deletion... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years, 5 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
« no previous file with comments | « no previous file | net/disk_cache/disk_format.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/block_files.h" 5 #include "net/disk_cache/block_files.h"
6 6
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/histogram.h" 8 #include "base/histogram.h"
9 #include "base/string_util.h" 9 #include "base/string_util.h"
10 #include "base/time.h" 10 #include "base/time.h"
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 254
255 if (header->updating) { 255 if (header->updating) {
256 // Last instance was not properly shutdown. 256 // Last instance was not properly shutdown.
257 if (!FixBlockFileHeader(file)) 257 if (!FixBlockFileHeader(file))
258 return false; 258 return false;
259 } 259 }
260 return true; 260 return true;
261 } 261 }
262 262
263 MappedFile* BlockFiles::GetFile(Addr address) { 263 MappedFile* BlockFiles::GetFile(Addr address) {
264 CHECK(block_files_.size() >= 4); 264 DCHECK(block_files_.size() >= 4);
265 DCHECK(address.is_block_file() || !address.is_initialized());
266 if (!address.is_initialized())
267 return NULL;
265 268
266 int file_index = address.FileNumber(); 269 int file_index = address.FileNumber();
267 if (static_cast<unsigned int>(file_index) >= block_files_.size() || 270 if (static_cast<unsigned int>(file_index) >= block_files_.size() ||
268 !block_files_[file_index]) { 271 !block_files_[file_index]) {
269 // We need to open the file 272 // We need to open the file
270 if (!OpenBlockFile(file_index)) 273 if (!OpenBlockFile(file_index))
271 return NULL; 274 return NULL;
272 } 275 }
273 DCHECK(block_files_.size() >= static_cast<unsigned int>(file_index)); 276 DCHECK(block_files_.size() >= static_cast<unsigned int>(file_index));
274 return block_files_[file_index]; 277 return block_files_[file_index];
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
430 int num_entries = (file_size - sizeof(*header)) / header->entry_size; 433 int num_entries = (file_size - sizeof(*header)) / header->entry_size;
431 header->max_entries = num_entries; 434 header->max_entries = num_entries;
432 } 435 }
433 436
434 FixAllocationCounters(header); 437 FixAllocationCounters(header);
435 header->updating = 0; 438 header->updating = 0;
436 return true; 439 return true;
437 } 440 }
438 441
439 } // namespace disk_cache 442 } // namespace disk_cache
OLDNEW
« no previous file with comments | « no previous file | net/disk_cache/disk_format.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698