| 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 SequencedTaskRunner; | 19 class SequencedTaskRunner; |
| 20 class SingleThreadTaskRunner; | 20 class SingleThreadTaskRunner; |
| 21 } | 21 } |
| 22 | 22 |
| 23 namespace net { | 23 namespace net { |
| 24 class URLRequestContextGetter; | 24 class URLRequestContextGetter; |
| 25 } | 25 } |
| 26 | 26 |
| 27 namespace quota { | 27 namespace storage { |
| 28 class QuotaManagerProxy; | 28 class QuotaManagerProxy; |
| 29 } | 29 } |
| 30 | 30 |
| 31 namespace content { | 31 namespace content { |
| 32 | 32 |
| 33 class BrowserContext; | 33 class BrowserContext; |
| 34 class ChromeBlobStorageContext; | 34 class ChromeBlobStorageContext; |
| 35 class ServiceWorkerContextCore; | 35 class ServiceWorkerContextCore; |
| 36 class ServiceWorkerContextObserver; | 36 class ServiceWorkerContextObserver; |
| 37 | 37 |
| 38 // 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 |
| 39 // 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 |
| 40 // 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 |
| 41 // is what is used internally in the service worker lib. | 41 // is what is used internally in the service worker lib. |
| 42 class CONTENT_EXPORT ServiceWorkerContextWrapper | 42 class CONTENT_EXPORT ServiceWorkerContextWrapper |
| 43 : NON_EXPORTED_BASE(public ServiceWorkerContext), | 43 : NON_EXPORTED_BASE(public ServiceWorkerContext), |
| 44 public base::RefCountedThreadSafe<ServiceWorkerContextWrapper> { | 44 public base::RefCountedThreadSafe<ServiceWorkerContextWrapper> { |
| 45 public: | 45 public: |
| 46 ServiceWorkerContextWrapper(BrowserContext* browser_context); | 46 ServiceWorkerContextWrapper(BrowserContext* browser_context); |
| 47 | 47 |
| 48 // Init and Shutdown are for use on the UI thread when the profile, | 48 // Init and Shutdown are for use on the UI thread when the profile, |
| 49 // storagepartition is being setup and torn down. | 49 // storagepartition is being setup and torn down. |
| 50 void Init(const base::FilePath& user_data_directory, | 50 void Init(const base::FilePath& user_data_directory, |
| 51 quota::QuotaManagerProxy* quota_manager_proxy); | 51 storage::QuotaManagerProxy* quota_manager_proxy); |
| 52 void Shutdown(); | 52 void Shutdown(); |
| 53 | 53 |
| 54 // Deletes all files on disk and restarts the system asynchronously. This | 54 // Deletes all files on disk and restarts the system asynchronously. This |
| 55 // leaves the system in a disabled state until it's done. This should be | 55 // leaves the system in a disabled state until it's done. This should be |
| 56 // called on the IO thread. | 56 // called on the IO thread. |
| 57 void DeleteAndStartOver(); | 57 void DeleteAndStartOver(); |
| 58 | 58 |
| 59 // The core context is only for use on the IO thread. | 59 // The core context is only for use on the IO thread. |
| 60 ServiceWorkerContextCore* context(); | 60 ServiceWorkerContextCore* context(); |
| 61 | 61 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 friend class base::RefCountedThreadSafe<ServiceWorkerContextWrapper>; | 95 friend class base::RefCountedThreadSafe<ServiceWorkerContextWrapper>; |
| 96 friend class EmbeddedWorkerTestHelper; | 96 friend class EmbeddedWorkerTestHelper; |
| 97 friend class ServiceWorkerProcessManager; | 97 friend class ServiceWorkerProcessManager; |
| 98 virtual ~ServiceWorkerContextWrapper(); | 98 virtual ~ServiceWorkerContextWrapper(); |
| 99 | 99 |
| 100 void InitInternal( | 100 void InitInternal( |
| 101 const base::FilePath& user_data_directory, | 101 const base::FilePath& user_data_directory, |
| 102 const scoped_refptr<base::SequencedTaskRunner>& stores_task_runner, | 102 const scoped_refptr<base::SequencedTaskRunner>& stores_task_runner, |
| 103 const scoped_refptr<base::SequencedTaskRunner>& database_task_runner, | 103 const scoped_refptr<base::SequencedTaskRunner>& database_task_runner, |
| 104 const scoped_refptr<base::SingleThreadTaskRunner>& disk_cache_thread, | 104 const scoped_refptr<base::SingleThreadTaskRunner>& disk_cache_thread, |
| 105 quota::QuotaManagerProxy* quota_manager_proxy); | 105 storage::QuotaManagerProxy* quota_manager_proxy); |
| 106 void ShutdownOnIO(); | 106 void ShutdownOnIO(); |
| 107 | 107 |
| 108 void DidDeleteAndStartOver(ServiceWorkerStatusCode status); | 108 void DidDeleteAndStartOver(ServiceWorkerStatusCode status); |
| 109 | 109 |
| 110 void DidGetAllRegistrationsForGetAllOrigins( | 110 void DidGetAllRegistrationsForGetAllOrigins( |
| 111 const GetUsageInfoCallback& callback, | 111 const GetUsageInfoCallback& callback, |
| 112 const std::vector<ServiceWorkerRegistrationInfo>& registrations); | 112 const std::vector<ServiceWorkerRegistrationInfo>& registrations); |
| 113 void DidGetAllRegistrationsForDeleteForOrigin( | 113 void DidGetAllRegistrationsForDeleteForOrigin( |
| 114 const GURL& origin, | 114 const GURL& origin, |
| 115 const std::vector<ServiceWorkerRegistrationInfo>& registrations); | 115 const std::vector<ServiceWorkerRegistrationInfo>& registrations); |
| 116 | 116 |
| 117 const scoped_refptr<ObserverListThreadSafe<ServiceWorkerContextObserver> > | 117 const scoped_refptr<ObserverListThreadSafe<ServiceWorkerContextObserver> > |
| 118 observer_list_; | 118 observer_list_; |
| 119 const scoped_ptr<ServiceWorkerProcessManager> process_manager_; | 119 const scoped_ptr<ServiceWorkerProcessManager> process_manager_; |
| 120 // Cleared in Shutdown(): | 120 // Cleared in Shutdown(): |
| 121 scoped_ptr<ServiceWorkerContextCore> context_core_; | 121 scoped_ptr<ServiceWorkerContextCore> context_core_; |
| 122 | 122 |
| 123 // Initialized in Init(); true of the user data directory is empty. | 123 // Initialized in Init(); true of the user data directory is empty. |
| 124 bool is_incognito_; | 124 bool is_incognito_; |
| 125 }; | 125 }; |
| 126 | 126 |
| 127 } // namespace content | 127 } // namespace content |
| 128 | 128 |
| 129 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CONTEXT_WRAPPER_H_ | 129 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CONTEXT_WRAPPER_H_ |
| OLD | NEW |