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