Chromium Code Reviews| Index: content/child/service_worker/service_worker_provider_context.h |
| diff --git a/content/child/service_worker/service_worker_provider_context.h b/content/child/service_worker/service_worker_provider_context.h |
| index ca623fbd846b5e7fa8e4f2dee7962b31d5fcd842..2c70c6094110d618242458185314112b096187c2 100644 |
| --- a/content/child/service_worker/service_worker_provider_context.h |
| +++ b/content/child/service_worker/service_worker_provider_context.h |
| @@ -10,7 +10,6 @@ |
| #include "base/memory/ref_counted.h" |
| #include "base/sequenced_task_runner_helpers.h" |
| -#include "base/synchronization/lock.h" |
| #include "content/common/service_worker/service_worker_types.h" |
| namespace base { |
| @@ -27,33 +26,47 @@ class ThreadSafeSender; |
| // An instance of this class holds information related to Document/Worker. |
| // Created and destructed on the main thread. Unless otherwise noted, all |
| // methods are called on the main thread. |
| +// |
| +// The role of this class varies for controllees and controllers: |
| +// - For controllees, this is used for keeping the controller service worker |
|
falken
2015/10/07 06:39:13
nit: keeping the <noun> alive
nhiroki
2015/10/07 07:50:38
Done.
|
| +// until controllee's ServiceWorkerContainer is created. |
| +// - For controllers, this is used for keeping the associated registration and |
|
falken
2015/10/07 06:39:13
nit: ditto
nhiroki
2015/10/07 07:50:38
Done.
|
| +// its versions until controller's ServiceWorkerGlobalScope is created. |
|
falken
2015/10/07 06:39:13
Thanks for the comments. Can you also add comments
nhiroki
2015/10/07 07:50:38
Done.
|
| +// |
| +// These operations are actually done in delegate classes owned by this class: |
| +// ControlleeDelegate and ControllerDelegate. |
| class ServiceWorkerProviderContext |
| : public base::RefCountedThreadSafe<ServiceWorkerProviderContext, |
| ServiceWorkerProviderContextDeleter> { |
| public: |
| - explicit ServiceWorkerProviderContext(int provider_id); |
| + ServiceWorkerProviderContext(int provider_id, |
| + ServiceWorkerProviderType provider_type); |
| - // Called from ServiceWorkerDispatcher. |
| + // Called from ServiceWorkerDispatcher on the main thread. |
|
falken
2015/10/07 06:39:13
nit: We should either annotate each function with
nhiroki
2015/10/07 07:50:38
Point taken. Removed.
|
| void OnAssociateRegistration(const ServiceWorkerRegistrationObjectInfo& info, |
| const ServiceWorkerVersionAttributes& attrs); |
| void OnDisassociateRegistration(); |
| void OnSetControllerServiceWorker(const ServiceWorkerObjectInfo& info); |
| + // Called on the worker thread. Used for initializing |
| + // ServiceWorkerGlobalScope. |
| + void GetAssociatedRegistration(ServiceWorkerRegistrationObjectInfo* info, |
| + ServiceWorkerVersionAttributes* attrs); |
| + |
| int provider_id() const { return provider_id_; } |
| ServiceWorkerHandleReference* controller(); |
| - // Called on the worker thread. |
| - bool GetRegistrationInfoAndVersionAttributes( |
| - ServiceWorkerRegistrationObjectInfo* info, |
| - ServiceWorkerVersionAttributes* attrs); |
| - |
| private: |
| friend class base::DeleteHelper<ServiceWorkerProviderContext>; |
| friend class base::RefCountedThreadSafe<ServiceWorkerProviderContext, |
| ServiceWorkerProviderContextDeleter>; |
| friend struct ServiceWorkerProviderContextDeleter; |
| + class Delegate; |
| + class ControlleeDelegate; |
| + class ControllerDelegate; |
| + |
| ~ServiceWorkerProviderContext(); |
| void DestructOnMainThread() const; |
| @@ -61,17 +74,7 @@ class ServiceWorkerProviderContext |
| scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner_; |
| scoped_refptr<ThreadSafeSender> thread_safe_sender_; |
| - // Protects (installing, waiting, active) worker and registration references. |
| - base::Lock lock_; |
| - |
| - // Used on both the main thread and the worker thread. |
| - scoped_ptr<ServiceWorkerHandleReference> installing_; |
| - scoped_ptr<ServiceWorkerHandleReference> waiting_; |
| - scoped_ptr<ServiceWorkerHandleReference> active_; |
| - scoped_ptr<ServiceWorkerRegistrationHandleReference> registration_; |
| - |
| - // Used only on the main thread. |
| - scoped_ptr<ServiceWorkerHandleReference> controller_; |
| + scoped_ptr<Delegate> delegate_; |
| DISALLOW_COPY_AND_ASSIGN(ServiceWorkerProviderContext); |
| }; |