OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_SERVICE_WORKER_CONTEXT_WRAPPER_H_ | 5 #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CONTEXT_WRAPPER_H_ |
6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CONTEXT_WRAPPER_H_ | 6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CONTEXT_WRAPPER_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
11 #include <string> | 11 #include <string> |
12 #include <vector> | 12 #include <vector> |
13 | 13 |
14 #include "base/files/file_path.h" | 14 #include "base/files/file_path.h" |
15 #include "base/macros.h" | 15 #include "base/macros.h" |
16 #include "base/memory/ref_counted.h" | 16 #include "base/memory/ref_counted.h" |
17 #include "content/browser/service_worker/service_worker_context_core.h" | 17 #include "content/browser/service_worker/service_worker_context_core.h" |
18 #include "content/common/content_export.h" | 18 #include "content/common/content_export.h" |
19 #include "content/public/browser/service_worker_context.h" | 19 #include "content/public/browser/service_worker_context.h" |
20 #include "net/url_request/url_request_context_getter_observer.h" | |
21 | 20 |
22 namespace base { | 21 namespace base { |
23 class FilePath; | 22 class FilePath; |
24 class SequencedTaskRunner; | 23 class SequencedTaskRunner; |
25 class SingleThreadTaskRunner; | 24 class SingleThreadTaskRunner; |
26 } | 25 } |
27 | 26 |
28 namespace storage { | 27 namespace storage { |
29 class QuotaManagerProxy; | 28 class QuotaManagerProxy; |
30 class SpecialStoragePolicy; | 29 class SpecialStoragePolicy; |
31 } | 30 } |
32 | 31 |
33 namespace content { | 32 namespace content { |
34 | 33 |
35 class BrowserContext; | 34 class BrowserContext; |
36 class ResourceContext; | 35 class ResourceContext; |
37 class ServiceWorkerContextCore; | 36 class ServiceWorkerContextCore; |
38 class ServiceWorkerContextObserver; | 37 class ServiceWorkerContextObserver; |
39 class StoragePartitionImpl; | 38 class StoragePartitionImpl; |
40 | 39 |
41 // A refcounted wrapper class for our core object. Higher level content lib | 40 // A refcounted wrapper class for our core object. Higher level content lib |
42 // classes keep references to this class on mutliple threads. The inner core | 41 // classes keep references to this class on mutliple threads. The inner core |
43 // instance is strictly single threaded and is not refcounted, the core object | 42 // instance is strictly single threaded and is not refcounted, the core object |
44 // is what is used internally in the service worker lib. | 43 // is what is used internally in the service worker lib. |
45 class CONTENT_EXPORT ServiceWorkerContextWrapper | 44 class CONTENT_EXPORT ServiceWorkerContextWrapper |
46 : NON_EXPORTED_BASE(public ServiceWorkerContext), | 45 : NON_EXPORTED_BASE(public ServiceWorkerContext), |
47 public net::URLRequestContextGetterObserver, | |
48 public base::RefCountedThreadSafe<ServiceWorkerContextWrapper> { | 46 public base::RefCountedThreadSafe<ServiceWorkerContextWrapper> { |
49 public: | 47 public: |
50 using StatusCallback = base::Callback<void(ServiceWorkerStatusCode)>; | 48 using StatusCallback = base::Callback<void(ServiceWorkerStatusCode)>; |
51 using BoolCallback = base::Callback<void(bool)>; | 49 using BoolCallback = base::Callback<void(bool)>; |
52 using FindRegistrationCallback = | 50 using FindRegistrationCallback = |
53 ServiceWorkerStorage::FindRegistrationCallback; | 51 ServiceWorkerStorage::FindRegistrationCallback; |
54 using GetRegistrationsInfosCallback = | 52 using GetRegistrationsInfosCallback = |
55 ServiceWorkerStorage::GetRegistrationsInfosCallback; | 53 ServiceWorkerStorage::GetRegistrationsInfosCallback; |
56 using GetUserDataCallback = ServiceWorkerStorage::GetUserDataCallback; | 54 using GetUserDataCallback = ServiceWorkerStorage::GetUserDataCallback; |
57 using GetUserDataForAllRegistrationsCallback = | 55 using GetUserDataForAllRegistrationsCallback = |
58 ServiceWorkerStorage::GetUserDataForAllRegistrationsCallback; | 56 ServiceWorkerStorage::GetUserDataForAllRegistrationsCallback; |
59 | 57 |
60 ServiceWorkerContextWrapper(BrowserContext* browser_context); | 58 ServiceWorkerContextWrapper(BrowserContext* browser_context); |
61 | 59 |
62 // Init and Shutdown are for use on the UI thread when the profile, | 60 // Init and Shutdown are for use on the UI thread when the profile, |
63 // storagepartition is being setup and torn down. | 61 // storagepartition is being setup and torn down. |
64 void Init(const base::FilePath& user_data_directory, | 62 void Init(const base::FilePath& user_data_directory, |
65 storage::QuotaManagerProxy* quota_manager_proxy, | 63 storage::QuotaManagerProxy* quota_manager_proxy, |
66 storage::SpecialStoragePolicy* special_storage_policy); | 64 storage::SpecialStoragePolicy* special_storage_policy); |
67 void Shutdown(); | 65 void Shutdown(); |
68 | 66 |
69 // Must be called on the IO thread. | 67 // Must be called on the IO thread. |
70 void InitializeResourceContext( | 68 void InitializeResourceContext(ResourceContext* resource_context); |
71 ResourceContext* resource_context, | |
72 scoped_refptr<net::URLRequestContextGetter> request_context_getter); | |
73 | |
74 // For net::URLRequestContextGetterObserver | |
75 void OnContextShuttingDown() override; | |
76 | 69 |
77 // Deletes all files on disk and restarts the system asynchronously. This | 70 // Deletes all files on disk and restarts the system asynchronously. This |
78 // leaves the system in a disabled state until it's done. This should be | 71 // leaves the system in a disabled state until it's done. This should be |
79 // called on the IO thread. | 72 // called on the IO thread. |
80 void DeleteAndStartOver(); | 73 void DeleteAndStartOver(); |
81 | 74 |
82 // The StoragePartition should only be used on the UI thread. | 75 // The StoragePartition should only be used on the UI thread. |
83 // Can be null before/during init and during/after shutdown. | 76 // Can be null before/during init and during/after shutdown. |
84 StoragePartitionImpl* storage_partition() const; | 77 StoragePartitionImpl* storage_partition() const; |
85 | 78 |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 | 237 |
245 // Initialized in Init(); true if the user data directory is empty. | 238 // Initialized in Init(); true if the user data directory is empty. |
246 bool is_incognito_; | 239 bool is_incognito_; |
247 | 240 |
248 // Raw pointer to the StoragePartitionImpl owning |this|. | 241 // Raw pointer to the StoragePartitionImpl owning |this|. |
249 StoragePartitionImpl* storage_partition_; | 242 StoragePartitionImpl* storage_partition_; |
250 | 243 |
251 // The ResourceContext associated with this context. | 244 // The ResourceContext associated with this context. |
252 ResourceContext* resource_context_; | 245 ResourceContext* resource_context_; |
253 | 246 |
254 scoped_refptr<net::URLRequestContextGetter> request_context_getter_; | |
255 | |
256 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerContextWrapper); | 247 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerContextWrapper); |
257 }; | 248 }; |
258 | 249 |
259 } // namespace content | 250 } // namespace content |
260 | 251 |
261 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CONTEXT_WRAPPER_H_ | 252 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CONTEXT_WRAPPER_H_ |
OLD | NEW |