| 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_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/scoped_ptr.h" | 9 #include "base/scoped_ptr.h" |
| 10 #include "net/base/net_log.h" | 10 #include "net/base/net_log.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 enum Operation { | 26 enum Operation { |
| 27 kRead, | 27 kRead, |
| 28 kWrite, | 28 kWrite, |
| 29 kSparseRead, | 29 kSparseRead, |
| 30 kSparseWrite, | 30 kSparseWrite, |
| 31 kAsyncIO | 31 kAsyncIO |
| 32 }; | 32 }; |
| 33 | 33 |
| 34 EntryImpl(BackendImpl* backend, Addr address, bool read_only); | 34 EntryImpl(BackendImpl* backend, Addr address, bool read_only); |
| 35 | 35 |
| 36 // Entry interface. | |
| 37 virtual void Doom(); | |
| 38 virtual void Close(); | |
| 39 virtual std::string GetKey() const; | |
| 40 virtual base::Time GetLastUsed() const; | |
| 41 virtual base::Time GetLastModified() const; | |
| 42 virtual int32 GetDataSize(int index) const; | |
| 43 virtual int ReadData(int index, int offset, net::IOBuffer* buf, int buf_len, | |
| 44 net::CompletionCallback* completion_callback); | |
| 45 virtual int WriteData(int index, int offset, net::IOBuffer* buf, int buf_len, | |
| 46 net::CompletionCallback* completion_callback, | |
| 47 bool truncate); | |
| 48 virtual int ReadSparseData(int64 offset, net::IOBuffer* buf, int buf_len, | |
| 49 net::CompletionCallback* completion_callback); | |
| 50 virtual int WriteSparseData(int64 offset, net::IOBuffer* buf, int buf_len, | |
| 51 net::CompletionCallback* completion_callback); | |
| 52 virtual int GetAvailableRange(int64 offset, int len, int64* start, | |
| 53 CompletionCallback* callback); | |
| 54 virtual bool CouldBeSparse() const; | |
| 55 virtual void CancelSparseIO(); | |
| 56 virtual int ReadyForSparseIO(net::CompletionCallback* completion_callback); | |
| 57 | |
| 58 // Background implementation of the Entry interface. | 36 // Background implementation of the Entry interface. |
| 59 void DoomImpl(); | 37 void DoomImpl(); |
| 60 int ReadDataImpl(int index, int offset, net::IOBuffer* buf, int buf_len, | 38 int ReadDataImpl(int index, int offset, net::IOBuffer* buf, int buf_len, |
| 61 CompletionCallback* callback); | 39 CompletionCallback* callback); |
| 62 int WriteDataImpl(int index, int offset, net::IOBuffer* buf, int buf_len, | 40 int WriteDataImpl(int index, int offset, net::IOBuffer* buf, int buf_len, |
| 63 CompletionCallback* callback, bool truncate); | 41 CompletionCallback* callback, bool truncate); |
| 64 int ReadSparseDataImpl(int64 offset, net::IOBuffer* buf, int buf_len, | 42 int ReadSparseDataImpl(int64 offset, net::IOBuffer* buf, int buf_len, |
| 65 CompletionCallback* callback); | 43 CompletionCallback* callback); |
| 66 int WriteSparseDataImpl(int64 offset, net::IOBuffer* buf, int buf_len, | 44 int WriteSparseDataImpl(int64 offset, net::IOBuffer* buf, int buf_len, |
| 67 CompletionCallback* callback); | 45 CompletionCallback* callback); |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 void ReportIOTime(Operation op, const base::TimeTicks& start); | 109 void ReportIOTime(Operation op, const base::TimeTicks& start); |
| 132 | 110 |
| 133 // Logs a begin event and enables logging for the EntryImpl. Will also cause | 111 // Logs a begin event and enables logging for the EntryImpl. Will also cause |
| 134 // an end event to be logged on destruction. The EntryImpl must have its key | 112 // an end event to be logged on destruction. The EntryImpl must have its key |
| 135 // initialized before this is called. |created| is true if the Entry was | 113 // initialized before this is called. |created| is true if the Entry was |
| 136 // created rather than opened. | 114 // created rather than opened. |
| 137 void BeginLogging(net::NetLog* net_log, bool created); | 115 void BeginLogging(net::NetLog* net_log, bool created); |
| 138 | 116 |
| 139 const net::BoundNetLog& net_log() const; | 117 const net::BoundNetLog& net_log() const; |
| 140 | 118 |
| 119 // Entry interface. |
| 120 virtual void Doom(); |
| 121 virtual void Close(); |
| 122 virtual std::string GetKey() const; |
| 123 virtual base::Time GetLastUsed() const; |
| 124 virtual base::Time GetLastModified() const; |
| 125 virtual int32 GetDataSize(int index) const; |
| 126 virtual int ReadData(int index, int offset, net::IOBuffer* buf, int buf_len, |
| 127 net::CompletionCallback* completion_callback); |
| 128 virtual int WriteData(int index, int offset, net::IOBuffer* buf, int buf_len, |
| 129 net::CompletionCallback* completion_callback, |
| 130 bool truncate); |
| 131 virtual int ReadSparseData(int64 offset, net::IOBuffer* buf, int buf_len, |
| 132 net::CompletionCallback* completion_callback); |
| 133 virtual int WriteSparseData(int64 offset, net::IOBuffer* buf, int buf_len, |
| 134 net::CompletionCallback* completion_callback); |
| 135 virtual int GetAvailableRange(int64 offset, int len, int64* start, |
| 136 CompletionCallback* callback); |
| 137 virtual bool CouldBeSparse() const; |
| 138 virtual void CancelSparseIO(); |
| 139 virtual int ReadyForSparseIO(net::CompletionCallback* completion_callback); |
| 140 |
| 141 private: | 141 private: |
| 142 enum { | 142 enum { |
| 143 kNumStreams = 3 | 143 kNumStreams = 3 |
| 144 }; | 144 }; |
| 145 class UserBuffer; | 145 class UserBuffer; |
| 146 | 146 |
| 147 ~EntryImpl(); | 147 ~EntryImpl(); |
| 148 | 148 |
| 149 // Do all the work for ReadDataImpl and WriteDataImpl. Implemented as | 149 // Do all the work for ReadDataImpl and WriteDataImpl. Implemented as |
| 150 // separate functions to make logging of results simpler. | 150 // separate functions to make logging of results simpler. |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 237 scoped_ptr<SparseControl> sparse_; // Support for sparse entries. | 237 scoped_ptr<SparseControl> sparse_; // Support for sparse entries. |
| 238 | 238 |
| 239 net::BoundNetLog net_log_; | 239 net::BoundNetLog net_log_; |
| 240 | 240 |
| 241 DISALLOW_COPY_AND_ASSIGN(EntryImpl); | 241 DISALLOW_COPY_AND_ASSIGN(EntryImpl); |
| 242 }; | 242 }; |
| 243 | 243 |
| 244 } // namespace disk_cache | 244 } // namespace disk_cache |
| 245 | 245 |
| 246 #endif // NET_DISK_CACHE_ENTRY_IMPL_H_ | 246 #endif // NET_DISK_CACHE_ENTRY_IMPL_H_ |
| OLD | NEW |