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

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

Issue 178023: Disk cache: Add a histogram to measure the latency of... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years, 3 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
« net/disk_cache/entry_impl.h ('K') | « net/disk_cache/entry_impl.h ('k') | no next file » | 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-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 11 matching lines...) Expand all
22 22
23 // Index for the file used to store the key, if any (files_[kKeyFileIndex]). 23 // Index for the file used to store the key, if any (files_[kKeyFileIndex]).
24 const int kKeyFileIndex = 3; 24 const int kKeyFileIndex = 3;
25 25
26 // This class implements FileIOCallback to buffer the callback from a file IO 26 // This class implements FileIOCallback to buffer the callback from a file IO
27 // operation from the actual net class. 27 // operation from the actual net class.
28 class SyncCallback: public disk_cache::FileIOCallback { 28 class SyncCallback: public disk_cache::FileIOCallback {
29 public: 29 public:
30 SyncCallback(disk_cache::EntryImpl* entry, net::IOBuffer* buffer, 30 SyncCallback(disk_cache::EntryImpl* entry, net::IOBuffer* buffer,
31 net::CompletionCallback* callback ) 31 net::CompletionCallback* callback )
32 : entry_(entry), callback_(callback), buf_(buffer) { 32 : entry_(entry), callback_(callback), buf_(buffer), start_(Time::Now()) {
33 entry->AddRef(); 33 entry->AddRef();
34 entry->IncrementIoCount(); 34 entry->IncrementIoCount();
35 } 35 }
36 ~SyncCallback() {} 36 ~SyncCallback() {}
37 37
38 virtual void OnFileIOComplete(int bytes_copied); 38 virtual void OnFileIOComplete(int bytes_copied);
39 void Discard(); 39 void Discard();
40 private: 40 private:
41 disk_cache::EntryImpl* entry_; 41 disk_cache::EntryImpl* entry_;
42 net::CompletionCallback* callback_; 42 net::CompletionCallback* callback_;
43 scoped_refptr<net::IOBuffer> buf_; 43 scoped_refptr<net::IOBuffer> buf_;
44 Time start_;
44 45
45 DISALLOW_EVIL_CONSTRUCTORS(SyncCallback); 46 DISALLOW_EVIL_CONSTRUCTORS(SyncCallback);
46 }; 47 };
47 48
48 void SyncCallback::OnFileIOComplete(int bytes_copied) { 49 void SyncCallback::OnFileIOComplete(int bytes_copied) {
49 entry_->DecrementIoCount(); 50 entry_->DecrementIoCount();
51 if (callback_) {
52 entry_->ReportIOTime(disk_cache::EntryImpl::kAsyncIO, start_);
53 callback_->Run(bytes_copied);
54 }
50 entry_->Release(); 55 entry_->Release();
51 if (callback_)
52 callback_->Run(bytes_copied);
53 delete this; 56 delete this;
54 } 57 }
55 58
56 void SyncCallback::Discard() { 59 void SyncCallback::Discard() {
57 callback_ = NULL; 60 callback_ = NULL;
58 buf_ = NULL; 61 buf_ = NULL;
59 OnFileIOComplete(0); 62 OnFileIOComplete(0);
60 } 63 }
61 64
62 // Clears buffer before offset and after valid_len, knowing that the size of 65 // Clears buffer before offset and after valid_len, knowing that the size of
(...skipping 810 matching lines...) Expand 10 before | Expand all | Expand 10 after
873 break; 876 break;
874 case kWrite: 877 case kWrite:
875 CACHE_UMA(AGE_MS, "WriteTime", group, start); 878 CACHE_UMA(AGE_MS, "WriteTime", group, start);
876 break; 879 break;
877 case kSparseRead: 880 case kSparseRead:
878 CACHE_UMA(AGE_MS, "SparseReadTime", 0, start); 881 CACHE_UMA(AGE_MS, "SparseReadTime", 0, start);
879 break; 882 break;
880 case kSparseWrite: 883 case kSparseWrite:
881 CACHE_UMA(AGE_MS, "SparseWriteTime", 0, start); 884 CACHE_UMA(AGE_MS, "SparseWriteTime", 0, start);
882 break; 885 break;
886 case kAsyncIO:
887 CACHE_UMA(AGE_MS, "AsyncIOTime", group, start);
888 break;
883 default: 889 default:
884 NOTREACHED(); 890 NOTREACHED();
885 } 891 }
886 } 892 }
887 893
888 void EntryImpl::Log(const char* msg) { 894 void EntryImpl::Log(const char* msg) {
889 int dirty = 0; 895 int dirty = 0;
890 if (node_.HasData()) { 896 if (node_.HasData()) {
891 dirty = node_.Data()->dirty; 897 dirty = node_.Data()->dirty;
892 } 898 }
893 899
894 Trace("%s 0x%p 0x%x 0x%x", msg, reinterpret_cast<void*>(this), 900 Trace("%s 0x%p 0x%x 0x%x", msg, reinterpret_cast<void*>(this),
895 entry_.address().value(), node_.address().value()); 901 entry_.address().value(), node_.address().value());
896 902
897 Trace(" data: 0x%x 0x%x 0x%x", entry_.Data()->data_addr[0], 903 Trace(" data: 0x%x 0x%x 0x%x", entry_.Data()->data_addr[0],
898 entry_.Data()->data_addr[1], entry_.Data()->long_key); 904 entry_.Data()->data_addr[1], entry_.Data()->long_key);
899 905
900 Trace(" doomed: %d 0x%x", doomed_, dirty); 906 Trace(" doomed: %d 0x%x", doomed_, dirty);
901 } 907 }
902 908
903 } // namespace disk_cache 909 } // namespace disk_cache
OLDNEW
« net/disk_cache/entry_impl.h ('K') | « net/disk_cache/entry_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698