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

Side by Side Diff: net/disk_cache/simple/simple_synchronous_entry.cc

Issue 24400004: Simple Cache: Add two optional stream 2 histograms (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: rebase Created 7 years, 2 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
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/simple/simple_synchronous_entry.h" 5 #include "net/disk_cache/simple/simple_synchronous_entry.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cstring> 8 #include <cstring>
9 #include <functional> 9 #include <functional>
10 #include <limits> 10 #include <limits>
(...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after
475 const int64 file_size = entry_stat.GetFileSize(key_, i); 475 const int64 file_size = entry_stat.GetFileSize(key_, i);
476 SIMPLE_CACHE_UMA(CUSTOM_COUNTS, 476 SIMPLE_CACHE_UMA(CUSTOM_COUNTS,
477 "LastClusterSize", cache_type_, 477 "LastClusterSize", cache_type_,
478 file_size % 4096, 0, 4097, 50); 478 file_size % 4096, 0, 4097, 50);
479 const int64 cluster_loss = file_size % 4096 ? 4096 - file_size % 4096 : 0; 479 const int64 cluster_loss = file_size % 4096 ? 4096 - file_size % 4096 : 0;
480 SIMPLE_CACHE_UMA(PERCENTAGE, 480 SIMPLE_CACHE_UMA(PERCENTAGE,
481 "LastClusterLossPercent", cache_type_, 481 "LastClusterLossPercent", cache_type_,
482 cluster_loss * 100 / (cluster_loss + file_size)); 482 cluster_loss * 100 / (cluster_loss + file_size));
483 } 483 }
484 484
485 if (files_created_) {
486 const int stream2_file_index = GetFileIndexFromStreamIndex(2);
487 SIMPLE_CACHE_UMA(BOOLEAN, "EntryCreatedAndStream2Omitted", cache_type_,
488 empty_file_omitted_[stream2_file_index]);
489 }
490
485 RecordCloseResult(cache_type_, CLOSE_RESULT_SUCCESS); 491 RecordCloseResult(cache_type_, CLOSE_RESULT_SUCCESS);
486 have_open_files_ = false; 492 have_open_files_ = false;
487 delete this; 493 delete this;
488 } 494 }
489 495
490 SimpleSynchronousEntry::SimpleSynchronousEntry(net::CacheType cache_type, 496 SimpleSynchronousEntry::SimpleSynchronousEntry(net::CacheType cache_type,
491 const FilePath& path, 497 const FilePath& path,
492 const std::string& key, 498 const std::string& key,
493 const uint64 entry_hash) 499 const uint64 entry_hash)
494 : cache_type_(cache_type), 500 : cache_type_(cache_type),
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
615 // data_size(2). In the case of file 0, it is the combined size of stream 621 // data_size(2). In the case of file 0, it is the combined size of stream
616 // 0, stream 1 and one EOF record. The exact distribution of sizes between 622 // 0, stream 1 and one EOF record. The exact distribution of sizes between
617 // stream 1 and stream 0 is only determined after reading the EOF record 623 // stream 1 and stream 0 is only determined after reading the EOF record
618 // for stream 0 in ReadAndValidateStream0. 624 // for stream 0 in ReadAndValidateStream0.
619 out_entry_stat->set_data_size(i + 1, file_info.size); 625 out_entry_stat->set_data_size(i + 1, file_info.size);
620 } 626 }
621 SIMPLE_CACHE_UMA(CUSTOM_COUNTS, 627 SIMPLE_CACHE_UMA(CUSTOM_COUNTS,
622 "SyncOpenEntryAge", cache_type_, 628 "SyncOpenEntryAge", cache_type_,
623 entry_age.InHours(), 1, 1000, 50); 629 entry_age.InHours(), 1, 1000, 50);
624 630
631 files_created_ = false;
632
625 return true; 633 return true;
626 } 634 }
627 635
628 bool SimpleSynchronousEntry::CreateFiles( 636 bool SimpleSynchronousEntry::CreateFiles(
629 bool had_index, 637 bool had_index,
630 SimpleEntryStat* out_entry_stat) { 638 SimpleEntryStat* out_entry_stat) {
631 for (int i = 0; i < kSimpleEntryFileCount; ++i) { 639 for (int i = 0; i < kSimpleEntryFileCount; ++i) {
632 PlatformFileError error; 640 PlatformFileError error;
633 if (!MaybeCreateFile(i, FILE_NOT_REQUIRED, &error)) { 641 if (!MaybeCreateFile(i, FILE_NOT_REQUIRED, &error)) {
634 // TODO(ttuttle,gavinp): Remove one each of these triplets of histograms. 642 // TODO(ttuttle,gavinp): Remove one each of these triplets of histograms.
(...skipping 19 matching lines...) Expand all
654 } 662 }
655 663
656 have_open_files_ = true; 664 have_open_files_ = true;
657 665
658 base::Time creation_time = Time::Now(); 666 base::Time creation_time = Time::Now();
659 out_entry_stat->set_last_modified(creation_time); 667 out_entry_stat->set_last_modified(creation_time);
660 out_entry_stat->set_last_used(creation_time); 668 out_entry_stat->set_last_used(creation_time);
661 for (int i = 0; i < kSimpleEntryStreamCount; ++i) 669 for (int i = 0; i < kSimpleEntryStreamCount; ++i)
662 out_entry_stat->set_data_size(i, 0); 670 out_entry_stat->set_data_size(i, 0);
663 671
672 files_created_ = true;
673
664 return true; 674 return true;
665 } 675 }
666 676
667 void SimpleSynchronousEntry::CloseFile(int index) { 677 void SimpleSynchronousEntry::CloseFile(int index) {
668 if (empty_file_omitted_[index]) { 678 if (empty_file_omitted_[index]) {
669 empty_file_omitted_[index] = false; 679 empty_file_omitted_[index] = false;
670 } else { 680 } else {
671 DCHECK_NE(kInvalidPlatformFileValue, files_[index]); 681 DCHECK_NE(kInvalidPlatformFileValue, files_[index]);
672 bool did_close = ClosePlatformFile(files_[index]); 682 bool did_close = ClosePlatformFile(files_[index]);
673 DCHECK(did_close); 683 DCHECK(did_close);
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
747 } 757 }
748 758
749 if (base::Hash(key.get(), header.key_length) != header.key_hash) { 759 if (base::Hash(key.get(), header.key_length) != header.key_hash) {
750 DLOG(WARNING) << "Hash mismatch on key."; 760 DLOG(WARNING) << "Hash mismatch on key.";
751 RecordSyncOpenResult( 761 RecordSyncOpenResult(
752 cache_type_, OPEN_ENTRY_KEY_HASH_MISMATCH, had_index); 762 cache_type_, OPEN_ENTRY_KEY_HASH_MISMATCH, had_index);
753 return net::ERR_FAILED; 763 return net::ERR_FAILED;
754 } 764 }
755 } 765 }
756 766
767 bool removed_stream2 = false;
757 const int stream2_file_index = GetFileIndexFromStreamIndex(2); 768 const int stream2_file_index = GetFileIndexFromStreamIndex(2);
758 DCHECK(CanOmitEmptyFile(stream2_file_index)); 769 DCHECK(CanOmitEmptyFile(stream2_file_index));
759 if (!empty_file_omitted_[stream2_file_index] && 770 if (!empty_file_omitted_[stream2_file_index] &&
760 out_entry_stat->data_size(2) == 0) { 771 out_entry_stat->data_size(2) == 0) {
761 DLOG(INFO) << "Removing empty stream 2 file."; 772 DLOG(INFO) << "Removing empty stream 2 file.";
762 CloseFile(stream2_file_index); 773 CloseFile(stream2_file_index);
763 DeleteFileForEntryHash(path_, entry_hash_, stream2_file_index); 774 DeleteFileForEntryHash(path_, entry_hash_, stream2_file_index);
764 empty_file_omitted_[stream2_file_index] = true; 775 empty_file_omitted_[stream2_file_index] = true;
776 removed_stream2 = true;
765 } 777 }
766 778
779 SIMPLE_CACHE_UMA(BOOLEAN, "EntryOpenedAndStream2Removed", cache_type_,
780 removed_stream2);
781
767 RecordSyncOpenResult(cache_type_, OPEN_ENTRY_SUCCESS, had_index); 782 RecordSyncOpenResult(cache_type_, OPEN_ENTRY_SUCCESS, had_index);
768 initialized_ = true; 783 initialized_ = true;
769 return net::OK; 784 return net::OK;
770 } 785 }
771 786
772 bool SimpleSynchronousEntry::InitializeCreatedFile( 787 bool SimpleSynchronousEntry::InitializeCreatedFile(
773 int file_index, 788 int file_index,
774 CreateEntryResult* out_result) { 789 CreateEntryResult* out_result) {
775 SimpleFileHeader header; 790 SimpleFileHeader header;
776 header.initial_magic_number = kSimpleInitialMagicNumber; 791 header.initial_magic_number = kSimpleInitialMagicNumber;
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
942 result, CREATE_ENTRY_MAX); 957 result, CREATE_ENTRY_MAX);
943 } 958 }
944 } 959 }
945 960
946 FilePath SimpleSynchronousEntry::GetFilenameFromFileIndex(int file_index) { 961 FilePath SimpleSynchronousEntry::GetFilenameFromFileIndex(int file_index) {
947 return path_.AppendASCII( 962 return path_.AppendASCII(
948 GetFilenameFromEntryHashAndFileIndex(entry_hash_, file_index)); 963 GetFilenameFromEntryHashAndFileIndex(entry_hash_, file_index));
949 } 964 }
950 965
951 } // namespace disk_cache 966 } // namespace disk_cache
OLDNEW
« no previous file with comments | « net/disk_cache/simple/simple_synchronous_entry.h ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698