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

Unified Diff: content/browser/service_worker/service_worker_provider_host.h

Issue 417043006: ServiceWorker: Make SWProviderHost listen to SWRegistration (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: address falken's comments Created 6 years, 4 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/browser/service_worker/service_worker_provider_host.h
diff --git a/content/browser/service_worker/service_worker_provider_host.h b/content/browser/service_worker/service_worker_provider_host.h
index 3175ef10d160dc8abfb8df41266eb0bddd38adf6..ba1e3943ac6246add2e71d9fcc119529a269bc5e 100644
--- a/content/browser/service_worker/service_worker_provider_host.h
+++ b/content/browser/service_worker/service_worker_provider_host.h
@@ -10,6 +10,7 @@
#include "base/memory/ref_counted.h"
#include "base/memory/weak_ptr.h"
+#include "content/browser/service_worker/service_worker_registration.h"
#include "content/common/content_export.h"
#include "content/common/service_worker/service_worker_types.h"
#include "content/public/common/resource_type.h"
@@ -38,13 +39,20 @@ class ServiceWorkerVersion;
// Note this class can also host a running service worker, in which
// case it will observe resource loads made directly by the service worker.
class CONTENT_EXPORT ServiceWorkerProviderHost
- : public base::SupportsWeakPtr<ServiceWorkerProviderHost> {
+ : public ServiceWorkerRegistration::Listener,
+ public base::SupportsWeakPtr<ServiceWorkerProviderHost> {
public:
ServiceWorkerProviderHost(int process_id,
int provider_id,
base::WeakPtr<ServiceWorkerContextCore> context,
ServiceWorkerDispatcherHost* dispatcher_host);
- ~ServiceWorkerProviderHost();
+ virtual ~ServiceWorkerProviderHost();
+
+ // ServiceWorkerRegistration::Listener overrides.
michaeln 2014/08/05 23:57:15 please put this in the private section since this
nhiroki 2014/08/06 06:57:27 Moved.
+ virtual void OnVersionAttributesChanged(
+ ServiceWorkerRegistration* registration,
+ ChangedVersionAttributesMask changed_mask,
+ const ServiceWorkerRegistrationInfo& info) OVERRIDE;
int process_id() const { return process_id_; }
int provider_id() const { return provider_id_; }
@@ -87,6 +95,9 @@ class CONTENT_EXPORT ServiceWorkerProviderHost
// provider, the method will reset that field to NULL.
void UnsetVersion(ServiceWorkerVersion* version);
+ // Associates to |registration| to listen for its version change events.
+ void SetRegistration(ServiceWorkerRegistration* registration);
michaeln 2014/08/05 23:57:15 We'll need to clear this association too in some c
nhiroki 2014/08/06 06:57:27 Done (please see my reply comment in service_worke
+
// Returns false if the version is not in the expected STARTING in our
// process state. That would be indicative of a bad IPC message.
bool SetHostedVersionId(int64 versions_id);
@@ -100,6 +111,10 @@ class CONTENT_EXPORT ServiceWorkerProviderHost
// Returns true if |version| can be associated with this provider.
bool CanAssociateVersion(ServiceWorkerVersion* version);
+ // Returns true if this provider hasn't been associated with any registration
+ // yet.
+ bool CanAssociateRegistration();
+
// Returns true if the context referred to by this host (i.e. |context_|) is
// still alive.
bool IsContextAlive();
@@ -118,6 +133,8 @@ class CONTENT_EXPORT ServiceWorkerProviderHost
const int provider_id_;
GURL document_url_;
+ scoped_refptr<ServiceWorkerRegistration> associated_registration_;
+
scoped_refptr<ServiceWorkerVersion> controlling_version_;
scoped_refptr<ServiceWorkerVersion> active_version_;
scoped_refptr<ServiceWorkerVersion> waiting_version_;

Powered by Google App Engine
This is Rietveld 408576698