Chromium Code Reviews| 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 // Defines the public interface of the disk cache. For more details see | 5 // Defines the public interface of the disk cache. For more details see |
| 6 // http://dev.chromium.org/developers/design-documents/network-stack/disk-cache | 6 // http://dev.chromium.org/developers/design-documents/network-stack/disk-cache |
| 7 | 7 |
| 8 #ifndef NET_DISK_CACHE_DISK_CACHE_H_ | 8 #ifndef NET_DISK_CACHE_DISK_CACHE_H_ |
| 9 #define NET_DISK_CACHE_DISK_CACHE_H_ | 9 #define NET_DISK_CACHE_DISK_CACHE_H_ |
| 10 | 10 |
| 11 #include <stdint.h> | 11 #include <stdint.h> |
| 12 | 12 |
| 13 #include <memory> | 13 #include <memory> |
| 14 #include <string> | 14 #include <string> |
| 15 #include <vector> | 15 #include <vector> |
| 16 | 16 |
| 17 #include "base/memory/ref_counted.h" | 17 #include "base/memory/ref_counted.h" |
| 18 #include "base/strings/string_split.h" | 18 #include "base/strings/string_split.h" |
| 19 #include "base/time/time.h" | 19 #include "base/time/time.h" |
| 20 #include "net/base/cache_type.h" | 20 #include "net/base/cache_type.h" |
| 21 #include "net/base/completion_callback.h" | 21 #include "net/base/completion_callback.h" |
| 22 #include "net/base/net_errors.h" | |
|
gavinp
2017/01/12 16:07:36
Amazing that this wasn't there already!!! Good cat
dullweber
2017/01/12 17:03:15
Oh, that's funny. The include is here because I tr
| |
| 22 #include "net/base/net_export.h" | 23 #include "net/base/net_export.h" |
| 23 | 24 |
| 24 namespace base { | 25 namespace base { |
| 25 class FilePath; | 26 class FilePath; |
| 26 class SingleThreadTaskRunner; | 27 class SingleThreadTaskRunner; |
| 27 } | 28 } |
| 28 | 29 |
| 29 namespace net { | 30 namespace net { |
| 30 class IOBuffer; | 31 class IOBuffer; |
| 31 class NetLog; | 32 class NetLog; |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 142 // Marks all entries accessed since |initial_time| for deletion. The return | 143 // Marks all entries accessed since |initial_time| for deletion. The return |
| 143 // value is a net error code. If this method returns ERR_IO_PENDING, the | 144 // value is a net error code. If this method returns ERR_IO_PENDING, the |
| 144 // |callback| will be invoked when the operation completes. | 145 // |callback| will be invoked when the operation completes. |
| 145 // Entries with |initial_time| <= access time are deleted. | 146 // Entries with |initial_time| <= access time are deleted. |
| 146 virtual int DoomEntriesSince(base::Time initial_time, | 147 virtual int DoomEntriesSince(base::Time initial_time, |
| 147 const CompletionCallback& callback) = 0; | 148 const CompletionCallback& callback) = 0; |
| 148 | 149 |
| 149 // Calculate the total size of the cache. The return value is the size in | 150 // Calculate the total size of the cache. The return value is the size in |
| 150 // bytes or a net error code. If this method returns ERR_IO_PENDING, | 151 // bytes or a net error code. If this method returns ERR_IO_PENDING, |
| 151 // the |callback| will be invoked when the operation completes. | 152 // the |callback| will be invoked when the operation completes. |
| 152 virtual int CalculateSizeOfAllEntries( | 153 virtual int CalculateSizeOfAllEntries(const CompletionCallback& callback) = 0; |
| 154 | |
| 155 // Calculate the size of all cache entries accessed between |initial_time| and | |
| 156 // |end_time|. | |
| 157 // The return value is the size in bytes or a net error code. A return value | |
| 158 // of ERR_NOT_IMPLEMTED means that there is no efficient way for the backend | |
|
gavinp
2017/01/12 16:07:36
typo: ERR_NOT_IMPLEMENTED, isn't it?
dullweber
2017/01/12 17:03:15
Done.
| |
| 159 // to determine the size for a subset of the cache. | |
| 160 // If this method returns ERR_IO_PENDING, the |callback| will be invoked when | |
| 161 // the operation completes. | |
| 162 virtual int CalculateSizeOfEntriesBetween( | |
| 163 base::Time initial_time, | |
| 164 base::Time end_time, | |
| 153 const CompletionCallback& callback) = 0; | 165 const CompletionCallback& callback) = 0; |
|
gavinp
2017/01/12 16:07:35
Does this method need to return a callback? Why no
dullweber
2017/01/12 17:03:15
The CalculateSizeOfAllEntries() method that just r
gavinp
2017/01/12 20:38:35
You've sold me. It's fine as it is.
| |
| 154 | 166 |
| 155 // Returns an iterator which will enumerate all entries of the cache in an | 167 // Returns an iterator which will enumerate all entries of the cache in an |
| 156 // undefined order. | 168 // undefined order. |
| 157 virtual std::unique_ptr<Iterator> CreateIterator() = 0; | 169 virtual std::unique_ptr<Iterator> CreateIterator() = 0; |
| 158 | 170 |
| 159 // Return a list of cache statistics. | 171 // Return a list of cache statistics. |
| 160 virtual void GetStats(base::StringPairs* stats) = 0; | 172 virtual void GetStats(base::StringPairs* stats) = 0; |
| 161 | 173 |
| 162 // Called whenever an external cache in the system reuses the resource | 174 // Called whenever an external cache in the system reuses the resource |
| 163 // referred to by |key|. | 175 // referred to by |key|. |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 331 entry->Close(); | 343 entry->Close(); |
| 332 } | 344 } |
| 333 }; | 345 }; |
| 334 | 346 |
| 335 // Automatically closes an entry when it goes out of scope. | 347 // Automatically closes an entry when it goes out of scope. |
| 336 typedef std::unique_ptr<Entry, EntryDeleter> ScopedEntryPtr; | 348 typedef std::unique_ptr<Entry, EntryDeleter> ScopedEntryPtr; |
| 337 | 349 |
| 338 } // namespace disk_cache | 350 } // namespace disk_cache |
| 339 | 351 |
| 340 #endif // NET_DISK_CACHE_DISK_CACHE_H_ | 352 #endif // NET_DISK_CACHE_DISK_CACHE_H_ |
| OLD | NEW |