| 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 #ifndef NET_DISK_CACHE_ENTRY_IMPL_H_ | 5 #ifndef NET_DISK_CACHE_ENTRY_IMPL_H_ |
| 6 #define NET_DISK_CACHE_ENTRY_IMPL_H_ | 6 #define NET_DISK_CACHE_ENTRY_IMPL_H_ |
| 7 | 7 |
| 8 #include "base/scoped_ptr.h" | 8 #include "base/scoped_ptr.h" |
| 9 #include "net/disk_cache/disk_cache.h" | 9 #include "net/disk_cache/disk_cache.h" |
| 10 #include "net/disk_cache/storage_block.h" | 10 #include "net/disk_cache/storage_block.h" |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 // Handle the pending asynchronous IO count. | 94 // Handle the pending asynchronous IO count. |
| 95 void IncrementIoCount(); | 95 void IncrementIoCount(); |
| 96 void DecrementIoCount(); | 96 void DecrementIoCount(); |
| 97 | 97 |
| 98 // Set the access times for this entry. This method provides support for | 98 // Set the access times for this entry. This method provides support for |
| 99 // the upgrade tool. | 99 // the upgrade tool. |
| 100 void SetTimes(base::Time last_used, base::Time last_modified); | 100 void SetTimes(base::Time last_used, base::Time last_modified); |
| 101 | 101 |
| 102 private: | 102 private: |
| 103 enum { | 103 enum { |
| 104 NUM_STREAMS = 3 | 104 kNumStreams = 3 |
| 105 }; |
| 106 |
| 107 enum Operation { |
| 108 kRead, |
| 109 kWrite, |
| 110 kSparseRead, |
| 111 kSparseWrite |
| 105 }; | 112 }; |
| 106 | 113 |
| 107 ~EntryImpl(); | 114 ~EntryImpl(); |
| 108 | 115 |
| 109 // Initializes the storage for an internal or external data block. | 116 // Initializes the storage for an internal or external data block. |
| 110 bool CreateDataBlock(int index, int size); | 117 bool CreateDataBlock(int index, int size); |
| 111 | 118 |
| 112 // Initializes the storage for an internal or external generic block. | 119 // Initializes the storage for an internal or external generic block. |
| 113 bool CreateBlock(int size, Addr* address); | 120 bool CreateBlock(int size, Addr* address); |
| 114 | 121 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 136 | 143 |
| 137 // Loads the external file to this object's memory buffer. | 144 // Loads the external file to this object's memory buffer. |
| 138 bool ImportSeparateFile(int index, int offset, int buf_len); | 145 bool ImportSeparateFile(int index, int offset, int buf_len); |
| 139 | 146 |
| 140 // Flush the in-memory data to the backing storage. | 147 // Flush the in-memory data to the backing storage. |
| 141 bool Flush(int index, int size, bool async); | 148 bool Flush(int index, int size, bool async); |
| 142 | 149 |
| 143 // Initializes the sparse control object. Returns a net error code. | 150 // Initializes the sparse control object. Returns a net error code. |
| 144 int InitSparseData(); | 151 int InitSparseData(); |
| 145 | 152 |
| 153 // Generates a histogram for the time spent working on this operation. |
| 154 void ReportIOTime(Operation op, const base::Time& start); |
| 155 |
| 146 // Logs this entry to the internal trace buffer. | 156 // Logs this entry to the internal trace buffer. |
| 147 void Log(const char* msg); | 157 void Log(const char* msg); |
| 148 | 158 |
| 149 CacheEntryBlock entry_; // Key related information for this entry. | 159 CacheEntryBlock entry_; // Key related information for this entry. |
| 150 CacheRankingsBlock node_; // Rankings related information for this entry. | 160 CacheRankingsBlock node_; // Rankings related information for this entry. |
| 151 BackendImpl* backend_; // Back pointer to the cache. | 161 BackendImpl* backend_; // Back pointer to the cache. |
| 152 scoped_array<char> user_buffers_[NUM_STREAMS]; // Store user data. | 162 scoped_array<char> user_buffers_[kNumStreams]; // Store user data. |
| 153 scoped_refptr<File> files_[NUM_STREAMS + 1]; // Files to store external user | 163 scoped_refptr<File> files_[kNumStreams + 1]; // Files to store external |
| 154 // data and key. | 164 // user data and key. |
| 155 int unreported_size_[NUM_STREAMS]; // Bytes not reported yet to the backend. | 165 int unreported_size_[kNumStreams]; // Bytes not reported yet to the backend. |
| 156 bool doomed_; // True if this entry was removed from the cache. | 166 bool doomed_; // True if this entry was removed from the cache. |
| 157 scoped_ptr<SparseControl> sparse_; // Support for sparse entries. | 167 scoped_ptr<SparseControl> sparse_; // Support for sparse entries. |
| 158 | 168 |
| 159 DISALLOW_EVIL_CONSTRUCTORS(EntryImpl); | 169 DISALLOW_EVIL_CONSTRUCTORS(EntryImpl); |
| 160 }; | 170 }; |
| 161 | 171 |
| 162 } // namespace disk_cache | 172 } // namespace disk_cache |
| 163 | 173 |
| 164 #endif // NET_DISK_CACHE_ENTRY_IMPL_H_ | 174 #endif // NET_DISK_CACHE_ENTRY_IMPL_H_ |
| OLD | NEW |