| 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 15 matching lines...) Expand all Loading... |
| 26 // SimpleBackendImpl is a new cache backend that stores entries in individual | 26 // SimpleBackendImpl is a new cache backend that stores entries in individual |
| 27 // files. | 27 // files. |
| 28 | 28 |
| 29 // It is currently a work in progress, missing many features of a real cache, | 29 // It is currently a work in progress, missing many features of a real cache, |
| 30 // such as eviction. | 30 // such as eviction. |
| 31 | 31 |
| 32 // See http://www.chromium.org/developers/design-documents/network-stack/disk-ca
che/very-simple-backend | 32 // See http://www.chromium.org/developers/design-documents/network-stack/disk-ca
che/very-simple-backend |
| 33 | 33 |
| 34 class SimpleIndex; | 34 class SimpleIndex; |
| 35 | 35 |
| 36 class NET_EXPORT_PRIVATE SimpleBackendImpl : public Backend { | 36 class NET_EXPORT_PRIVATE SimpleBackendImpl : public Backend, |
| 37 public base::SupportsWeakPtr<SimpleBackendImpl> { |
| 37 public: | 38 public: |
| 38 SimpleBackendImpl(const base::FilePath& path, int max_bytes, | 39 SimpleBackendImpl(const base::FilePath& path, int max_bytes, |
| 39 net::CacheType type, | 40 net::CacheType type, |
| 40 base::SingleThreadTaskRunner* cache_thread, | 41 base::SingleThreadTaskRunner* cache_thread, |
| 41 net::NetLog* net_log); | 42 net::NetLog* net_log); |
| 42 | 43 |
| 43 virtual ~SimpleBackendImpl(); | 44 virtual ~SimpleBackendImpl(); |
| 44 | 45 |
| 45 // Must run on IO Thread. | 46 // Must run on IO Thread. |
| 46 int Init(const CompletionCallback& completion_callback); | 47 int Init(const CompletionCallback& completion_callback); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 66 virtual void GetStats( | 67 virtual void GetStats( |
| 67 std::vector<std::pair<std::string, std::string> >* stats) OVERRIDE; | 68 std::vector<std::pair<std::string, std::string> >* stats) OVERRIDE; |
| 68 virtual void OnExternalCacheHit(const std::string& key) OVERRIDE; | 69 virtual void OnExternalCacheHit(const std::string& key) OVERRIDE; |
| 69 | 70 |
| 70 private: | 71 private: |
| 71 typedef base::Callback<void(int result)> InitializeIndexCallback; | 72 typedef base::Callback<void(int result)> InitializeIndexCallback; |
| 72 | 73 |
| 73 // Must run on IO Thread. | 74 // Must run on IO Thread. |
| 74 void InitializeIndex(const CompletionCallback& callback, int result); | 75 void InitializeIndex(const CompletionCallback& callback, int result); |
| 75 | 76 |
| 77 // Dooms all entries previously accessed between |initial_time| and |
| 78 // |end_time|. Invoked when the index is ready. |
| 79 void IndexReadyForDoom(base::Time initial_time, |
| 80 base::Time end_time, |
| 81 const CompletionCallback& callback, |
| 82 int result); |
| 83 |
| 76 // Try to create the directory if it doesn't exist. | 84 // Try to create the directory if it doesn't exist. |
| 77 // Must run on Cache Thread. | 85 // Must run on Cache Thread. |
| 78 static void CreateDirectory( | 86 static void CreateDirectory( |
| 79 base::SingleThreadTaskRunner* io_thread, | 87 base::SingleThreadTaskRunner* io_thread, |
| 80 const base::FilePath& path, | 88 const base::FilePath& path, |
| 81 const InitializeIndexCallback& initialize_index_callback); | 89 const InitializeIndexCallback& initialize_index_callback); |
| 82 | 90 |
| 83 const base::FilePath path_; | 91 const base::FilePath path_; |
| 84 scoped_ptr<SimpleIndex> index_; | 92 scoped_ptr<SimpleIndex> index_; |
| 85 const scoped_refptr<base::SingleThreadTaskRunner> cache_thread_; | 93 const scoped_refptr<base::SingleThreadTaskRunner> cache_thread_; |
| 86 }; | 94 }; |
| 87 | 95 |
| 88 } // namespace disk_cache | 96 } // namespace disk_cache |
| 89 | 97 |
| 90 #endif // NET_DISK_CACHE_SIMPLE_SIMPLE_BACKEND_IMPL_H_ | 98 #endif // NET_DISK_CACHE_SIMPLE_SIMPLE_BACKEND_IMPL_H_ |
| OLD | NEW |