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 #ifndef CONTENT_BROWSER_APPCACHE_APPCACHE_DISK_CACHE_H_ | 5 #ifndef CONTENT_BROWSER_APPCACHE_APPCACHE_DISK_CACHE_H_ |
| 6 #define CONTENT_BROWSER_APPCACHE_APPCACHE_DISK_CACHE_H_ | 6 #define CONTENT_BROWSER_APPCACHE_APPCACHE_DISK_CACHE_H_ |
| 7 | 7 |
| 8 #include <set> | 8 #include <set> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
| 12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "content/browser/appcache/appcache_response.h" | 13 #include "content/browser/appcache/appcache_response.h" |
| 14 #include "content/common/content_export.h" | 14 #include "content/common/content_export.h" |
| 15 #include "net/disk_cache/disk_cache.h" | 15 #include "net/disk_cache/disk_cache.h" |
| 16 | 16 |
| 17 namespace base { | 17 namespace base { |
| 18 class SingleThreadTaskRunner; | 18 class SingleThreadTaskRunner; |
| 19 } // namespace base | 19 } // namespace base |
| 20 | 20 |
| 21 namespace content { | 21 namespace content { |
| 22 | 22 |
| 23 // An implementation of AppCacheDiskCacheInterface that | 23 // An implementation of AppCacheDiskCacheInterface that |
| 24 // uses net::DiskCache as the backing store. | 24 // uses net::DiskCache as the backing store. |
| 25 class CONTENT_EXPORT AppCacheDiskCache | 25 class CONTENT_EXPORT AppCacheDiskCache |
| 26 : public AppCacheDiskCacheInterface { | 26 : public AppCacheDiskCacheInterface { |
| 27 public: | 27 public: |
| 28 AppCacheDiskCache(); | 28 AppCacheDiskCache(); |
|
michaeln
2015/05/14 23:35:26
might be cleaner to provide a second protected cto
nhiroki
2015/05/15 02:12:51
Done.
| |
| 29 ~AppCacheDiskCache() override; | 29 ~AppCacheDiskCache() override; |
| 30 | 30 |
| 31 // Initializes the object to use disk backed storage. | 31 // Initializes the object to use disk backed storage. |
| 32 int InitWithDiskBackend( | 32 int InitWithDiskBackend( |
| 33 const base::FilePath& disk_cache_directory, | 33 const base::FilePath& disk_cache_directory, |
| 34 int disk_cache_size, | 34 int disk_cache_size, |
| 35 bool force, | 35 bool force, |
| 36 const scoped_refptr<base::SingleThreadTaskRunner>& cache_thread, | 36 const scoped_refptr<base::SingleThreadTaskRunner>& cache_thread, |
| 37 const net::CompletionCallback& callback); | 37 const net::CompletionCallback& callback); |
| 38 | 38 |
| 39 // Initializes the object to use memory only storage. | 39 // Initializes the object to use memory only storage. |
| 40 // This is used for Chrome's incognito browsing. | 40 // This is used for Chrome's incognito browsing. |
| 41 int InitWithMemBackend(int disk_cache_size, | 41 int InitWithMemBackend(int disk_cache_size, |
| 42 const net::CompletionCallback& callback); | 42 const net::CompletionCallback& callback); |
| 43 | 43 |
| 44 void Disable(); | 44 void Disable(); |
| 45 bool is_disabled() const { return is_disabled_; } | 45 bool is_disabled() const { return is_disabled_; } |
| 46 | 46 |
| 47 int CreateEntry(int64 key, | 47 int CreateEntry(int64 key, |
| 48 Entry** entry, | 48 Entry** entry, |
| 49 const net::CompletionCallback& callback) override; | 49 const net::CompletionCallback& callback) override; |
| 50 int OpenEntry(int64 key, | 50 int OpenEntry(int64 key, |
| 51 Entry** entry, | 51 Entry** entry, |
| 52 const net::CompletionCallback& callback) override; | 52 const net::CompletionCallback& callback) override; |
| 53 int DoomEntry(int64 key, const net::CompletionCallback& callback) override; | 53 int DoomEntry(int64 key, const net::CompletionCallback& callback) override; |
| 54 | 54 |
| 55 protected: | |
| 56 bool use_simple_cache_ = false; | |
| 57 | |
| 55 private: | 58 private: |
| 56 class CreateBackendCallbackShim; | 59 class CreateBackendCallbackShim; |
| 57 class EntryImpl; | 60 class EntryImpl; |
| 58 | 61 |
| 59 // PendingCalls allow CreateEntry, OpenEntry, and DoomEntry to be called | 62 // PendingCalls allow CreateEntry, OpenEntry, and DoomEntry to be called |
| 60 // immediately after construction, without waiting for the | 63 // immediately after construction, without waiting for the |
| 61 // underlying disk_cache::Backend to be fully constructed. Early | 64 // underlying disk_cache::Backend to be fully constructed. Early |
| 62 // calls are queued up and serviced once the disk_cache::Backend is | 65 // calls are queued up and serviced once the disk_cache::Backend is |
| 63 // really ready to go. | 66 // really ready to go. |
| 64 enum PendingCallType { | 67 enum PendingCallType { |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 106 scoped_refptr<CreateBackendCallbackShim> create_backend_callback_; | 109 scoped_refptr<CreateBackendCallbackShim> create_backend_callback_; |
| 107 PendingCalls pending_calls_; | 110 PendingCalls pending_calls_; |
| 108 ActiveCalls active_calls_; | 111 ActiveCalls active_calls_; |
| 109 OpenEntries open_entries_; | 112 OpenEntries open_entries_; |
| 110 scoped_ptr<disk_cache::Backend> disk_cache_; | 113 scoped_ptr<disk_cache::Backend> disk_cache_; |
| 111 }; | 114 }; |
| 112 | 115 |
| 113 } // namespace content | 116 } // namespace content |
| 114 | 117 |
| 115 #endif // CONTENT_BROWSER_APPCACHE_APPCACHE_DISK_CACHE_H_ | 118 #endif // CONTENT_BROWSER_APPCACHE_APPCACHE_DISK_CACHE_H_ |
| OLD | NEW |