Chromium Code Reviews| Index: content/browser/service_worker/service_worker_context_wrapper.h |
| diff --git a/content/browser/service_worker/service_worker_context_wrapper.h b/content/browser/service_worker/service_worker_context_wrapper.h |
| index cea9c06a4d07cc4ed8e9bdf7a32cf687bf796c17..e3875030da74bb4ebdcef3f0ed2ecc207406d9d6 100644 |
| --- a/content/browser/service_worker/service_worker_context_wrapper.h |
| +++ b/content/browser/service_worker/service_worker_context_wrapper.h |
| @@ -22,6 +22,8 @@ class QuotaManagerProxy; |
| namespace content { |
| +class BrowserContext; |
| +class ServiceWorkerContextCore; |
| class ServiceWorkerContextObserver; |
| // A refcounted wrapper class for our core object. Higher level content lib |
| @@ -43,13 +45,30 @@ class CONTENT_EXPORT ServiceWorkerContextWrapper |
| // The core context is only for use on the IO thread. |
| ServiceWorkerContextCore* context(); |
| - // ServiceWorkerContext implementation: |
| - virtual void RegisterServiceWorker(const GURL& pattern, |
| - const GURL& script_url, |
| - int source_process_id, |
| - const ResultCallback& continuation) |
| - OVERRIDE; |
| + // Call this on the UI thread to get a reference to a running process suitable |
| + // for starting the Service Worker at |script_url|. Processes in |process_ids| |
| + // will be checked in order for existence, and if none exist, then a new |
| + // process will be created. Posts |callback| to the IO thread to indicate |
| + // whether creation succeeded and the process ID that has a new reference. |
| + // |
| + // Process creation can fail with SERVICE_WORKER_ERROR_START_WORKER_FAILED if |
| + // RenderProcessHost::Init fails. |
| + void IncrementWorkerRef( |
|
kinuko
2014/04/25 13:46:35
Could these method be factored out into its own cl
Jeffrey Yasskin
2014/04/26 03:52:19
Done.
|
| + const std::vector<int>& process_ids, |
| + const GURL& script_url, |
| + const base::Callback<void(ServiceWorkerStatusCode, int process_id)>& |
| + callback) const; |
| + |
| + // Call this on the UI thread to drop a reference to a process that was |
| + // running a Service Worker. This must match a call to IncrementWorkerRef. |
| + static void DecrementWorkerRef(int process_id); |
| + // ServiceWorkerContext implementation: |
| + virtual void RegisterServiceWorker( |
| + const GURL& pattern, |
| + const GURL& script_url, |
| + BrowserContext* context, |
| + const ResultCallback& continuation) OVERRIDE; |
| virtual void UnregisterServiceWorker(const GURL& pattern, |
| int source_process_id, |
| const ResultCallback& continuation) |
| @@ -58,10 +77,18 @@ class CONTENT_EXPORT ServiceWorkerContextWrapper |
| void AddObserver(ServiceWorkerContextObserver* observer); |
| void RemoveObserver(ServiceWorkerContextObserver* observer); |
| + // These functions will be called on the UI thread, take a process ID to |
| + // Increment/DecrementWorkerRefCount(), and should return whether the process |
| + // existed. Null Callbacks reset the behavior to the default. |
| + static void ResetWorkerRefCountOperationsForTest( |
| + const base::Callback<bool(int)>& increment = base::Callback<bool(int)>(), |
| + const base::Callback<bool(int)>& decrement = base::Callback<bool(int)>()); |
| + |
| private: |
| friend class base::RefCountedThreadSafe<ServiceWorkerContextWrapper>; |
| virtual ~ServiceWorkerContextWrapper(); |
| + BrowserContext* browser_context_; // UI thread-only; cleared in Shutdown(). |
| scoped_ptr<ServiceWorkerContextCore> context_core_; |
| scoped_refptr<ObserverListThreadSafe<ServiceWorkerContextObserver> > |
| observer_list_; |