| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_REGISTER_JOB_H_ | 5 #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_REGISTER_JOB_H_ |
| 6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_REGISTER_JOB_H_ | 6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_REGISTER_JOB_H_ |
| 7 | 7 |
| 8 #include "base/memory/weak_ptr.h" | 8 #include "base/memory/weak_ptr.h" |
| 9 #include "content/browser/service_worker/service_worker_job_coordinator.h" |
| 9 #include "content/browser/service_worker/service_worker_registration_status.h" | 10 #include "content/browser/service_worker/service_worker_registration_status.h" |
| 10 #include "content/browser/service_worker/service_worker_storage.h" | 11 #include "content/browser/service_worker/service_worker_storage.h" |
| 11 | 12 |
| 12 namespace content { | 13 namespace content { |
| 13 | 14 |
| 14 // A ServiceWorkerRegisterJob lives only for the lifetime of a single | 15 // A ServiceWorkerRegisterJob lives only for the lifetime of a single |
| 15 // registration or unregistration. | 16 // registration or unregistration. |
| 16 class ServiceWorkerRegisterJob { | 17 class ServiceWorkerRegisterJob { |
| 17 public: | 18 public: |
| 18 typedef base::Callback<void( | 19 typedef base::Callback<void( |
| (...skipping 25 matching lines...) Expand all Loading... |
| 44 // everything that was created during the Registration process, | 45 // everything that was created during the Registration process, |
| 45 // including the ServiceWorkerRegistration itself. | 46 // including the ServiceWorkerRegistration itself. |
| 46 // This method should be called once and only once per job. | 47 // This method should be called once and only once per job. |
| 47 void StartUnregister(const GURL& pattern); | 48 void StartUnregister(const GURL& pattern); |
| 48 | 49 |
| 49 private: | 50 private: |
| 50 // These are all steps in the registration and unregistration pipeline. | 51 // These are all steps in the registration and unregistration pipeline. |
| 51 void RegisterPatternAndContinue( | 52 void RegisterPatternAndContinue( |
| 52 const GURL& pattern, | 53 const GURL& pattern, |
| 53 const GURL& script_url, | 54 const GURL& script_url, |
| 54 const ServiceWorkerStorage::RegistrationCallback& callback, | 55 const ServiceWorkerJobCoordinator::RegistrationCallback& callback, |
| 55 ServiceWorkerRegistrationStatus previous_status); | 56 ServiceWorkerRegistrationStatus previous_status); |
| 56 | 57 |
| 57 void UnregisterPatternAndContinue( | 58 void UnregisterPatternAndContinue( |
| 58 const GURL& pattern, | 59 const GURL& pattern, |
| 59 const GURL& script_url, | 60 const GURL& script_url, |
| 60 const ServiceWorkerStorage::UnregistrationCallback& callback, | 61 const ServiceWorkerJobCoordinator::UnregistrationCallback& callback, |
| 61 bool found, | 62 bool found, |
| 62 ServiceWorkerRegistrationStatus previous_status, | 63 ServiceWorkerRegistrationStatus previous_status, |
| 63 const scoped_refptr<ServiceWorkerRegistration>& previous_registration); | 64 const scoped_refptr<ServiceWorkerRegistration>& previous_registration); |
| 64 | 65 |
| 65 // These methods are the last internal callback in the callback | 66 // These methods are the last internal callback in the callback |
| 66 // chain, and ultimately call callback_. | 67 // chain, and ultimately call callback_. |
| 67 void UnregisterComplete(ServiceWorkerRegistrationStatus status); | 68 void UnregisterComplete(ServiceWorkerRegistrationStatus status); |
| 68 void RegisterComplete( | 69 void RegisterComplete( |
| 69 ServiceWorkerRegistrationStatus status, | 70 ServiceWorkerRegistrationStatus status, |
| 70 const scoped_refptr<ServiceWorkerRegistration>& registration); | 71 const scoped_refptr<ServiceWorkerRegistration>& registration); |
| 71 | 72 |
| 72 const base::WeakPtr<ServiceWorkerStorage> storage_; | 73 const base::WeakPtr<ServiceWorkerStorage> storage_; |
| 73 const RegistrationCompleteCallback callback_; | 74 const RegistrationCompleteCallback callback_; |
| 74 base::WeakPtrFactory<ServiceWorkerRegisterJob> weak_factory_; | 75 base::WeakPtrFactory<ServiceWorkerRegisterJob> weak_factory_; |
| 75 | 76 |
| 76 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerRegisterJob); | 77 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerRegisterJob); |
| 77 }; | 78 }; |
| 78 } // namespace content | 79 } // namespace content |
| 79 | 80 |
| 80 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_REGISTER_JOB_H_ | 81 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_REGISTER_JOB_H_ |
| OLD | NEW |