| OLD | NEW |
| 1 // Copyright (c) 2006-2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2010 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 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "base/scoped_ptr.h" | 9 #include "base/scoped_ptr.h" |
| 10 #include "net/base/net_log.h" | |
| 11 #include "net/disk_cache/disk_cache.h" | 10 #include "net/disk_cache/disk_cache.h" |
| 12 #include "net/disk_cache/storage_block.h" | 11 #include "net/disk_cache/storage_block.h" |
| 13 #include "net/disk_cache/storage_block-inl.h" | 12 #include "net/disk_cache/storage_block-inl.h" |
| 14 | 13 |
| 15 namespace disk_cache { | 14 namespace disk_cache { |
| 16 | 15 |
| 17 class BackendImpl; | 16 class BackendImpl; |
| 18 class SparseControl; | 17 class SparseControl; |
| 19 | 18 |
| 20 // This class implements the Entry interface. An object of this | 19 // This class implements the Entry interface. An object of this |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 void IncrementIoCount(); | 122 void IncrementIoCount(); |
| 124 void DecrementIoCount(); | 123 void DecrementIoCount(); |
| 125 | 124 |
| 126 // Set the access times for this entry. This method provides support for | 125 // Set the access times for this entry. This method provides support for |
| 127 // the upgrade tool. | 126 // the upgrade tool. |
| 128 void SetTimes(base::Time last_used, base::Time last_modified); | 127 void SetTimes(base::Time last_used, base::Time last_modified); |
| 129 | 128 |
| 130 // Generates a histogram for the time spent working on this operation. | 129 // Generates a histogram for the time spent working on this operation. |
| 131 void ReportIOTime(Operation op, const base::TimeTicks& start); | 130 void ReportIOTime(Operation op, const base::TimeTicks& start); |
| 132 | 131 |
| 133 // Logs a begin event and enables logging for the EntryImpl. Will also cause | |
| 134 // an end event to be logged on destruction. The EntryImpl must have its key | |
| 135 // initialized before this is called. |created| is true if the Entry was | |
| 136 // created rather than opened. | |
| 137 void BeginLogging(net::NetLog* net_log, bool created); | |
| 138 | |
| 139 const net::BoundNetLog& net_log() const; | |
| 140 | |
| 141 private: | 132 private: |
| 142 enum { | 133 enum { |
| 143 kNumStreams = 3 | 134 kNumStreams = 3 |
| 144 }; | 135 }; |
| 145 class UserBuffer; | 136 class UserBuffer; |
| 146 | 137 |
| 147 ~EntryImpl(); | 138 ~EntryImpl(); |
| 148 | 139 |
| 149 // Do all the work for ReadDataImpl and WriteDataImpl. Implemented as | |
| 150 // separate functions to make logging of results simpler. | |
| 151 int InternalReadData(int index, int offset, net::IOBuffer* buf, | |
| 152 int buf_len, CompletionCallback* callback); | |
| 153 int InternalWriteData(int index, int offset, net::IOBuffer* buf, int buf_len, | |
| 154 CompletionCallback* callback, bool truncate); | |
| 155 | |
| 156 // Initializes the storage for an internal or external data block. | 140 // Initializes the storage for an internal or external data block. |
| 157 bool CreateDataBlock(int index, int size); | 141 bool CreateDataBlock(int index, int size); |
| 158 | 142 |
| 159 // Initializes the storage for an internal or external generic block. | 143 // Initializes the storage for an internal or external generic block. |
| 160 bool CreateBlock(int size, Addr* address); | 144 bool CreateBlock(int size, Addr* address); |
| 161 | 145 |
| 162 // Deletes the data pointed by address, maybe backed by files_[index]. | 146 // Deletes the data pointed by address, maybe backed by files_[index]. |
| 163 // Note that most likely the caller should delete (and store) the reference to | 147 // Note that most likely the caller should delete (and store) the reference to |
| 164 // |address| *before* calling this method because we don't want to have an | 148 // |address| *before* calling this method because we don't want to have an |
| 165 // entry using an address that is already free. | 149 // entry using an address that is already free. |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 BackendImpl* backend_; // Back pointer to the cache. | 213 BackendImpl* backend_; // Back pointer to the cache. |
| 230 scoped_ptr<UserBuffer> user_buffers_[kNumStreams]; // Stores user data. | 214 scoped_ptr<UserBuffer> user_buffers_[kNumStreams]; // Stores user data. |
| 231 // Files to store external user data and key. | 215 // Files to store external user data and key. |
| 232 scoped_refptr<File> files_[kNumStreams + 1]; | 216 scoped_refptr<File> files_[kNumStreams + 1]; |
| 233 mutable std::string key_; // Copy of the key. | 217 mutable std::string key_; // Copy of the key. |
| 234 int unreported_size_[kNumStreams]; // Bytes not reported yet to the backend. | 218 int unreported_size_[kNumStreams]; // Bytes not reported yet to the backend. |
| 235 bool doomed_; // True if this entry was removed from the cache. | 219 bool doomed_; // True if this entry was removed from the cache. |
| 236 bool read_only_; // True if not yet writing. | 220 bool read_only_; // True if not yet writing. |
| 237 scoped_ptr<SparseControl> sparse_; // Support for sparse entries. | 221 scoped_ptr<SparseControl> sparse_; // Support for sparse entries. |
| 238 | 222 |
| 239 net::BoundNetLog net_log_; | |
| 240 | |
| 241 DISALLOW_COPY_AND_ASSIGN(EntryImpl); | 223 DISALLOW_COPY_AND_ASSIGN(EntryImpl); |
| 242 }; | 224 }; |
| 243 | 225 |
| 244 } // namespace disk_cache | 226 } // namespace disk_cache |
| 245 | 227 |
| 246 #endif // NET_DISK_CACHE_ENTRY_IMPL_H_ | 228 #endif // NET_DISK_CACHE_ENTRY_IMPL_H_ |
| OLD | NEW |