| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "net/base/net_log.h" | 10 #include "net/base/net_log.h" |
| 11 #include "net/disk_cache/disk_cache.h" | 11 #include "net/disk_cache/disk_cache.h" |
| 12 #include "net/disk_cache/storage_block.h" | 12 #include "net/disk_cache/storage_block.h" |
| 13 #include "net/disk_cache/storage_block-inl.h" | 13 #include "net/disk_cache/storage_block-inl.h" |
| 14 | 14 |
| 15 namespace disk_cache { | 15 namespace disk_cache { |
| 16 | 16 |
| 17 class BackendImpl; | 17 class BackendImpl; |
| 18 class InFlightBackendIO; |
| 18 class SparseControl; | 19 class SparseControl; |
| 19 | 20 |
| 20 // This class implements the Entry interface. An object of this | 21 // This class implements the Entry interface. An object of this |
| 21 // class represents a single entry on the cache. | 22 // class represents a single entry on the cache. |
| 22 class NET_EXPORT_PRIVATE EntryImpl | 23 class NET_EXPORT_PRIVATE EntryImpl |
| 23 : public Entry, | 24 : public Entry, |
| 24 public base::RefCounted<EntryImpl> { | 25 public base::RefCounted<EntryImpl> { |
| 25 friend class base::RefCounted<EntryImpl>; | 26 friend class base::RefCounted<EntryImpl>; |
| 26 friend class SparseControl; | 27 friend class SparseControl; |
| 27 public: | 28 public: |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 bool SanityCheck(); | 115 bool SanityCheck(); |
| 115 bool DataSanityCheck(); | 116 bool DataSanityCheck(); |
| 116 | 117 |
| 117 // Attempts to make this entry reachable though the key. | 118 // Attempts to make this entry reachable though the key. |
| 118 void FixForDelete(); | 119 void FixForDelete(); |
| 119 | 120 |
| 120 // Handle the pending asynchronous IO count. | 121 // Handle the pending asynchronous IO count. |
| 121 void IncrementIoCount(); | 122 void IncrementIoCount(); |
| 122 void DecrementIoCount(); | 123 void DecrementIoCount(); |
| 123 | 124 |
| 125 // This entry is being returned to the user. It is always called from the |
| 126 // primary thread (not the dedicated cache thread). |
| 127 void OnEntryCreated(BackendImpl* backend); |
| 128 |
| 124 // Set the access times for this entry. This method provides support for | 129 // Set the access times for this entry. This method provides support for |
| 125 // the upgrade tool. | 130 // the upgrade tool. |
| 126 void SetTimes(base::Time last_used, base::Time last_modified); | 131 void SetTimes(base::Time last_used, base::Time last_modified); |
| 127 | 132 |
| 128 // Generates a histogram for the time spent working on this operation. | 133 // Generates a histogram for the time spent working on this operation. |
| 129 void ReportIOTime(Operation op, const base::TimeTicks& start); | 134 void ReportIOTime(Operation op, const base::TimeTicks& start); |
| 130 | 135 |
| 131 // Logs a begin event and enables logging for the EntryImpl. Will also cause | 136 // Logs a begin event and enables logging for the EntryImpl. Will also cause |
| 132 // an end event to be logged on destruction. The EntryImpl must have its key | 137 // an end event to be logged on destruction. The EntryImpl must have its key |
| 133 // initialized before this is called. |created| is true if the Entry was | 138 // initialized before this is called. |created| is true if the Entry was |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 247 // responsible for deleting the block (or file) from the backing store at some | 252 // responsible for deleting the block (or file) from the backing store at some |
| 248 // point; there is no need to report any storage-size change, only to do the | 253 // point; there is no need to report any storage-size change, only to do the |
| 249 // actual cleanup. | 254 // actual cleanup. |
| 250 void GetData(int index, char** buffer, Addr* address); | 255 void GetData(int index, char** buffer, Addr* address); |
| 251 | 256 |
| 252 // Logs this entry to the internal trace buffer. | 257 // Logs this entry to the internal trace buffer. |
| 253 void Log(const char* msg); | 258 void Log(const char* msg); |
| 254 | 259 |
| 255 CacheEntryBlock entry_; // Key related information for this entry. | 260 CacheEntryBlock entry_; // Key related information for this entry. |
| 256 CacheRankingsBlock node_; // Rankings related information for this entry. | 261 CacheRankingsBlock node_; // Rankings related information for this entry. |
| 257 BackendImpl* backend_; // Back pointer to the cache. | 262 base::WeakPtr<BackendImpl> backend_; // Back pointer to the cache. |
| 263 base::WeakPtr<InFlightBackendIO> background_queue_; // In-progress queue. |
| 258 scoped_ptr<UserBuffer> user_buffers_[kNumStreams]; // Stores user data. | 264 scoped_ptr<UserBuffer> user_buffers_[kNumStreams]; // Stores user data. |
| 259 // Files to store external user data and key. | 265 // Files to store external user data and key. |
| 260 scoped_refptr<File> files_[kNumStreams + 1]; | 266 scoped_refptr<File> files_[kNumStreams + 1]; |
| 261 mutable std::string key_; // Copy of the key. | 267 mutable std::string key_; // Copy of the key. |
| 262 int unreported_size_[kNumStreams]; // Bytes not reported yet to the backend. | 268 int unreported_size_[kNumStreams]; // Bytes not reported yet to the backend. |
| 263 bool doomed_; // True if this entry was removed from the cache. | 269 bool doomed_; // True if this entry was removed from the cache. |
| 264 bool read_only_; // True if not yet writing. | 270 bool read_only_; // True if not yet writing. |
| 265 bool dirty_; // True if we detected that this is a dirty entry. | 271 bool dirty_; // True if we detected that this is a dirty entry. |
| 266 scoped_ptr<SparseControl> sparse_; // Support for sparse entries. | 272 scoped_ptr<SparseControl> sparse_; // Support for sparse entries. |
| 267 | 273 |
| 268 net::BoundNetLog net_log_; | 274 net::BoundNetLog net_log_; |
| 269 | 275 |
| 270 DISALLOW_COPY_AND_ASSIGN(EntryImpl); | 276 DISALLOW_COPY_AND_ASSIGN(EntryImpl); |
| 271 }; | 277 }; |
| 272 | 278 |
| 273 } // namespace disk_cache | 279 } // namespace disk_cache |
| 274 | 280 |
| 275 #endif // NET_DISK_CACHE_ENTRY_IMPL_H_ | 281 #endif // NET_DISK_CACHE_ENTRY_IMPL_H_ |
| OLD | NEW |