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