OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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_SIMPLE_SIMPLE_BACKEND_IMPL_H_ | 5 #ifndef NET_DISK_CACHE_SIMPLE_SIMPLE_BACKEND_IMPL_H_ |
6 #define NET_DISK_CACHE_SIMPLE_SIMPLE_BACKEND_IMPL_H_ | 6 #define NET_DISK_CACHE_SIMPLE_SIMPLE_BACKEND_IMPL_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <utility> | 9 #include <utility> |
10 #include <vector> | 10 #include <vector> |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 public SimpleIndexDelegate, | 49 public SimpleIndexDelegate, |
50 public base::SupportsWeakPtr<SimpleBackendImpl> { | 50 public base::SupportsWeakPtr<SimpleBackendImpl> { |
51 public: | 51 public: |
52 SimpleBackendImpl( | 52 SimpleBackendImpl( |
53 const base::FilePath& path, | 53 const base::FilePath& path, |
54 int max_bytes, | 54 int max_bytes, |
55 net::CacheType cache_type, | 55 net::CacheType cache_type, |
56 const scoped_refptr<base::SingleThreadTaskRunner>& cache_thread, | 56 const scoped_refptr<base::SingleThreadTaskRunner>& cache_thread, |
57 net::NetLog* net_log); | 57 net::NetLog* net_log); |
58 | 58 |
59 virtual ~SimpleBackendImpl(); | 59 ~SimpleBackendImpl() override; |
60 | 60 |
61 net::CacheType cache_type() const { return cache_type_; } | 61 net::CacheType cache_type() const { return cache_type_; } |
62 SimpleIndex* index() { return index_.get(); } | 62 SimpleIndex* index() { return index_.get(); } |
63 | 63 |
64 base::TaskRunner* worker_pool() { return worker_pool_.get(); } | 64 base::TaskRunner* worker_pool() { return worker_pool_.get(); } |
65 | 65 |
66 int Init(const CompletionCallback& completion_callback); | 66 int Init(const CompletionCallback& completion_callback); |
67 | 67 |
68 // Sets the maximum size for the total amount of data stored by this instance. | 68 // Sets the maximum size for the total amount of data stored by this instance. |
69 bool SetMaxSize(int max_bytes); | 69 bool SetMaxSize(int max_bytes); |
70 | 70 |
71 // Returns the maximum file size permitted in this backend. | 71 // Returns the maximum file size permitted in this backend. |
72 int GetMaxFileSize() const; | 72 int GetMaxFileSize() const; |
73 | 73 |
74 // Flush our SequencedWorkerPool. | 74 // Flush our SequencedWorkerPool. |
75 static void FlushWorkerPoolForTesting(); | 75 static void FlushWorkerPoolForTesting(); |
76 | 76 |
77 // The entry for |entry_hash| is being doomed; the backend will not attempt | 77 // The entry for |entry_hash| is being doomed; the backend will not attempt |
78 // run new operations for this |entry_hash| until the Doom is completed. | 78 // run new operations for this |entry_hash| until the Doom is completed. |
79 void OnDoomStart(uint64 entry_hash); | 79 void OnDoomStart(uint64 entry_hash); |
80 | 80 |
81 // The entry for |entry_hash| has been successfully doomed, we can now allow | 81 // The entry for |entry_hash| has been successfully doomed, we can now allow |
82 // operations on this entry, and we can run any operations enqueued while the | 82 // operations on this entry, and we can run any operations enqueued while the |
83 // doom completed. | 83 // doom completed. |
84 void OnDoomComplete(uint64 entry_hash); | 84 void OnDoomComplete(uint64 entry_hash); |
85 | 85 |
86 // SimpleIndexDelegate: | 86 // SimpleIndexDelegate: |
87 virtual void DoomEntries(std::vector<uint64>* entry_hashes, | 87 void DoomEntries(std::vector<uint64>* entry_hashes, |
88 const CompletionCallback& callback) override; | 88 const CompletionCallback& callback) override; |
89 | 89 |
90 // Backend: | 90 // Backend: |
91 virtual net::CacheType GetCacheType() const override; | 91 net::CacheType GetCacheType() const override; |
92 virtual int32 GetEntryCount() const override; | 92 int32 GetEntryCount() const override; |
93 virtual int OpenEntry(const std::string& key, Entry** entry, | 93 int OpenEntry(const std::string& key, |
94 const CompletionCallback& callback) override; | 94 Entry** entry, |
95 virtual int CreateEntry(const std::string& key, Entry** entry, | 95 const CompletionCallback& callback) override; |
96 const CompletionCallback& callback) override; | 96 int CreateEntry(const std::string& key, |
97 virtual int DoomEntry(const std::string& key, | 97 Entry** entry, |
98 const CompletionCallback& callback) override; | 98 const CompletionCallback& callback) override; |
99 virtual int DoomAllEntries(const CompletionCallback& callback) override; | 99 int DoomEntry(const std::string& key, |
100 virtual int DoomEntriesBetween(base::Time initial_time, | 100 const CompletionCallback& callback) override; |
101 base::Time end_time, | 101 int DoomAllEntries(const CompletionCallback& callback) override; |
102 const CompletionCallback& callback) override; | 102 int DoomEntriesBetween(base::Time initial_time, |
103 virtual int DoomEntriesSince(base::Time initial_time, | 103 base::Time end_time, |
104 const CompletionCallback& callback) override; | 104 const CompletionCallback& callback) override; |
105 virtual scoped_ptr<Iterator> CreateIterator() override; | 105 int DoomEntriesSince(base::Time initial_time, |
106 virtual void GetStats( | 106 const CompletionCallback& callback) override; |
107 std::vector<std::pair<std::string, std::string> >* stats) override; | 107 scoped_ptr<Iterator> CreateIterator() override; |
108 virtual void OnExternalCacheHit(const std::string& key) override; | 108 void GetStats( |
| 109 std::vector<std::pair<std::string, std::string>>* stats) override; |
| 110 void OnExternalCacheHit(const std::string& key) override; |
109 | 111 |
110 private: | 112 private: |
111 class SimpleIterator; | 113 class SimpleIterator; |
112 friend class SimpleIterator; | 114 friend class SimpleIterator; |
113 | 115 |
114 typedef base::hash_map<uint64, SimpleEntryImpl*> EntryMap; | 116 typedef base::hash_map<uint64, SimpleEntryImpl*> EntryMap; |
115 | 117 |
116 typedef base::Callback<void(base::Time mtime, uint64 max_size, int result)> | 118 typedef base::Callback<void(base::Time mtime, uint64 max_size, int result)> |
117 InitializeIndexCallback; | 119 InitializeIndexCallback; |
118 | 120 |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 // is complete. The base::Closure map target is used to store deferred | 203 // is complete. The base::Closure map target is used to store deferred |
202 // operations to be run at the completion of the Doom. | 204 // operations to be run at the completion of the Doom. |
203 base::hash_map<uint64, std::vector<base::Closure> > entries_pending_doom_; | 205 base::hash_map<uint64, std::vector<base::Closure> > entries_pending_doom_; |
204 | 206 |
205 net::NetLog* const net_log_; | 207 net::NetLog* const net_log_; |
206 }; | 208 }; |
207 | 209 |
208 } // namespace disk_cache | 210 } // namespace disk_cache |
209 | 211 |
210 #endif // NET_DISK_CACHE_SIMPLE_SIMPLE_BACKEND_IMPL_H_ | 212 #endif // NET_DISK_CACHE_SIMPLE_SIMPLE_BACKEND_IMPL_H_ |
OLD | NEW |