OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_CACHE_STORAGE_CACHE_STORAGE_H_ | 5 #ifndef CONTENT_BROWSER_CACHE_STORAGE_CACHE_STORAGE_H_ |
6 #define CONTENT_BROWSER_CACHE_STORAGE_CACHE_STORAGE_H_ | 6 #define CONTENT_BROWSER_CACHE_STORAGE_CACHE_STORAGE_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/callback.h" | 11 #include "base/callback.h" |
12 #include "base/files/file_path.h" | 12 #include "base/files/file_path.h" |
| 13 #include "base/memory/ref_counted.h" |
13 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
14 #include "content/browser/cache_storage/cache_storage_cache.h" | 15 #include "content/browser/cache_storage/cache_storage_cache.h" |
15 | 16 |
16 namespace base { | 17 namespace base { |
17 class SequencedTaskRunner; | 18 class SequencedTaskRunner; |
18 } | 19 } |
19 | 20 |
20 namespace net { | 21 namespace net { |
21 class URLRequestContext; | 22 class URLRequestContextGetter; |
22 } | 23 } |
23 | 24 |
24 namespace storage { | 25 namespace storage { |
25 class BlobStorageContext; | 26 class BlobStorageContext; |
26 } | 27 } |
27 | 28 |
28 namespace content { | 29 namespace content { |
29 class CacheStorageScheduler; | 30 class CacheStorageScheduler; |
30 | 31 |
31 // TODO(jkarlin): Constrain the total bytes used per origin. | 32 // TODO(jkarlin): Constrain the total bytes used per origin. |
32 | 33 |
33 // CacheStorage holds the set of caches for a given origin. It is | 34 // CacheStorage holds the set of caches for a given origin. It is |
34 // owned by the CacheStorageManager. This class expects to be run | 35 // owned by the CacheStorageManager. This class expects to be run |
35 // on the IO thread. The asynchronous methods are executed serially. | 36 // on the IO thread. The asynchronous methods are executed serially. |
36 class CONTENT_EXPORT CacheStorage { | 37 class CONTENT_EXPORT CacheStorage { |
37 public: | 38 public: |
38 typedef std::vector<std::string> StringVector; | 39 typedef std::vector<std::string> StringVector; |
39 typedef base::Callback<void(bool, CacheStorageError)> BoolAndErrorCallback; | 40 typedef base::Callback<void(bool, CacheStorageError)> BoolAndErrorCallback; |
40 typedef base::Callback<void(const scoped_refptr<CacheStorageCache>&, | 41 typedef base::Callback<void(const scoped_refptr<CacheStorageCache>&, |
41 CacheStorageError)> CacheAndErrorCallback; | 42 CacheStorageError)> CacheAndErrorCallback; |
42 typedef base::Callback<void(const StringVector&, CacheStorageError)> | 43 typedef base::Callback<void(const StringVector&, CacheStorageError)> |
43 StringsAndErrorCallback; | 44 StringsAndErrorCallback; |
44 | 45 |
45 static const char kIndexFileName[]; | 46 static const char kIndexFileName[]; |
46 | 47 |
47 CacheStorage( | 48 CacheStorage( |
48 const base::FilePath& origin_path, | 49 const base::FilePath& origin_path, |
49 bool memory_only, | 50 bool memory_only, |
50 base::SequencedTaskRunner* cache_task_runner, | 51 base::SequencedTaskRunner* cache_task_runner, |
51 net::URLRequestContext* request_context, | 52 const scoped_refptr<net::URLRequestContextGetter>& request_context_getter, |
52 const scoped_refptr<storage::QuotaManagerProxy>& quota_manager_proxy, | 53 const scoped_refptr<storage::QuotaManagerProxy>& quota_manager_proxy, |
53 base::WeakPtr<storage::BlobStorageContext> blob_context, | 54 base::WeakPtr<storage::BlobStorageContext> blob_context, |
54 const GURL& origin); | 55 const GURL& origin); |
55 | 56 |
56 // Any unfinished asynchronous operations may not complete or call their | 57 // Any unfinished asynchronous operations may not complete or call their |
57 // callbacks. | 58 // callbacks. |
58 virtual ~CacheStorage(); | 59 virtual ~CacheStorage(); |
59 | 60 |
60 // Get the cache for the given key. If the cache is not found it is | 61 // Get the cache for the given key. If the cache is not found it is |
61 // created. | 62 // created. |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 scoped_ptr<CacheLoader> cache_loader_; | 218 scoped_ptr<CacheLoader> cache_loader_; |
218 | 219 |
219 base::WeakPtrFactory<CacheStorage> weak_factory_; | 220 base::WeakPtrFactory<CacheStorage> weak_factory_; |
220 | 221 |
221 DISALLOW_COPY_AND_ASSIGN(CacheStorage); | 222 DISALLOW_COPY_AND_ASSIGN(CacheStorage); |
222 }; | 223 }; |
223 | 224 |
224 } // namespace content | 225 } // namespace content |
225 | 226 |
226 #endif // CONTENT_BROWSER_CACHE_STORAGE_CACHE_STORAGE_H_ | 227 #endif // CONTENT_BROWSER_CACHE_STORAGE_CACHE_STORAGE_H_ |
OLD | NEW |