OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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_MEM_ENTRY_IMPL_H__ | 5 #ifndef NET_DISK_CACHE_MEM_ENTRY_IMPL_H__ |
6 #define NET_DISK_CACHE_MEM_ENTRY_IMPL_H__ | 6 #define NET_DISK_CACHE_MEM_ENTRY_IMPL_H__ |
7 | 7 |
8 #include "net/disk_cache/disk_cache.h" | 8 #include "net/disk_cache/disk_cache.h" |
9 | 9 |
10 namespace disk_cache { | 10 namespace disk_cache { |
11 | 11 |
12 class MemBackendImpl; | 12 class MemBackendImpl; |
13 | 13 |
14 // This class implements the Entry interface for the memory-only cache. An | 14 // This class implements the Entry interface for the memory-only cache. An |
15 // object of this class represents a single entry on the cache. | 15 // object of this class represents a single entry on the cache. |
16 class MemEntryImpl : public Entry { | 16 class MemEntryImpl : public Entry { |
17 public: | 17 public: |
18 explicit MemEntryImpl(MemBackendImpl* backend); | 18 explicit MemEntryImpl(MemBackendImpl* backend); |
19 | 19 |
20 // Entry interface. | 20 // Entry interface. |
21 virtual void Doom(); | 21 virtual void Doom(); |
22 virtual void Close(); | 22 virtual void Close(); |
23 virtual std::string GetKey() const; | 23 virtual std::string GetKey() const; |
24 virtual Time GetLastUsed() const; | 24 virtual base::Time GetLastUsed() const; |
25 virtual Time GetLastModified() const; | 25 virtual base::Time GetLastModified() const; |
26 virtual int32 GetDataSize(int index) const; | 26 virtual int32 GetDataSize(int index) const; |
27 virtual int ReadData(int index, int offset, char* buf, int buf_len, | 27 virtual int ReadData(int index, int offset, char* buf, int buf_len, |
28 net::CompletionCallback* completion_callback); | 28 net::CompletionCallback* completion_callback); |
29 virtual int WriteData(int index, int offset, const char* buf, int buf_len, | 29 virtual int WriteData(int index, int offset, const char* buf, int buf_len, |
30 net::CompletionCallback* completion_callback, | 30 net::CompletionCallback* completion_callback, |
31 bool truncate); | 31 bool truncate); |
32 | 32 |
33 // Performs the initialization of a EntryImpl that will be added to the | 33 // Performs the initialization of a EntryImpl that will be added to the |
34 // cache. | 34 // cache. |
35 bool CreateEntry(const std::string& key); | 35 bool CreateEntry(const std::string& key); |
(...skipping 29 matching lines...) Expand all Loading... |
65 // Updates ranking information. | 65 // Updates ranking information. |
66 void UpdateRank(bool modified); | 66 void UpdateRank(bool modified); |
67 | 67 |
68 std::string key_; | 68 std::string key_; |
69 std::vector<char> data_[2]; // User data. | 69 std::vector<char> data_[2]; // User data. |
70 int32 data_size_[2]; | 70 int32 data_size_[2]; |
71 int ref_count_; | 71 int ref_count_; |
72 | 72 |
73 MemEntryImpl* next_; // Pointers for the LRU list. | 73 MemEntryImpl* next_; // Pointers for the LRU list. |
74 MemEntryImpl* prev_; | 74 MemEntryImpl* prev_; |
75 Time last_modified_; // LRU information. | 75 base::Time last_modified_; // LRU information. |
76 Time last_used_; | 76 base::Time last_used_; |
77 MemBackendImpl* backend_; // Back pointer to the cache. | 77 MemBackendImpl* backend_; // Back pointer to the cache. |
78 bool doomed_; // True if this entry was removed from the cache. | 78 bool doomed_; // True if this entry was removed from the cache. |
79 | 79 |
80 DISALLOW_EVIL_CONSTRUCTORS(MemEntryImpl); | 80 DISALLOW_EVIL_CONSTRUCTORS(MemEntryImpl); |
81 }; | 81 }; |
82 | 82 |
83 } // namespace disk_cache | 83 } // namespace disk_cache |
84 | 84 |
85 #endif // NET_DISK_CACHE_MEM_ENTRY_IMPL_H__ | 85 #endif // NET_DISK_CACHE_MEM_ENTRY_IMPL_H__ |
86 | 86 |
OLD | NEW |