| 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 | 39 // TODO(jsbell): Derive from a public CacheStorageContext. crbug.com/466371 |
| 38 class CONTENT_EXPORT CacheStorageContextImpl | 40 class CONTENT_EXPORT CacheStorageContextImpl |
| 39 : public base::RefCountedThreadSafe<CacheStorageContextImpl> { | 41 : NON_EXPORTED_BASE(public CacheStorageContext) { |
| 40 public: | 42 public: |
| 41 explicit CacheStorageContextImpl(BrowserContext* browser_context); | 43 explicit CacheStorageContextImpl(BrowserContext* browser_context); |
| 42 | 44 |
| 43 // Init and Shutdown are for use on the UI thread when the profile, | 45 // Init and Shutdown are for use on the UI thread when the profile, |
| 44 // storagepartition is being setup and torn down. | 46 // storagepartition is being setup and torn down. |
| 45 void Init(const base::FilePath& user_data_directory, | 47 void Init(const base::FilePath& user_data_directory, |
| 46 storage::QuotaManagerProxy* quota_manager_proxy, | 48 storage::QuotaManagerProxy* quota_manager_proxy, |
| 47 storage::SpecialStoragePolicy* special_storage_policy); | 49 storage::SpecialStoragePolicy* special_storage_policy); |
| 48 void Shutdown(); | 50 void Shutdown(); |
| 49 | 51 |
| 50 // Only callable on the IO thread. | 52 // Only callable on the IO thread. |
| 51 CacheStorageManager* cache_manager() const; | 53 CacheStorageManager* cache_manager() const; |
| 52 | 54 |
| 53 bool is_incognito() const { return is_incognito_; } | 55 bool is_incognito() const { return is_incognito_; } |
| 54 | 56 |
| 55 // The URLRequestContext doesn't exist until after the StoragePartition is | 57 // The URLRequestContext doesn't exist until after the StoragePartition is |
| 56 // made (which is after this object is made). This function must be called | 58 // made (which is after this object is made). This function must be called |
| 57 // after this object is created but before any CacheStorageCache operations. | 59 // 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 | 60 // It must be called on the IO thread. If either parameter is NULL the |
| 59 // function immediately returns without forwarding to the | 61 // function immediately returns without forwarding to the |
| 60 // CacheStorageManager. | 62 // CacheStorageManager. |
| 61 void SetBlobParametersForCache( | 63 void SetBlobParametersForCache( |
| 62 net::URLRequestContextGetter* request_context_getter, | 64 net::URLRequestContextGetter* request_context_getter, |
| 63 ChromeBlobStorageContext* blob_storage_context); | 65 ChromeBlobStorageContext* blob_storage_context); |
| 64 | 66 |
| 67 // CacheStorageContext |
| 68 void GetAllOriginsInfo(const GetUsageInfoCallback& callback) override; |
| 69 void DeleteForOrigin(const GURL& origin) override; |
| 70 |
| 71 protected: |
| 72 ~CacheStorageContextImpl() override; |
| 73 |
| 65 private: | 74 private: |
| 66 friend class base::RefCountedThreadSafe<CacheStorageContextImpl>; | |
| 67 | |
| 68 ~CacheStorageContextImpl(); | |
| 69 | |
| 70 void CreateCacheStorageManager( | 75 void CreateCacheStorageManager( |
| 71 const base::FilePath& user_data_directory, | 76 const base::FilePath& user_data_directory, |
| 72 const scoped_refptr<base::SequencedTaskRunner>& cache_task_runner, | 77 const scoped_refptr<base::SequencedTaskRunner>& cache_task_runner, |
| 73 storage::QuotaManagerProxy* quota_manager_proxy, | 78 storage::QuotaManagerProxy* quota_manager_proxy, |
| 74 storage::SpecialStoragePolicy* special_storage_policy); | 79 storage::SpecialStoragePolicy* special_storage_policy); |
| 75 | 80 |
| 76 void ShutdownOnIO(); | 81 void ShutdownOnIO(); |
| 77 | 82 |
| 78 // Initialized in Init(); true if the user data directory is empty. | 83 // Initialized in Init(); true if the user data directory is empty. |
| 79 bool is_incognito_ = false; | 84 bool is_incognito_ = false; |
| 80 | 85 |
| 81 // Only accessed on the IO thread. | 86 // Only accessed on the IO thread. |
| 82 scoped_ptr<CacheStorageManager> cache_manager_; | 87 scoped_ptr<CacheStorageManager> cache_manager_; |
| 83 }; | 88 }; |
| 84 | 89 |
| 85 } // namespace content | 90 } // namespace content |
| 86 | 91 |
| 87 #endif // CONTENT_BROWSER_CACHE_STORAGE_CACHE_STORAGE_CONTEXT_IMPL_H_ | 92 #endif // CONTENT_BROWSER_CACHE_STORAGE_CACHE_STORAGE_CONTEXT_IMPL_H_ |
| OLD | NEW |