Index: content/browser/service_worker/service_worker_register_job.h |
diff --git a/content/browser/service_worker/service_worker_register_job.h b/content/browser/service_worker/service_worker_register_job.h |
index 0d7e56085f6a66e0a63c99671f20b911e0bd0bee..b6d5777bb3f4e8912455d9baee130d4c4fd4e326 100644 |
--- a/content/browser/service_worker/service_worker_register_job.h |
+++ b/content/browser/service_worker/service_worker_register_job.h |
@@ -5,33 +5,54 @@ |
#ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_REGISTER_JOB_H_ |
#define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_REGISTER_JOB_H_ |
+#include <vector> |
+ |
#include "base/memory/weak_ptr.h" |
#include "content/browser/service_worker/service_worker_registration_status.h" |
#include "content/browser/service_worker/service_worker_storage.h" |
namespace content { |
+class ServiceWorkerJobCoordinator; |
+ |
// A ServiceWorkerRegisterJob lives only for the lifetime of a single |
// registration or unregistration. |
class ServiceWorkerRegisterJob { |
public: |
+ enum RegistrationType { |
+ REGISTER, |
+ UNREGISTER, |
+ }; |
+ |
typedef base::Callback<void(ServiceWorkerRegistrationStatus status, |
const scoped_refptr<ServiceWorkerRegistration>& |
registration)> RegistrationCallback; |
typedef base::Callback<void(ServiceWorkerRegistrationStatus status)> |
UnregistrationCallback; |
- typedef base::Callback<void( |
- ServiceWorkerRegisterJob* job, |
- ServiceWorkerRegistrationStatus status, |
- ServiceWorkerRegistration* registration)> RegistrationCompleteCallback; |
- |
// All type of jobs (Register and Unregister) complete through a |
// single call to this callback on the IO thread. |
ServiceWorkerRegisterJob(ServiceWorkerStorage* storage, |
- const RegistrationCompleteCallback& callback); |
+ ServiceWorkerJobCoordinator* coordinator, |
+ const GURL& pattern, |
+ const GURL& script_url, |
+ RegistrationType type); |
~ServiceWorkerRegisterJob(); |
+ void AddCallback(const RegistrationCallback& callback); |
+ |
+ void Start(); |
+ |
+ const GURL& pattern() const { return pattern_; } |
+ const GURL& script_url() const { |
+ DCHECK(type_ == REGISTER); |
+ return script_url_; |
+ } |
+ RegistrationType type() const { return type_; } |
kinuko
2014/01/09 10:54:08
Looks like these public accessors are no longer ne
alecflett
2014/01/09 21:23:14
Done.
|
+ |
+ bool Equals(ServiceWorkerRegisterJob* job); |
+ |
+ private: |
// The Registration flow includes most or all of the following, |
// depending on what is already registered: |
// - creating a ServiceWorkerRegistration instance if there isn't |
@@ -44,25 +65,20 @@ class ServiceWorkerRegisterJob { |
// - Waiting for older ServiceWorkerVersions to deactivate |
// - designating the new version to be the 'active' version |
// This method should be called once and only once per job. |
- void StartRegister(const GURL& pattern, const GURL& script_url); |
+ void StartRegister(); |
// The Unregistration process is primarily cleanup, removing |
// everything that was created during the Registration process, |
// including the ServiceWorkerRegistration itself. |
// This method should be called once and only once per job. |
- void StartUnregister(const GURL& pattern); |
+ void StartUnregister(); |
- private: |
// These are all steps in the registration and unregistration pipeline. |
void RegisterPatternAndContinue( |
- const GURL& pattern, |
- const GURL& script_url, |
const RegistrationCallback& callback, |
ServiceWorkerRegistrationStatus previous_status); |
void UnregisterPatternAndContinue( |
- const GURL& pattern, |
- const GURL& script_url, |
const UnregistrationCallback& callback, |
bool found, |
ServiceWorkerRegistrationStatus previous_status, |
@@ -75,6 +91,10 @@ class ServiceWorkerRegisterJob { |
ServiceWorkerRegistrationStatus status, |
const scoped_refptr<ServiceWorkerRegistration>& registration); |
+ void RunCallbacks( |
+ ServiceWorkerRegistrationStatus status, |
+ const scoped_refptr<ServiceWorkerRegistration>& registration); |
+ |
// The ServiceWorkerStorage object should always outlive |
// this. |
@@ -83,8 +103,12 @@ class ServiceWorkerRegisterJob { |
// because we may be cancelling while there are outstanding |
// callbacks that expect access to storage_. |
ServiceWorkerStorage* storage_; |
- const RegistrationCompleteCallback callback_; |
+ ServiceWorkerJobCoordinator* coordinator_; |
+ const GURL pattern_; |
+ GURL script_url_; // should be unset for register case |
+ std::vector<RegistrationCallback> callbacks_; |
base::WeakPtrFactory<ServiceWorkerRegisterJob> weak_factory_; |
+ const RegistrationType type_; |
kinuko
2014/01/09 10:54:08
(While it's ok in this particular case) can you mo
alecflett
2014/01/09 21:23:14
Done.
|
DISALLOW_COPY_AND_ASSIGN(ServiceWorkerRegisterJob); |
}; |