| OLD | NEW |
| 1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2009 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 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 377 } | 377 } |
| 378 | 378 |
| 379 int EntryImpl::GetAvailableRange(int64 offset, int len, int64* start) { | 379 int EntryImpl::GetAvailableRange(int64 offset, int len, int64* start) { |
| 380 int result = InitSparseData(); | 380 int result = InitSparseData(); |
| 381 if (net::OK != result) | 381 if (net::OK != result) |
| 382 return result; | 382 return result; |
| 383 | 383 |
| 384 return sparse_->GetAvailableRange(offset, len, start); | 384 return sparse_->GetAvailableRange(offset, len, start); |
| 385 } | 385 } |
| 386 | 386 |
| 387 // ------------------------------------------------------------------------ |
| 388 |
| 387 uint32 EntryImpl::GetHash() { | 389 uint32 EntryImpl::GetHash() { |
| 388 return entry_.Data()->hash; | 390 return entry_.Data()->hash; |
| 389 } | 391 } |
| 390 | 392 |
| 391 bool EntryImpl::CreateEntry(Addr node_address, const std::string& key, | 393 bool EntryImpl::CreateEntry(Addr node_address, const std::string& key, |
| 392 uint32 hash) { | 394 uint32 hash) { |
| 393 Trace("Create entry In"); | 395 Trace("Create entry In"); |
| 394 EntryStore* entry_store = entry_.Data(); | 396 EntryStore* entry_store = entry_.Data(); |
| 395 RankingsNode* node = node_.Data(); | 397 RankingsNode* node = node_.Data(); |
| 396 memset(entry_store, 0, sizeof(EntryStore) * entry_.address().num_blocks()); | 398 memset(entry_store, 0, sizeof(EntryStore) * entry_.address().num_blocks()); |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 568 void EntryImpl::DecrementIoCount() { | 570 void EntryImpl::DecrementIoCount() { |
| 569 backend_->DecrementIoCount(); | 571 backend_->DecrementIoCount(); |
| 570 } | 572 } |
| 571 | 573 |
| 572 void EntryImpl::SetTimes(base::Time last_used, base::Time last_modified) { | 574 void EntryImpl::SetTimes(base::Time last_used, base::Time last_modified) { |
| 573 node_.Data()->last_used = last_used.ToInternalValue(); | 575 node_.Data()->last_used = last_used.ToInternalValue(); |
| 574 node_.Data()->last_modified = last_modified.ToInternalValue(); | 576 node_.Data()->last_modified = last_modified.ToInternalValue(); |
| 575 node_.set_modified(); | 577 node_.set_modified(); |
| 576 } | 578 } |
| 577 | 579 |
| 580 void EntryImpl::ReportIOTime(Operation op, const base::Time& start) { |
| 581 int group = backend_->GetSizeGroup(); |
| 582 switch (op) { |
| 583 case kRead: |
| 584 CACHE_UMA(AGE_MS, "ReadTime", group, start); |
| 585 break; |
| 586 case kWrite: |
| 587 CACHE_UMA(AGE_MS, "WriteTime", group, start); |
| 588 break; |
| 589 case kSparseRead: |
| 590 CACHE_UMA(AGE_MS, "SparseReadTime", 0, start); |
| 591 break; |
| 592 case kSparseWrite: |
| 593 CACHE_UMA(AGE_MS, "SparseWriteTime", 0, start); |
| 594 break; |
| 595 case kAsyncIO: |
| 596 CACHE_UMA(AGE_MS, "AsyncIOTime", group, start); |
| 597 break; |
| 598 default: |
| 599 NOTREACHED(); |
| 600 } |
| 601 } |
| 602 |
| 603 // ------------------------------------------------------------------------ |
| 604 |
| 578 bool EntryImpl::CreateDataBlock(int index, int size) { | 605 bool EntryImpl::CreateDataBlock(int index, int size) { |
| 579 DCHECK(index >= 0 && index < kNumStreams); | 606 DCHECK(index >= 0 && index < kNumStreams); |
| 580 | 607 |
| 581 Addr address(entry_.Data()->data_addr[index]); | 608 Addr address(entry_.Data()->data_addr[index]); |
| 582 if (!CreateBlock(size, &address)) | 609 if (!CreateBlock(size, &address)) |
| 583 return false; | 610 return false; |
| 584 | 611 |
| 585 entry_.Data()->data_addr[index] = address.value(); | 612 entry_.Data()->data_addr[index] = address.value(); |
| 586 entry_.Store(); | 613 entry_.Store(); |
| 587 return true; | 614 return true; |
| (...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 861 address->set_value(entry_.Data()->data_addr[index]); | 888 address->set_value(entry_.Data()->data_addr[index]); |
| 862 if (address->is_initialized()) { | 889 if (address->is_initialized()) { |
| 863 // Prevent us from deleting the block from the backing store. | 890 // Prevent us from deleting the block from the backing store. |
| 864 backend_->ModifyStorageSize(entry_.Data()->data_size[index] - | 891 backend_->ModifyStorageSize(entry_.Data()->data_size[index] - |
| 865 unreported_size_[index], 0); | 892 unreported_size_[index], 0); |
| 866 entry_.Data()->data_addr[index] = 0; | 893 entry_.Data()->data_addr[index] = 0; |
| 867 entry_.Data()->data_size[index] = 0; | 894 entry_.Data()->data_size[index] = 0; |
| 868 } | 895 } |
| 869 } | 896 } |
| 870 | 897 |
| 871 void EntryImpl::ReportIOTime(Operation op, const base::Time& start) { | |
| 872 int group = backend_->GetSizeGroup(); | |
| 873 switch (op) { | |
| 874 case kRead: | |
| 875 CACHE_UMA(AGE_MS, "ReadTime", group, start); | |
| 876 break; | |
| 877 case kWrite: | |
| 878 CACHE_UMA(AGE_MS, "WriteTime", group, start); | |
| 879 break; | |
| 880 case kSparseRead: | |
| 881 CACHE_UMA(AGE_MS, "SparseReadTime", 0, start); | |
| 882 break; | |
| 883 case kSparseWrite: | |
| 884 CACHE_UMA(AGE_MS, "SparseWriteTime", 0, start); | |
| 885 break; | |
| 886 case kAsyncIO: | |
| 887 CACHE_UMA(AGE_MS, "AsyncIOTime", group, start); | |
| 888 break; | |
| 889 default: | |
| 890 NOTREACHED(); | |
| 891 } | |
| 892 } | |
| 893 | |
| 894 void EntryImpl::Log(const char* msg) { | 898 void EntryImpl::Log(const char* msg) { |
| 895 int dirty = 0; | 899 int dirty = 0; |
| 896 if (node_.HasData()) { | 900 if (node_.HasData()) { |
| 897 dirty = node_.Data()->dirty; | 901 dirty = node_.Data()->dirty; |
| 898 } | 902 } |
| 899 | 903 |
| 900 Trace("%s 0x%p 0x%x 0x%x", msg, reinterpret_cast<void*>(this), | 904 Trace("%s 0x%p 0x%x 0x%x", msg, reinterpret_cast<void*>(this), |
| 901 entry_.address().value(), node_.address().value()); | 905 entry_.address().value(), node_.address().value()); |
| 902 | 906 |
| 903 Trace(" data: 0x%x 0x%x 0x%x", entry_.Data()->data_addr[0], | 907 Trace(" data: 0x%x 0x%x 0x%x", entry_.Data()->data_addr[0], |
| 904 entry_.Data()->data_addr[1], entry_.Data()->long_key); | 908 entry_.Data()->data_addr[1], entry_.Data()->long_key); |
| 905 | 909 |
| 906 Trace(" doomed: %d 0x%x", doomed_, dirty); | 910 Trace(" doomed: %d 0x%x", doomed_, dirty); |
| 907 } | 911 } |
| 908 | 912 |
| 909 } // namespace disk_cache | 913 } // namespace disk_cache |
| OLD | NEW |