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