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.
5 #ifndef CONTENT_BROWSER_CACHE_STORAGE_CACHE_STORAGE_CONTEXT_IMPL_H_
6 #define CONTENT_BROWSER_CACHE_STORAGE_CACHE_STORAGE_CONTEXT_IMPL_H_
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 #include "content/public/browser/cache_storage_context.h"
13 #include "content/public/browser/cache_storage_usage_info.h"
17 class SequencedTaskRunner
;
21 class URLRequestContextGetter
;
25 class QuotaManagerProxy
;
26 class SpecialStoragePolicy
;
32 class ChromeBlobStorageContext
;
33 class CacheStorageManager
;
35 // One instance of this exists per StoragePartition, and services multiple
36 // child processes/origins. Most logic is delegated to the owned
37 // CacheStorageManager instance, which is only accessed on the IO
39 class CONTENT_EXPORT CacheStorageContextImpl
40 : NON_EXPORTED_BASE(public CacheStorageContext
) {
42 explicit CacheStorageContextImpl(BrowserContext
* browser_context
);
44 // Init and Shutdown are for use on the UI thread when the profile,
45 // storagepartition is being setup and torn down.
46 void Init(const base::FilePath
& user_data_directory
,
47 storage::QuotaManagerProxy
* quota_manager_proxy
,
48 storage::SpecialStoragePolicy
* special_storage_policy
);
51 // Only callable on the IO thread.
52 CacheStorageManager
* cache_manager() const;
54 bool is_incognito() const { return is_incognito_
; }
56 // The URLRequestContext doesn't exist until after the StoragePartition is
57 // made (which is after this object is made). This function must be called
58 // after this object is created but before any CacheStorageCache operations.
59 // It must be called on the IO thread. If either parameter is NULL the
60 // function immediately returns without forwarding to the
61 // CacheStorageManager.
62 void SetBlobParametersForCache(
63 net::URLRequestContextGetter
* request_context_getter
,
64 ChromeBlobStorageContext
* blob_storage_context
);
66 // CacheStorageContext
67 void GetAllOriginsInfo(const GetUsageInfoCallback
& callback
) override
;
68 void DeleteForOrigin(const GURL
& origin
) override
;
71 ~CacheStorageContextImpl() override
;
74 void CreateCacheStorageManager(
75 const base::FilePath
& user_data_directory
,
76 const scoped_refptr
<base::SequencedTaskRunner
>& cache_task_runner
,
77 storage::QuotaManagerProxy
* quota_manager_proxy
,
78 storage::SpecialStoragePolicy
* special_storage_policy
);
82 // Initialized in Init(); true if the user data directory is empty.
83 bool is_incognito_
= false;
85 // Only accessed on the IO thread.
86 scoped_ptr
<CacheStorageManager
> cache_manager_
;
89 } // namespace content
91 #endif // CONTENT_BROWSER_CACHE_STORAGE_CACHE_STORAGE_CONTEXT_IMPL_H_