Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(536)

Side by Side Diff: net/disk_cache/blockfile/entry_impl_v3.h

Issue 266243004: Clang format slam. Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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_V3_H_ 5 #ifndef NET_DISK_CACHE_BLOCKFILE_ENTRY_IMPL_V3_H_
6 #define NET_DISK_CACHE_BLOCKFILE_ENTRY_IMPL_V3_H_ 6 #define NET_DISK_CACHE_BLOCKFILE_ENTRY_IMPL_V3_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
11 #include "net/base/net_log.h" 11 #include "net/base/net_log.h"
12 #include "net/disk_cache/blockfile/disk_format_v3.h" 12 #include "net/disk_cache/blockfile/disk_format_v3.h"
13 #include "net/disk_cache/blockfile/storage_block.h" 13 #include "net/disk_cache/blockfile/storage_block.h"
14 #include "net/disk_cache/disk_cache.h" 14 #include "net/disk_cache/disk_cache.h"
15 15
16 namespace disk_cache { 16 namespace disk_cache {
17 17
18 class BackendImplV3; 18 class BackendImplV3;
19 class SparseControlV3; 19 class SparseControlV3;
20 20
21 // This class implements the Entry interface. An object of this 21 // This class implements the Entry interface. An object of this
22 // class represents a single entry on the cache. 22 // class represents a single entry on the cache.
23 class NET_EXPORT_PRIVATE EntryImplV3 23 class NET_EXPORT_PRIVATE EntryImplV3 : public Entry,
24 : public Entry, 24 public base::RefCounted<EntryImplV3> {
25 public base::RefCounted<EntryImplV3> {
26 friend class base::RefCounted<EntryImplV3>; 25 friend class base::RefCounted<EntryImplV3>;
27 // friend class SparseControlV3; 26 // friend class SparseControlV3;
28 public: 27 public:
29 enum Operation { 28 enum Operation {
30 kRead, 29 kRead,
31 kWrite, 30 kWrite,
32 kSparseRead, 31 kSparseRead,
33 kSparseWrite, 32 kSparseWrite,
34 kAsyncIO, 33 kAsyncIO,
35 kReadAsync1, 34 kReadAsync1,
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 75
77 const net::BoundNetLog& net_log() const; 76 const net::BoundNetLog& net_log() const;
78 77
79 // Entry interface. 78 // Entry interface.
80 virtual void Doom() OVERRIDE; 79 virtual void Doom() OVERRIDE;
81 virtual void Close() OVERRIDE; 80 virtual void Close() OVERRIDE;
82 virtual std::string GetKey() const OVERRIDE; 81 virtual std::string GetKey() const OVERRIDE;
83 virtual base::Time GetLastUsed() const OVERRIDE; 82 virtual base::Time GetLastUsed() const OVERRIDE;
84 virtual base::Time GetLastModified() const OVERRIDE; 83 virtual base::Time GetLastModified() const OVERRIDE;
85 virtual int32 GetDataSize(int index) const OVERRIDE; 84 virtual int32 GetDataSize(int index) const OVERRIDE;
86 virtual int ReadData(int index, int offset, IOBuffer* buf, int buf_len, 85 virtual int ReadData(int index,
86 int offset,
87 IOBuffer* buf,
88 int buf_len,
87 const CompletionCallback& callback) OVERRIDE; 89 const CompletionCallback& callback) OVERRIDE;
88 virtual int WriteData(int index, int offset, IOBuffer* buf, int buf_len, 90 virtual int WriteData(int index,
91 int offset,
92 IOBuffer* buf,
93 int buf_len,
89 const CompletionCallback& callback, 94 const CompletionCallback& callback,
90 bool truncate) OVERRIDE; 95 bool truncate) OVERRIDE;
91 virtual int ReadSparseData(int64 offset, IOBuffer* buf, int buf_len, 96 virtual int ReadSparseData(int64 offset,
97 IOBuffer* buf,
98 int buf_len,
92 const CompletionCallback& callback) OVERRIDE; 99 const CompletionCallback& callback) OVERRIDE;
93 virtual int WriteSparseData(int64 offset, IOBuffer* buf, int buf_len, 100 virtual int WriteSparseData(int64 offset,
101 IOBuffer* buf,
102 int buf_len,
94 const CompletionCallback& callback) OVERRIDE; 103 const CompletionCallback& callback) OVERRIDE;
95 virtual int GetAvailableRange(int64 offset, int len, int64* start, 104 virtual int GetAvailableRange(int64 offset,
105 int len,
106 int64* start,
96 const CompletionCallback& callback) OVERRIDE; 107 const CompletionCallback& callback) OVERRIDE;
97 virtual bool CouldBeSparse() const OVERRIDE; 108 virtual bool CouldBeSparse() const OVERRIDE;
98 virtual void CancelSparseIO() OVERRIDE; 109 virtual void CancelSparseIO() OVERRIDE;
99 virtual int ReadyForSparseIO(const CompletionCallback& callback) OVERRIDE; 110 virtual int ReadyForSparseIO(const CompletionCallback& callback) OVERRIDE;
100 111
101 private: 112 private:
102 enum { 113 enum { kNumStreams = 3 };
103 kNumStreams = 3
104 };
105 class UserBuffer; 114 class UserBuffer;
106 115
107 virtual ~EntryImplV3(); 116 virtual ~EntryImplV3();
108 117
109 // Do all the work for ReadDataImpl and WriteDataImpl. Implemented as 118 // Do all the work for ReadDataImpl and WriteDataImpl. Implemented as
110 // separate functions to make logging of results simpler. 119 // separate functions to make logging of results simpler.
111 int InternalReadData(int index, int offset, IOBuffer* buf, 120 int InternalReadData(int index,
112 int buf_len, const CompletionCallback& callback); 121 int offset,
113 int InternalWriteData(int index, int offset, IOBuffer* buf, int buf_len, 122 IOBuffer* buf,
114 const CompletionCallback& callback, bool truncate); 123 int buf_len,
124 const CompletionCallback& callback);
125 int InternalWriteData(int index,
126 int offset,
127 IOBuffer* buf,
128 int buf_len,
129 const CompletionCallback& callback,
130 bool truncate);
115 131
116 // Initializes the storage for an internal or external data block. 132 // Initializes the storage for an internal or external data block.
117 bool CreateDataBlock(int index, int size); 133 bool CreateDataBlock(int index, int size);
118 134
119 // Initializes the storage for an internal or external generic block. 135 // Initializes the storage for an internal or external generic block.
120 bool CreateBlock(int size, Addr* address); 136 bool CreateBlock(int size, Addr* address);
121 137
122 // Deletes the data pointed by address, maybe backed by files_[index]. 138 // Deletes the data pointed by address, maybe backed by files_[index].
123 // Note that most likely the caller should delete (and store) the reference to 139 // Note that most likely the caller should delete (and store) the reference to
124 // |address| *before* calling this method because we don't want to have an 140 // |address| *before* calling this method because we don't want to have an
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 // point; there is no need to report any storage-size change, only to do the 194 // point; there is no need to report any storage-size change, only to do the
179 // actual cleanup. 195 // actual cleanup.
180 void GetData(int index, char** buffer, Addr* address); 196 void GetData(int index, char** buffer, Addr* address);
181 197
182 // Generates a histogram for the time spent working on this operation. 198 // Generates a histogram for the time spent working on this operation.
183 void ReportIOTime(Operation op, const base::TimeTicks& start); 199 void ReportIOTime(Operation op, const base::TimeTicks& start);
184 200
185 // Logs this entry to the internal trace buffer. 201 // Logs this entry to the internal trace buffer.
186 void Log(const char* msg); 202 void Log(const char* msg);
187 203
188 scoped_ptr<EntryRecord> entry_; // Basic record for this entry. 204 scoped_ptr<EntryRecord> entry_; // Basic record for this entry.
189 scoped_ptr<ShortEntryRecord> short_entry_; // Valid for evicted entries. 205 scoped_ptr<ShortEntryRecord> short_entry_; // Valid for evicted entries.
190 base::WeakPtr<BackendImplV3> backend_; // Back pointer to the cache. 206 base::WeakPtr<BackendImplV3> backend_; // Back pointer to the cache.
191 scoped_ptr<UserBuffer> user_buffers_[kNumStreams]; // Stores user data. 207 scoped_ptr<UserBuffer> user_buffers_[kNumStreams]; // Stores user data.
192 mutable std::string key_; // Copy of the key. 208 mutable std::string key_; // Copy of the key.
193 Addr address_; 209 Addr address_;
194 int unreported_size_[kNumStreams]; // Bytes not reported yet to the backend. 210 int unreported_size_[kNumStreams]; // Bytes not reported yet to the backend.
195 bool doomed_; // True if this entry was removed from the cache. 211 bool doomed_; // True if this entry was removed from the cache.
196 bool read_only_; 212 bool read_only_;
197 bool dirty_; // True if there is something to write. 213 bool dirty_; // True if there is something to write.
198 bool modified_; 214 bool modified_;
199 // scoped_ptr<SparseControlV3> sparse_; // Support for sparse entries. 215 // scoped_ptr<SparseControlV3> sparse_; // Support for sparse entries.
200 216
201 net::BoundNetLog net_log_; 217 net::BoundNetLog net_log_;
202 218
203 DISALLOW_COPY_AND_ASSIGN(EntryImplV3); 219 DISALLOW_COPY_AND_ASSIGN(EntryImplV3);
204 }; 220 };
205 221
206 } // namespace disk_cache 222 } // namespace disk_cache
207 223
208 #endif // NET_DISK_CACHE_BLOCKFILE_ENTRY_IMPL_V3_H_ 224 #endif // NET_DISK_CACHE_BLOCKFILE_ENTRY_IMPL_V3_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698