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 <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
13 #include "content/browser/service_worker/service_worker_context_core.h" | 13 #include "content/browser/service_worker/service_worker_context_core.h" |
14 #include "content/common/content_export.h" | 14 #include "content/common/content_export.h" |
15 #include "content/public/browser/service_worker_context.h" | 15 #include "content/public/browser/service_worker_context.h" |
16 | 16 |
17 namespace base { | 17 namespace base { |
18 class FilePath; | 18 class FilePath; |
19 class MessageLoopProxy; | 19 class MessageLoopProxy; |
20 class SequencedTaskRunner; | 20 class SequencedTaskRunner; |
21 } | 21 } |
22 | 22 |
| 23 namespace net { |
| 24 class URLRequestContext; |
| 25 } |
| 26 |
23 namespace quota { | 27 namespace quota { |
24 class QuotaManagerProxy; | 28 class QuotaManagerProxy; |
25 } | 29 } |
26 | 30 |
27 namespace content { | 31 namespace content { |
28 | 32 |
29 class BrowserContext; | 33 class BrowserContext; |
| 34 class ChromeBlobStorageContext; |
30 class ServiceWorkerContextCore; | 35 class ServiceWorkerContextCore; |
31 class ServiceWorkerContextObserver; | 36 class ServiceWorkerContextObserver; |
32 | 37 |
33 // A refcounted wrapper class for our core object. Higher level content lib | 38 // A refcounted wrapper class for our core object. Higher level content lib |
34 // classes keep references to this class on mutliple threads. The inner core | 39 // classes keep references to this class on mutliple threads. The inner core |
35 // instance is strictly single threaded and is not refcounted, the core object | 40 // instance is strictly single threaded and is not refcounted, the core object |
36 // is what is used internally in the service worker lib. | 41 // is what is used internally in the service worker lib. |
37 class CONTENT_EXPORT ServiceWorkerContextWrapper | 42 class CONTENT_EXPORT ServiceWorkerContextWrapper |
38 : NON_EXPORTED_BASE(public ServiceWorkerContext), | 43 : NON_EXPORTED_BASE(public ServiceWorkerContext), |
39 public base::RefCountedThreadSafe<ServiceWorkerContextWrapper> { | 44 public base::RefCountedThreadSafe<ServiceWorkerContextWrapper> { |
(...skipping 27 matching lines...) Expand all Loading... |
67 virtual void UnregisterServiceWorker(const GURL& pattern, | 72 virtual void UnregisterServiceWorker(const GURL& pattern, |
68 const ResultCallback& continuation) | 73 const ResultCallback& continuation) |
69 OVERRIDE; | 74 OVERRIDE; |
70 virtual void Terminate() OVERRIDE; | 75 virtual void Terminate() OVERRIDE; |
71 | 76 |
72 void AddObserver(ServiceWorkerContextObserver* observer); | 77 void AddObserver(ServiceWorkerContextObserver* observer); |
73 void RemoveObserver(ServiceWorkerContextObserver* observer); | 78 void RemoveObserver(ServiceWorkerContextObserver* observer); |
74 | 79 |
75 bool is_incognito() const { return is_incognito_; } | 80 bool is_incognito() const { return is_incognito_; } |
76 | 81 |
| 82 // The URLRequestContext doesn't exist until after the StoragePartition is |
| 83 // made (which is after this object is made). This function must be called |
| 84 // after this object is created but before any ServiceWorkerCache operations. |
| 85 // It must be called on the IO thread. |
| 86 void SetBlobParametersForCache( |
| 87 net::URLRequestContext* request_context, |
| 88 base::WeakPtr<webkit_blob::BlobStorageContext> blob_storage_context); |
| 89 |
77 private: | 90 private: |
78 friend class base::RefCountedThreadSafe<ServiceWorkerContextWrapper>; | 91 friend class base::RefCountedThreadSafe<ServiceWorkerContextWrapper>; |
79 friend class EmbeddedWorkerTestHelper; | 92 friend class EmbeddedWorkerTestHelper; |
80 friend class ServiceWorkerProcessManager; | 93 friend class ServiceWorkerProcessManager; |
81 virtual ~ServiceWorkerContextWrapper(); | 94 virtual ~ServiceWorkerContextWrapper(); |
82 | 95 |
83 void InitInternal(const base::FilePath& user_data_directory, | 96 void InitInternal(const base::FilePath& user_data_directory, |
84 base::SequencedTaskRunner* stores_task_runner, | 97 base::SequencedTaskRunner* stores_task_runner, |
85 base::SequencedTaskRunner* database_task_runner, | 98 base::SequencedTaskRunner* database_task_runner, |
86 base::MessageLoopProxy* disk_cache_thread, | 99 base::MessageLoopProxy* disk_cache_thread, |
87 quota::QuotaManagerProxy* quota_manager_proxy); | 100 quota::QuotaManagerProxy* quota_manager_proxy); |
88 void ShutdownOnIO(); | 101 void ShutdownOnIO(); |
89 | 102 |
90 void DidDeleteAndStartOver(ServiceWorkerStatusCode status); | 103 void DidDeleteAndStartOver(ServiceWorkerStatusCode status); |
91 | 104 |
92 const scoped_refptr<ObserverListThreadSafe<ServiceWorkerContextObserver> > | 105 const scoped_refptr<ObserverListThreadSafe<ServiceWorkerContextObserver> > |
93 observer_list_; | 106 observer_list_; |
94 const scoped_ptr<ServiceWorkerProcessManager> process_manager_; | 107 const scoped_ptr<ServiceWorkerProcessManager> process_manager_; |
95 // Cleared in Shutdown(): | 108 // Cleared in Shutdown(): |
96 scoped_ptr<ServiceWorkerContextCore> context_core_; | 109 scoped_ptr<ServiceWorkerContextCore> context_core_; |
97 | 110 |
98 // Initialized in Init(); true of the user data directory is empty. | 111 // Initialized in Init(); true of the user data directory is empty. |
99 bool is_incognito_; | 112 bool is_incognito_; |
100 }; | 113 }; |
101 | 114 |
102 } // namespace content | 115 } // namespace content |
103 | 116 |
104 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CONTEXT_WRAPPER_H_ | 117 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CONTEXT_WRAPPER_H_ |
OLD | NEW |