OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_CONTEXT_IMPL_H_ | 5 #ifndef CONTENT_BROWSER_CACHE_STORAGE_CACHE_STORAGE_CONTEXT_IMPL_H_ |
6 #define CONTENT_BROWSER_CACHE_STORAGE_CACHE_STORAGE_CONTEXT_IMPL_H_ | 6 #define CONTENT_BROWSER_CACHE_STORAGE_CACHE_STORAGE_CONTEXT_IMPL_H_ |
7 | 7 |
8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
11 #include "content/common/content_export.h" | 11 #include "content/common/content_export.h" |
| 12 #include "content/public/browser/cache_storage_context.h" |
| 13 #include "content/public/browser/cache_storage_usage_info.h" |
12 | 14 |
13 namespace base { | 15 namespace base { |
14 class FilePath; | 16 class FilePath; |
15 class SequencedTaskRunner; | 17 class SequencedTaskRunner; |
16 } | 18 } |
17 | 19 |
18 namespace net { | 20 namespace net { |
19 class URLRequestContextGetter; | 21 class URLRequestContextGetter; |
20 } | 22 } |
21 | 23 |
22 namespace storage { | 24 namespace storage { |
23 class QuotaManagerProxy; | 25 class QuotaManagerProxy; |
24 class SpecialStoragePolicy; | 26 class SpecialStoragePolicy; |
25 } | 27 } |
26 | 28 |
27 namespace content { | 29 namespace content { |
28 | 30 |
29 class BrowserContext; | 31 class BrowserContext; |
30 class ChromeBlobStorageContext; | 32 class ChromeBlobStorageContext; |
31 class CacheStorageManager; | 33 class CacheStorageManager; |
32 | 34 |
33 // One instance of this exists per StoragePartition, and services multiple | 35 // One instance of this exists per StoragePartition, and services multiple |
34 // child processes/origins. Most logic is delegated to the owned | 36 // child processes/origins. Most logic is delegated to the owned |
35 // CacheStorageManager instance, which is only accessed on the IO | 37 // CacheStorageManager instance, which is only accessed on the IO |
36 // thread. | 38 // thread. |
37 // TODO(jsbell): Derive from a public CacheStorageContext. crbug.com/466371 | |
38 class CONTENT_EXPORT CacheStorageContextImpl | 39 class CONTENT_EXPORT CacheStorageContextImpl |
39 : public base::RefCountedThreadSafe<CacheStorageContextImpl> { | 40 : NON_EXPORTED_BASE(public CacheStorageContext) { |
40 public: | 41 public: |
41 explicit CacheStorageContextImpl(BrowserContext* browser_context); | 42 explicit CacheStorageContextImpl(BrowserContext* browser_context); |
42 | 43 |
43 // Init and Shutdown are for use on the UI thread when the profile, | 44 // Init and Shutdown are for use on the UI thread when the profile, |
44 // storagepartition is being setup and torn down. | 45 // storagepartition is being setup and torn down. |
45 void Init(const base::FilePath& user_data_directory, | 46 void Init(const base::FilePath& user_data_directory, |
46 storage::QuotaManagerProxy* quota_manager_proxy, | 47 storage::QuotaManagerProxy* quota_manager_proxy, |
47 storage::SpecialStoragePolicy* special_storage_policy); | 48 storage::SpecialStoragePolicy* special_storage_policy); |
48 void Shutdown(); | 49 void Shutdown(); |
49 | 50 |
50 // Only callable on the IO thread. | 51 // Only callable on the IO thread. |
51 CacheStorageManager* cache_manager() const; | 52 CacheStorageManager* cache_manager() const; |
52 | 53 |
53 bool is_incognito() const { return is_incognito_; } | 54 bool is_incognito() const { return is_incognito_; } |
54 | 55 |
55 // The URLRequestContext doesn't exist until after the StoragePartition is | 56 // The URLRequestContext doesn't exist until after the StoragePartition is |
56 // made (which is after this object is made). This function must be called | 57 // made (which is after this object is made). This function must be called |
57 // after this object is created but before any CacheStorageCache operations. | 58 // after this object is created but before any CacheStorageCache operations. |
58 // It must be called on the IO thread. If either parameter is NULL the | 59 // It must be called on the IO thread. If either parameter is NULL the |
59 // function immediately returns without forwarding to the | 60 // function immediately returns without forwarding to the |
60 // CacheStorageManager. | 61 // CacheStorageManager. |
61 void SetBlobParametersForCache( | 62 void SetBlobParametersForCache( |
62 net::URLRequestContextGetter* request_context_getter, | 63 net::URLRequestContextGetter* request_context_getter, |
63 ChromeBlobStorageContext* blob_storage_context); | 64 ChromeBlobStorageContext* blob_storage_context); |
64 | 65 |
| 66 // CacheStorageContext |
| 67 void GetAllOriginsInfo(const GetUsageInfoCallback& callback) override; |
| 68 void DeleteForOrigin(const GURL& origin) override; |
| 69 |
| 70 protected: |
| 71 ~CacheStorageContextImpl() override; |
| 72 |
65 private: | 73 private: |
66 friend class base::RefCountedThreadSafe<CacheStorageContextImpl>; | |
67 | |
68 ~CacheStorageContextImpl(); | |
69 | |
70 void CreateCacheStorageManager( | 74 void CreateCacheStorageManager( |
71 const base::FilePath& user_data_directory, | 75 const base::FilePath& user_data_directory, |
72 const scoped_refptr<base::SequencedTaskRunner>& cache_task_runner, | 76 const scoped_refptr<base::SequencedTaskRunner>& cache_task_runner, |
73 storage::QuotaManagerProxy* quota_manager_proxy, | 77 storage::QuotaManagerProxy* quota_manager_proxy, |
74 storage::SpecialStoragePolicy* special_storage_policy); | 78 storage::SpecialStoragePolicy* special_storage_policy); |
75 | 79 |
76 void ShutdownOnIO(); | 80 void ShutdownOnIO(); |
77 | 81 |
78 // Initialized in Init(); true if the user data directory is empty. | 82 // Initialized in Init(); true if the user data directory is empty. |
79 bool is_incognito_ = false; | 83 bool is_incognito_ = false; |
80 | 84 |
81 // Only accessed on the IO thread. | 85 // Only accessed on the IO thread. |
82 scoped_ptr<CacheStorageManager> cache_manager_; | 86 scoped_ptr<CacheStorageManager> cache_manager_; |
83 }; | 87 }; |
84 | 88 |
85 } // namespace content | 89 } // namespace content |
86 | 90 |
87 #endif // CONTENT_BROWSER_CACHE_STORAGE_CACHE_STORAGE_CONTEXT_IMPL_H_ | 91 #endif // CONTENT_BROWSER_CACHE_STORAGE_CACHE_STORAGE_CONTEXT_IMPL_H_ |
OLD | NEW |