| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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" |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 kReadAsync1, | 34 kReadAsync1, |
| 35 kWriteAsync1 | 35 kWriteAsync1 |
| 36 }; | 36 }; |
| 37 | 37 |
| 38 EntryImpl(BackendImpl* backend, Addr address, bool read_only); | 38 EntryImpl(BackendImpl* backend, Addr address, bool read_only); |
| 39 | 39 |
| 40 // Background implementation of the Entry interface. | 40 // Background implementation of the Entry interface. |
| 41 void DoomImpl(); | 41 void DoomImpl(); |
| 42 int ReadDataImpl(int index, int offset, net::IOBuffer* buf, int buf_len, | 42 int ReadDataImpl(int index, int offset, net::IOBuffer* buf, int buf_len, |
| 43 OldCompletionCallback* callback); | 43 OldCompletionCallback* callback); |
| 44 int ReadDataImpl(int index, int offset, net::IOBuffer* buf, int buf_len, |
| 45 const net::CompletionCallback& callback); |
| 44 int WriteDataImpl(int index, int offset, net::IOBuffer* buf, int buf_len, | 46 int WriteDataImpl(int index, int offset, net::IOBuffer* buf, int buf_len, |
| 45 OldCompletionCallback* callback, bool truncate); | 47 OldCompletionCallback* callback, bool truncate); |
| 48 int WriteDataImpl(int index, int offset, net::IOBuffer* buf, int buf_len, |
| 49 const net::CompletionCallback& callback, bool truncate); |
| 46 int ReadSparseDataImpl(int64 offset, net::IOBuffer* buf, int buf_len, | 50 int ReadSparseDataImpl(int64 offset, net::IOBuffer* buf, int buf_len, |
| 47 OldCompletionCallback* callback); | 51 OldCompletionCallback* callback); |
| 48 int WriteSparseDataImpl(int64 offset, net::IOBuffer* buf, int buf_len, | 52 int WriteSparseDataImpl(int64 offset, net::IOBuffer* buf, int buf_len, |
| 49 OldCompletionCallback* callback); | 53 OldCompletionCallback* callback); |
| 50 int GetAvailableRangeImpl(int64 offset, int len, int64* start); | 54 int GetAvailableRangeImpl(int64 offset, int len, int64* start); |
| 51 void CancelSparseIOImpl(); | 55 void CancelSparseIOImpl(); |
| 52 int ReadyForSparseIOImpl(OldCompletionCallback* callback); | 56 int ReadyForSparseIOImpl(OldCompletionCallback* callback); |
| 53 | 57 |
| 54 inline CacheEntryBlock* entry() { | 58 inline CacheEntryBlock* entry() { |
| 55 return &entry_; | 59 return &entry_; |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 // Entry interface. | 146 // Entry interface. |
| 143 virtual void Doom() OVERRIDE; | 147 virtual void Doom() OVERRIDE; |
| 144 virtual void Close() OVERRIDE; | 148 virtual void Close() OVERRIDE; |
| 145 virtual std::string GetKey() const OVERRIDE; | 149 virtual std::string GetKey() const OVERRIDE; |
| 146 virtual base::Time GetLastUsed() const OVERRIDE; | 150 virtual base::Time GetLastUsed() const OVERRIDE; |
| 147 virtual base::Time GetLastModified() const OVERRIDE; | 151 virtual base::Time GetLastModified() const OVERRIDE; |
| 148 virtual int32 GetDataSize(int index) const OVERRIDE; | 152 virtual int32 GetDataSize(int index) const OVERRIDE; |
| 149 virtual int ReadData( | 153 virtual int ReadData( |
| 150 int index, int offset, net::IOBuffer* buf, int buf_len, | 154 int index, int offset, net::IOBuffer* buf, int buf_len, |
| 151 net::OldCompletionCallback* completion_callback) OVERRIDE; | 155 net::OldCompletionCallback* completion_callback) OVERRIDE; |
| 156 virtual int ReadData( |
| 157 int index, int offset, net::IOBuffer* buf, int buf_len, |
| 158 const net::CompletionCallback& completion_callback) OVERRIDE; |
| 152 virtual int WriteData(int index, int offset, net::IOBuffer* buf, int buf_len, | 159 virtual int WriteData(int index, int offset, net::IOBuffer* buf, int buf_len, |
| 153 net::OldCompletionCallback* completion_callback, | 160 net::OldCompletionCallback* completion_callback, |
| 154 bool truncate) OVERRIDE; | 161 bool truncate) OVERRIDE; |
| 162 virtual int WriteData(int index, int offset, net::IOBuffer* buf, int buf_len, |
| 163 const net::CompletionCallback& completion_callback, |
| 164 bool truncate) OVERRIDE; |
| 155 virtual int ReadSparseData( | 165 virtual int ReadSparseData( |
| 156 int64 offset, net::IOBuffer* buf, int buf_len, | 166 int64 offset, net::IOBuffer* buf, int buf_len, |
| 157 net::OldCompletionCallback* completion_callback) OVERRIDE; | 167 net::OldCompletionCallback* completion_callback) OVERRIDE; |
| 158 virtual int WriteSparseData( | 168 virtual int WriteSparseData( |
| 159 int64 offset, net::IOBuffer* buf, int buf_len, | 169 int64 offset, net::IOBuffer* buf, int buf_len, |
| 160 net::OldCompletionCallback* completion_callback) OVERRIDE; | 170 net::OldCompletionCallback* completion_callback) OVERRIDE; |
| 161 virtual int GetAvailableRange(int64 offset, int len, int64* start, | 171 virtual int GetAvailableRange(int64 offset, int len, int64* start, |
| 162 OldCompletionCallback* callback) OVERRIDE; | 172 OldCompletionCallback* callback) OVERRIDE; |
| 163 virtual bool CouldBeSparse() const OVERRIDE; | 173 virtual bool CouldBeSparse() const OVERRIDE; |
| 164 virtual void CancelSparseIO() OVERRIDE; | 174 virtual void CancelSparseIO() OVERRIDE; |
| 165 virtual int ReadyForSparseIO( | 175 virtual int ReadyForSparseIO( |
| 166 net::OldCompletionCallback* completion_callback) OVERRIDE; | 176 net::OldCompletionCallback* completion_callback) OVERRIDE; |
| 167 | 177 |
| 168 private: | 178 private: |
| 169 enum { | 179 enum { |
| 170 kNumStreams = 3 | 180 kNumStreams = 3 |
| 171 }; | 181 }; |
| 172 class UserBuffer; | 182 class UserBuffer; |
| 173 | 183 |
| 174 virtual ~EntryImpl(); | 184 virtual ~EntryImpl(); |
| 175 | 185 |
| 176 // Do all the work for ReadDataImpl and WriteDataImpl. Implemented as | 186 // Do all the work for ReadDataImpl and WriteDataImpl. Implemented as |
| 177 // separate functions to make logging of results simpler. | 187 // separate functions to make logging of results simpler. |
| 178 int InternalReadData(int index, int offset, net::IOBuffer* buf, | 188 int InternalReadData(int index, int offset, net::IOBuffer* buf, |
| 179 int buf_len, OldCompletionCallback* callback); | 189 int buf_len, OldCompletionCallback* callback); |
| 190 int InternalReadData(int index, int offset, net::IOBuffer* buf, |
| 191 int buf_len, const net::CompletionCallback& callback); |
| 180 int InternalWriteData(int index, int offset, net::IOBuffer* buf, int buf_len, | 192 int InternalWriteData(int index, int offset, net::IOBuffer* buf, int buf_len, |
| 181 OldCompletionCallback* callback, bool truncate); | 193 OldCompletionCallback* callback, bool truncate); |
| 194 int InternalWriteData(int index, int offset, net::IOBuffer* buf, int buf_len, |
| 195 const net::CompletionCallback& callback, bool truncate); |
| 182 | 196 |
| 183 // Initializes the storage for an internal or external data block. | 197 // Initializes the storage for an internal or external data block. |
| 184 bool CreateDataBlock(int index, int size); | 198 bool CreateDataBlock(int index, int size); |
| 185 | 199 |
| 186 // Initializes the storage for an internal or external generic block. | 200 // Initializes the storage for an internal or external generic block. |
| 187 bool CreateBlock(int size, Addr* address); | 201 bool CreateBlock(int size, Addr* address); |
| 188 | 202 |
| 189 // Deletes the data pointed by address, maybe backed by files_[index]. | 203 // Deletes the data pointed by address, maybe backed by files_[index]. |
| 190 // Note that most likely the caller should delete (and store) the reference to | 204 // Note that most likely the caller should delete (and store) the reference to |
| 191 // |address| *before* calling this method because we don't want to have an | 205 // |address| *before* calling this method because we don't want to have an |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 265 scoped_ptr<SparseControl> sparse_; // Support for sparse entries. | 279 scoped_ptr<SparseControl> sparse_; // Support for sparse entries. |
| 266 | 280 |
| 267 net::BoundNetLog net_log_; | 281 net::BoundNetLog net_log_; |
| 268 | 282 |
| 269 DISALLOW_COPY_AND_ASSIGN(EntryImpl); | 283 DISALLOW_COPY_AND_ASSIGN(EntryImpl); |
| 270 }; | 284 }; |
| 271 | 285 |
| 272 } // namespace disk_cache | 286 } // namespace disk_cache |
| 273 | 287 |
| 274 #endif // NET_DISK_CACHE_ENTRY_IMPL_H_ | 288 #endif // NET_DISK_CACHE_ENTRY_IMPL_H_ |
| OLD | NEW |