| OLD | NEW |
| 1 // Copyright (c) 2012 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_BLOCKFILE_ENTRY_IMPL_H_ | 5 #ifndef NET_DISK_CACHE_BLOCKFILE_ENTRY_IMPL_H_ |
| 6 #define NET_DISK_CACHE_BLOCKFILE_ENTRY_IMPL_H_ | 6 #define NET_DISK_CACHE_BLOCKFILE_ENTRY_IMPL_H_ |
| 7 | 7 |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "net/base/net_log.h" | 9 #include "net/base/net_log.h" |
| 10 #include "net/disk_cache/blockfile/disk_format.h" | 10 #include "net/disk_cache/blockfile/disk_format.h" |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 // initialized before this is called. |created| is true if the Entry was | 140 // initialized before this is called. |created| is true if the Entry was |
| 141 // created rather than opened. | 141 // created rather than opened. |
| 142 void BeginLogging(net::NetLog* net_log, bool created); | 142 void BeginLogging(net::NetLog* net_log, bool created); |
| 143 | 143 |
| 144 const net::BoundNetLog& net_log() const; | 144 const net::BoundNetLog& net_log() const; |
| 145 | 145 |
| 146 // Returns the number of blocks needed to store an EntryStore. | 146 // Returns the number of blocks needed to store an EntryStore. |
| 147 static int NumBlocksForEntry(int key_size); | 147 static int NumBlocksForEntry(int key_size); |
| 148 | 148 |
| 149 // Entry interface. | 149 // Entry interface. |
| 150 virtual void Doom() override; | 150 void Doom() override; |
| 151 virtual void Close() override; | 151 void Close() override; |
| 152 virtual std::string GetKey() const override; | 152 std::string GetKey() const override; |
| 153 virtual base::Time GetLastUsed() const override; | 153 base::Time GetLastUsed() const override; |
| 154 virtual base::Time GetLastModified() const override; | 154 base::Time GetLastModified() const override; |
| 155 virtual int32 GetDataSize(int index) const override; | 155 int32 GetDataSize(int index) const override; |
| 156 virtual int ReadData(int index, int offset, IOBuffer* buf, int buf_len, | 156 int ReadData(int index, |
| 157 const CompletionCallback& callback) override; | 157 int offset, |
| 158 virtual int WriteData(int index, int offset, IOBuffer* buf, int buf_len, | 158 IOBuffer* buf, |
| 159 const CompletionCallback& callback, | 159 int buf_len, |
| 160 bool truncate) override; | 160 const CompletionCallback& callback) override; |
| 161 virtual int ReadSparseData(int64 offset, IOBuffer* buf, int buf_len, | 161 int WriteData(int index, |
| 162 const CompletionCallback& callback) override; | 162 int offset, |
| 163 virtual int WriteSparseData(int64 offset, IOBuffer* buf, int buf_len, | 163 IOBuffer* buf, |
| 164 const CompletionCallback& callback) override; | 164 int buf_len, |
| 165 virtual int GetAvailableRange(int64 offset, int len, int64* start, | 165 const CompletionCallback& callback, |
| 166 const CompletionCallback& callback) override; | 166 bool truncate) override; |
| 167 virtual bool CouldBeSparse() const override; | 167 int ReadSparseData(int64 offset, |
| 168 virtual void CancelSparseIO() override; | 168 IOBuffer* buf, |
| 169 virtual int ReadyForSparseIO(const CompletionCallback& callback) override; | 169 int buf_len, |
| 170 const CompletionCallback& callback) override; |
| 171 int WriteSparseData(int64 offset, |
| 172 IOBuffer* buf, |
| 173 int buf_len, |
| 174 const CompletionCallback& callback) override; |
| 175 int GetAvailableRange(int64 offset, |
| 176 int len, |
| 177 int64* start, |
| 178 const CompletionCallback& callback) override; |
| 179 bool CouldBeSparse() const override; |
| 180 void CancelSparseIO() override; |
| 181 int ReadyForSparseIO(const CompletionCallback& callback) override; |
| 170 | 182 |
| 171 private: | 183 private: |
| 172 enum { | 184 enum { |
| 173 kNumStreams = 3 | 185 kNumStreams = 3 |
| 174 }; | 186 }; |
| 175 class UserBuffer; | 187 class UserBuffer; |
| 176 | 188 |
| 177 virtual ~EntryImpl(); | 189 ~EntryImpl() override; |
| 178 | 190 |
| 179 // Do all the work for ReadDataImpl and WriteDataImpl. Implemented as | 191 // Do all the work for ReadDataImpl and WriteDataImpl. Implemented as |
| 180 // separate functions to make logging of results simpler. | 192 // separate functions to make logging of results simpler. |
| 181 int InternalReadData(int index, int offset, IOBuffer* buf, | 193 int InternalReadData(int index, int offset, IOBuffer* buf, |
| 182 int buf_len, const CompletionCallback& callback); | 194 int buf_len, const CompletionCallback& callback); |
| 183 int InternalWriteData(int index, int offset, IOBuffer* buf, int buf_len, | 195 int InternalWriteData(int index, int offset, IOBuffer* buf, int buf_len, |
| 184 const CompletionCallback& callback, bool truncate); | 196 const CompletionCallback& callback, bool truncate); |
| 185 | 197 |
| 186 // Initializes the storage for an internal or external data block. | 198 // Initializes the storage for an internal or external data block. |
| 187 bool CreateDataBlock(int index, int size); | 199 bool CreateDataBlock(int index, int size); |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 scoped_ptr<SparseControl> sparse_; // Support for sparse entries. | 281 scoped_ptr<SparseControl> sparse_; // Support for sparse entries. |
| 270 | 282 |
| 271 net::BoundNetLog net_log_; | 283 net::BoundNetLog net_log_; |
| 272 | 284 |
| 273 DISALLOW_COPY_AND_ASSIGN(EntryImpl); | 285 DISALLOW_COPY_AND_ASSIGN(EntryImpl); |
| 274 }; | 286 }; |
| 275 | 287 |
| 276 } // namespace disk_cache | 288 } // namespace disk_cache |
| 277 | 289 |
| 278 #endif // NET_DISK_CACHE_BLOCKFILE_ENTRY_IMPL_H_ | 290 #endif // NET_DISK_CACHE_BLOCKFILE_ENTRY_IMPL_H_ |
| OLD | NEW |