Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(949)

Unified Diff: content/child/service_worker/service_worker_provider_context.h

Issue 1344783002: ServiceWorker: Carve out methods of ServiceWorkerProviderContext to delegate classes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add class comments more Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..2040bcdbacc6e839339f294e8102e43770898831 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 {
@@ -26,12 +25,26 @@ 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.
+// methods are called on the main thread. The lifetime of this class is equals
+// to the corresponding ServiceWorkerNetworkProvider.
+//
+// The role of this class varies for controllees and controllers:
+// - For controllees, this is used for keeping the associated registration and
+// the controller alive to create controllee's ServiceWorkerContainer. The
+// references to them are kept until OnDisassociateRegistration() is called
+// or OnSetControllerServiceWorker() is called with an invalid worker info.
+// - For controllers, this is used for keeping the associated registration and
+// its versions alive to create controller's ServiceWorkerGlobalScope. The
+// references to them are kept until OnDisassociateRegistration() is called.
+//
+// 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.
void OnAssociateRegistration(const ServiceWorkerRegistrationObjectInfo& info,
@@ -39,21 +52,25 @@ class ServiceWorkerProviderContext
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 +78,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);
};

Powered by Google App Engine
This is Rietveld 408576698