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

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

Issue 113133013: Refactor job coordination into a separate class. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove WeakPtr usage from Storage Created 6 years, 11 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_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 9e12eb518549cf05379e8199f07871f5fea38653..0d7e56085f6a66e0a63c99671f20b911e0bd0bee 100644
--- a/content/browser/service_worker/service_worker_register_job.h
+++ b/content/browser/service_worker/service_worker_register_job.h
@@ -15,6 +15,12 @@ namespace content {
// registration or unregistration.
class ServiceWorkerRegisterJob {
public:
+ 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,
@@ -22,7 +28,7 @@ class ServiceWorkerRegisterJob {
// All type of jobs (Register and Unregister) complete through a
// single call to this callback on the IO thread.
- ServiceWorkerRegisterJob(const base::WeakPtr<ServiceWorkerStorage>& storage,
+ ServiceWorkerRegisterJob(ServiceWorkerStorage* storage,
const RegistrationCompleteCallback& callback);
~ServiceWorkerRegisterJob();
@@ -51,13 +57,13 @@ class ServiceWorkerRegisterJob {
void RegisterPatternAndContinue(
const GURL& pattern,
const GURL& script_url,
- const ServiceWorkerStorage::RegistrationCallback& callback,
+ const RegistrationCallback& callback,
ServiceWorkerRegistrationStatus previous_status);
void UnregisterPatternAndContinue(
const GURL& pattern,
const GURL& script_url,
- const ServiceWorkerStorage::UnregistrationCallback& callback,
+ const UnregistrationCallback& callback,
bool found,
ServiceWorkerRegistrationStatus previous_status,
const scoped_refptr<ServiceWorkerRegistration>& previous_registration);
@@ -69,7 +75,14 @@ class ServiceWorkerRegisterJob {
ServiceWorkerRegistrationStatus status,
const scoped_refptr<ServiceWorkerRegistration>& registration);
- const base::WeakPtr<ServiceWorkerStorage> storage_;
+ // The ServiceWorkerStorage object should always outlive
+ // this.
+
+ // TODO(alecflett) When we support job cancelling, if we are keeping
+ // this job alive for any reason, be sure to clear this variable,
+ // because we may be cancelling while there are outstanding
+ // callbacks that expect access to storage_.
+ ServiceWorkerStorage* storage_;
const RegistrationCompleteCallback callback_;
base::WeakPtrFactory<ServiceWorkerRegisterJob> weak_factory_;

Powered by Google App Engine
This is Rietveld 408576698