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 #include "content/public/browser/cache_storage_context.h" | |
13 | |
14 namespace base { | |
15 class FilePath; | |
16 class SequencedTaskRunner; | |
17 } | |
18 | |
19 namespace net { | |
20 class URLRequestContextGetter; | |
21 } | |
22 | |
23 namespace storage { | |
24 class QuotaManagerProxy; | |
25 class SpecialStoragePolicy; | |
26 } | |
27 | |
28 namespace content { | |
29 | |
30 class BrowserContext; | |
31 class ChromeBlobStorageContext; | |
32 class ServiceWorkerCacheStorageManager; | |
33 | |
34 // One instance of this exists per StoragePartition, and services multiple | |
35 // child processes/origins. Most logic is delegated to the owned | |
36 // ServiceWorkerCacheStorageManager instance, which is only accessed on the IO | |
37 // thread. | |
38 class CONTENT_EXPORT CacheStorageContextImpl | |
39 : NON_EXPORTED_BASE(public CacheStorageContext), | |
40 public base::RefCountedThreadSafe<CacheStorageContextImpl> { | |
41 public: | |
42 explicit CacheStorageContextImpl(BrowserContext* browser_context); | |
43 | |
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); | |
49 void Shutdown(); | |
50 | |
51 // Only callable on the IO thread. | |
52 ServiceWorkerCacheStorageManager* cache_manager() const; | |
53 | |
54 bool is_incognito() const { return is_incognito_; } | |
55 | |
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 ServiceWorkerCache 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 // ServiceWorkerCacheStorageManager. | |
62 void SetBlobParametersForCache( | |
63 net::URLRequestContextGetter* request_context, | |
64 ChromeBlobStorageContext* blob_storage_context); | |
65 | |
66 private: | |
67 friend class base::RefCountedThreadSafe<CacheStorageContextImpl>; | |
68 | |
69 ~CacheStorageContextImpl() override; | |
70 | |
71 void CreateCacheStorageManager( | |
72 const base::FilePath& user_data_directory, | |
73 const scoped_refptr<base::SequencedTaskRunner>& cache_task_runner, | |
74 storage::QuotaManagerProxy* quota_manager_proxy, | |
75 storage::SpecialStoragePolicy* special_storage_policy); | |
76 | |
77 void ShutdownOnIO(); | |
78 | |
79 // Initialized in Init(); true if the user data directory is empty. | |
80 bool is_incognito_ = false; | |
kinuko
2015/03/12 10:57:25
Yay we're now in c++11 world :)
| |
81 | |
82 // Only accessed on the IO thread. | |
83 scoped_ptr<ServiceWorkerCacheStorageManager> cache_manager_; | |
84 }; | |
85 | |
86 } // namespace content | |
87 | |
88 #endif // CONTENT_BROWSER_SERVICE_WORKER_CACHE_STORAGE_CONTEXT_IMPL_H_ | |
OLD | NEW |