| 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_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 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "base/hash_tables.h" | 9 #include "base/hash_tables.h" |
| 10 #include "base/scoped_ptr.h" | 10 #include "base/scoped_ptr.h" |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 | 45 |
| 46 class MemEntryImpl : public Entry { | 46 class MemEntryImpl : public Entry { |
| 47 public: | 47 public: |
| 48 enum EntryType { | 48 enum EntryType { |
| 49 kParentEntry, | 49 kParentEntry, |
| 50 kChildEntry, | 50 kChildEntry, |
| 51 }; | 51 }; |
| 52 | 52 |
| 53 explicit MemEntryImpl(MemBackendImpl* backend); | 53 explicit MemEntryImpl(MemBackendImpl* backend); |
| 54 | 54 |
| 55 // Entry interface. | |
| 56 virtual void Doom(); | |
| 57 virtual void Close(); | |
| 58 virtual std::string GetKey() const; | |
| 59 virtual base::Time GetLastUsed() const; | |
| 60 virtual base::Time GetLastModified() const; | |
| 61 virtual int32 GetDataSize(int index) const; | |
| 62 virtual int ReadData(int index, int offset, net::IOBuffer* buf, int buf_len, | |
| 63 net::CompletionCallback* completion_callback); | |
| 64 virtual int WriteData(int index, int offset, net::IOBuffer* buf, int buf_len, | |
| 65 net::CompletionCallback* completion_callback, | |
| 66 bool truncate); | |
| 67 virtual int ReadSparseData(int64 offset, net::IOBuffer* buf, int buf_len, | |
| 68 net::CompletionCallback* completion_callback); | |
| 69 virtual int WriteSparseData(int64 offset, net::IOBuffer* buf, int buf_len, | |
| 70 net::CompletionCallback* completion_callback); | |
| 71 virtual int GetAvailableRange(int64 offset, int len, int64* start, | |
| 72 CompletionCallback* callback); | |
| 73 virtual bool CouldBeSparse() const; | |
| 74 virtual void CancelSparseIO() {} | |
| 75 virtual int ReadyForSparseIO(net::CompletionCallback* completion_callback); | |
| 76 | |
| 77 // Performs the initialization of a EntryImpl that will be added to the | 55 // Performs the initialization of a EntryImpl that will be added to the |
| 78 // cache. | 56 // cache. |
| 79 bool CreateEntry(const std::string& key); | 57 bool CreateEntry(const std::string& key); |
| 80 | 58 |
| 81 // Permanently destroys this entry. | 59 // Permanently destroys this entry. |
| 82 void InternalDoom(); | 60 void InternalDoom(); |
| 83 | 61 |
| 84 void Open(); | 62 void Open(); |
| 85 bool InUse(); | 63 bool InUse(); |
| 86 | 64 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 97 } | 75 } |
| 98 | 76 |
| 99 void set_prev(MemEntryImpl* prev) { | 77 void set_prev(MemEntryImpl* prev) { |
| 100 prev_ = prev; | 78 prev_ = prev; |
| 101 } | 79 } |
| 102 | 80 |
| 103 EntryType type() const { | 81 EntryType type() const { |
| 104 return parent_ ? kChildEntry : kParentEntry; | 82 return parent_ ? kChildEntry : kParentEntry; |
| 105 } | 83 } |
| 106 | 84 |
| 85 // Entry interface. |
| 86 virtual void Doom(); |
| 87 virtual void Close(); |
| 88 virtual std::string GetKey() const; |
| 89 virtual base::Time GetLastUsed() const; |
| 90 virtual base::Time GetLastModified() const; |
| 91 virtual int32 GetDataSize(int index) const; |
| 92 virtual int ReadData(int index, int offset, net::IOBuffer* buf, int buf_len, |
| 93 net::CompletionCallback* completion_callback); |
| 94 virtual int WriteData(int index, int offset, net::IOBuffer* buf, int buf_len, |
| 95 net::CompletionCallback* completion_callback, |
| 96 bool truncate); |
| 97 virtual int ReadSparseData(int64 offset, net::IOBuffer* buf, int buf_len, |
| 98 net::CompletionCallback* completion_callback); |
| 99 virtual int WriteSparseData(int64 offset, net::IOBuffer* buf, int buf_len, |
| 100 net::CompletionCallback* completion_callback); |
| 101 virtual int GetAvailableRange(int64 offset, int len, int64* start, |
| 102 CompletionCallback* callback); |
| 103 virtual bool CouldBeSparse() const; |
| 104 virtual void CancelSparseIO() {} |
| 105 virtual int ReadyForSparseIO(net::CompletionCallback* completion_callback); |
| 106 |
| 107 private: | 107 private: |
| 108 typedef base::hash_map<int, MemEntryImpl*> EntryMap; | 108 typedef base::hash_map<int, MemEntryImpl*> EntryMap; |
| 109 | 109 |
| 110 enum { | 110 enum { |
| 111 NUM_STREAMS = 3 | 111 NUM_STREAMS = 3 |
| 112 }; | 112 }; |
| 113 | 113 |
| 114 ~MemEntryImpl(); | 114 ~MemEntryImpl(); |
| 115 | 115 |
| 116 // Old Entry interface. | 116 // Old Entry interface. |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 base::Time last_used_; | 162 base::Time last_used_; |
| 163 MemBackendImpl* backend_; // Back pointer to the cache. | 163 MemBackendImpl* backend_; // Back pointer to the cache. |
| 164 bool doomed_; // True if this entry was removed from the cache. | 164 bool doomed_; // True if this entry was removed from the cache. |
| 165 | 165 |
| 166 DISALLOW_COPY_AND_ASSIGN(MemEntryImpl); | 166 DISALLOW_COPY_AND_ASSIGN(MemEntryImpl); |
| 167 }; | 167 }; |
| 168 | 168 |
| 169 } // namespace disk_cache | 169 } // namespace disk_cache |
| 170 | 170 |
| 171 #endif // NET_DISK_CACHE_MEM_ENTRY_IMPL_H_ | 171 #endif // NET_DISK_CACHE_MEM_ENTRY_IMPL_H_ |
| OLD | NEW |