| 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 // See net/disk_cache/disk_cache.h for the public interface of the cache. | 5 // See net/disk_cache/disk_cache.h for the public interface of the cache. |
| 6 | 6 |
| 7 #ifndef NET_DISK_CACHE_MEMORY_MEM_BACKEND_IMPL_H_ | 7 #ifndef NET_DISK_CACHE_MEMORY_MEM_BACKEND_IMPL_H_ |
| 8 #define NET_DISK_CACHE_MEMORY_MEM_BACKEND_IMPL_H_ | 8 #define NET_DISK_CACHE_MEMORY_MEM_BACKEND_IMPL_H_ |
| 9 | 9 |
| 10 #include <stdint.h> | 10 #include <stdint.h> |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 class NET_EXPORT_PRIVATE MemBackendImpl final : public Backend { | 32 class NET_EXPORT_PRIVATE MemBackendImpl final : public Backend { |
| 33 public: | 33 public: |
| 34 explicit MemBackendImpl(net::NetLog* net_log); | 34 explicit MemBackendImpl(net::NetLog* net_log); |
| 35 ~MemBackendImpl() override; | 35 ~MemBackendImpl() override; |
| 36 | 36 |
| 37 // Returns an instance of a Backend implemented only in memory. The returned | 37 // Returns an instance of a Backend implemented only in memory. The returned |
| 38 // object should be deleted when not needed anymore. max_bytes is the maximum | 38 // object should be deleted when not needed anymore. max_bytes is the maximum |
| 39 // size the cache can grow to. If zero is passed in as max_bytes, the cache | 39 // size the cache can grow to. If zero is passed in as max_bytes, the cache |
| 40 // will determine the value to use based on the available memory. The returned | 40 // will determine the value to use based on the available memory. The returned |
| 41 // pointer can be NULL if a fatal error is found. | 41 // pointer can be NULL if a fatal error is found. |
| 42 static scoped_ptr<Backend> CreateBackend(int max_bytes, net::NetLog* net_log); | 42 static std::unique_ptr<Backend> CreateBackend(int max_bytes, |
| 43 net::NetLog* net_log); |
| 43 | 44 |
| 44 // Performs general initialization for this current instance of the cache. | 45 // Performs general initialization for this current instance of the cache. |
| 45 bool Init(); | 46 bool Init(); |
| 46 | 47 |
| 47 // Sets the maximum size for the total amount of data stored by this instance. | 48 // Sets the maximum size for the total amount of data stored by this instance. |
| 48 bool SetMaxSize(int max_bytes); | 49 bool SetMaxSize(int max_bytes); |
| 49 | 50 |
| 50 // Returns the maximum size for a file to reside on the cache. | 51 // Returns the maximum size for a file to reside on the cache. |
| 51 int MaxFileSize() const; | 52 int MaxFileSize() const; |
| 52 | 53 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 82 const CompletionCallback& callback) override; | 83 const CompletionCallback& callback) override; |
| 83 int DoomEntry(const std::string& key, | 84 int DoomEntry(const std::string& key, |
| 84 const CompletionCallback& callback) override; | 85 const CompletionCallback& callback) override; |
| 85 int DoomAllEntries(const CompletionCallback& callback) override; | 86 int DoomAllEntries(const CompletionCallback& callback) override; |
| 86 int DoomEntriesBetween(base::Time initial_time, | 87 int DoomEntriesBetween(base::Time initial_time, |
| 87 base::Time end_time, | 88 base::Time end_time, |
| 88 const CompletionCallback& callback) override; | 89 const CompletionCallback& callback) override; |
| 89 int DoomEntriesSince(base::Time initial_time, | 90 int DoomEntriesSince(base::Time initial_time, |
| 90 const CompletionCallback& callback) override; | 91 const CompletionCallback& callback) override; |
| 91 int CalculateSizeOfAllEntries(const CompletionCallback& callback) override; | 92 int CalculateSizeOfAllEntries(const CompletionCallback& callback) override; |
| 92 scoped_ptr<Iterator> CreateIterator() override; | 93 std::unique_ptr<Iterator> CreateIterator() override; |
| 93 void GetStats(base::StringPairs* stats) override {} | 94 void GetStats(base::StringPairs* stats) override {} |
| 94 void OnExternalCacheHit(const std::string& key) override; | 95 void OnExternalCacheHit(const std::string& key) override; |
| 95 | 96 |
| 96 private: | 97 private: |
| 97 class MemIterator; | 98 class MemIterator; |
| 98 friend class MemIterator; | 99 friend class MemIterator; |
| 99 | 100 |
| 100 typedef base::hash_map<std::string, MemEntryImpl*> EntryMap; | 101 typedef base::hash_map<std::string, MemEntryImpl*> EntryMap; |
| 101 | 102 |
| 102 // Deletes entries from the cache until the current size is below the limit. | 103 // Deletes entries from the cache until the current size is below the limit. |
| (...skipping 11 matching lines...) Expand all Loading... |
| 114 net::NetLog* net_log_; | 115 net::NetLog* net_log_; |
| 115 | 116 |
| 116 base::WeakPtrFactory<MemBackendImpl> weak_factory_; | 117 base::WeakPtrFactory<MemBackendImpl> weak_factory_; |
| 117 | 118 |
| 118 DISALLOW_COPY_AND_ASSIGN(MemBackendImpl); | 119 DISALLOW_COPY_AND_ASSIGN(MemBackendImpl); |
| 119 }; | 120 }; |
| 120 | 121 |
| 121 } // namespace disk_cache | 122 } // namespace disk_cache |
| 122 | 123 |
| 123 #endif // NET_DISK_CACHE_MEMORY_MEM_BACKEND_IMPL_H_ | 124 #endif // NET_DISK_CACHE_MEMORY_MEM_BACKEND_IMPL_H_ |
| OLD | NEW |