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

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

Issue 48112: Disk cache: First implementation of TrimDeleted() and a few... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years, 9 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/entry_impl.h" 5 #include "net/disk_cache/entry_impl.h"
6 6
7 #include "base/histogram.h" 7 #include "base/histogram.h"
8 #include "base/message_loop.h" 8 #include "base/message_loop.h"
9 #include "base/string_util.h" 9 #include "base/string_util.h"
10 #include "net/base/io_buffer.h" 10 #include "net/base/io_buffer.h"
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 base::PlatformFile EntryImpl::GetPlatformFile(int index) { 375 base::PlatformFile EntryImpl::GetPlatformFile(int index) {
376 DCHECK(index >= 0 && index < NUM_STREAMS); 376 DCHECK(index >= 0 && index < NUM_STREAMS);
377 377
378 Addr address(entry_.Data()->data_addr[index]); 378 Addr address(entry_.Data()->data_addr[index]);
379 if (!address.is_initialized() || !address.is_separate_file()) 379 if (!address.is_initialized() || !address.is_separate_file())
380 return base::kInvalidPlatformFileValue; 380 return base::kInvalidPlatformFileValue;
381 381
382 return base::CreatePlatformFile(backend_->GetFileName(address), 382 return base::CreatePlatformFile(backend_->GetFileName(address),
383 base::PLATFORM_FILE_OPEN | 383 base::PLATFORM_FILE_OPEN |
384 base::PLATFORM_FILE_READ | 384 base::PLATFORM_FILE_READ |
385 base::PLATFORM_FILE_ASYNC, 385 base::PLATFORM_FILE_ASYNC,
386 NULL); 386 NULL);
387 } 387 }
388 388
389 uint32 EntryImpl::GetHash() { 389 uint32 EntryImpl::GetHash() {
390 return entry_.Data()->hash; 390 return entry_.Data()->hash;
391 } 391 }
392 392
393 bool EntryImpl::CreateEntry(Addr node_address, const std::string& key, 393 bool EntryImpl::CreateEntry(Addr node_address, const std::string& key,
394 uint32 hash) { 394 uint32 hash) {
395 Trace("Create entry In"); 395 Trace("Create entry In");
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
450 if (!node_.Data()->dirty) { 450 if (!node_.Data()->dirty) {
451 node_.Data()->dirty = backend_->GetCurrentEntryId(); 451 node_.Data()->dirty = backend_->GetCurrentEntryId();
452 node_.Store(); 452 node_.Store();
453 } 453 }
454 doomed_ = true; 454 doomed_ = true;
455 } 455 }
456 456
457 void EntryImpl::DeleteEntryData(bool everything) { 457 void EntryImpl::DeleteEntryData(bool everything) {
458 DCHECK(doomed_ || !everything); 458 DCHECK(doomed_ || !everything);
459 459
460 UMA_HISTOGRAM_COUNTS("DiskCache.DeleteHeader", GetDataSize(0)); 460 if (GetDataSize(0))
461 UMA_HISTOGRAM_COUNTS("DiskCache.DeleteData", GetDataSize(1)); 461 UMA_HISTOGRAM_COUNTS("DiskCache.DeleteHeader", GetDataSize(0));
462 if (GetDataSize(1))
463 UMA_HISTOGRAM_COUNTS("DiskCache.DeleteData", GetDataSize(1));
462 for (int index = 0; index < NUM_STREAMS; index++) { 464 for (int index = 0; index < NUM_STREAMS; index++) {
463 Addr address(entry_.Data()->data_addr[index]); 465 Addr address(entry_.Data()->data_addr[index]);
464 if (address.is_initialized()) { 466 if (address.is_initialized()) {
465 DeleteData(address, index); 467 DeleteData(address, index);
466 backend_->ModifyStorageSize(entry_.Data()->data_size[index] - 468 backend_->ModifyStorageSize(entry_.Data()->data_size[index] -
467 unreported_size_[index], 0); 469 unreported_size_[index], 0);
470 entry_.Data()->data_addr[index] = 0;
471 entry_.Data()->data_size[index] = 0;
468 } 472 }
469 } 473 }
470 474
471 if (!everything) 475 if (!everything) {
476 entry_.Store();
472 return; 477 return;
478 }
473 479
474 // Remove all traces of this entry. 480 // Remove all traces of this entry.
475 backend_->RemoveEntry(this); 481 backend_->RemoveEntry(this);
476 482
477 Addr address(entry_.Data()->long_key); 483 Addr address(entry_.Data()->long_key);
478 DeleteData(address, kKeyFileIndex); 484 DeleteData(address, kKeyFileIndex);
479 backend_->ModifyStorageSize(entry_.Data()->key_len, 0); 485 backend_->ModifyStorageSize(entry_.Data()->key_len, 0);
480 486
481 memset(node_.buffer(), 0, node_.size()); 487 memset(node_.buffer(), 0, node_.size());
482 memset(entry_.buffer(), 0, entry_.size()); 488 memset(entry_.buffer(), 0, entry_.size());
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after
842 Trace("%s 0x%p 0x%x 0x%x", msg, reinterpret_cast<void*>(this), 848 Trace("%s 0x%p 0x%x 0x%x", msg, reinterpret_cast<void*>(this),
843 entry_.address().value(), node_.address().value()); 849 entry_.address().value(), node_.address().value());
844 850
845 Trace(" data: 0x%x 0x%x 0x%x", entry_.Data()->data_addr[0], 851 Trace(" data: 0x%x 0x%x 0x%x", entry_.Data()->data_addr[0],
846 entry_.Data()->data_addr[1], entry_.Data()->long_key); 852 entry_.Data()->data_addr[1], entry_.Data()->long_key);
847 853
848 Trace(" doomed: %d 0x%p 0x%x", doomed_, pointer, dirty); 854 Trace(" doomed: %d 0x%p 0x%x", doomed_, pointer, dirty);
849 } 855 }
850 856
851 } // namespace disk_cache 857 } // namespace disk_cache
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698