Chromium Code Reviews| Index: content/browser/service_worker/service_worker_job_coordinator.h |
| diff --git a/content/browser/service_worker/service_worker_job_coordinator.h b/content/browser/service_worker/service_worker_job_coordinator.h |
| index 46ead776e7e126d899a1524121f6cc8d82833b61..557ebe98e6dac9f94953bab7afa80124e09d3cc2 100644 |
| --- a/content/browser/service_worker/service_worker_job_coordinator.h |
| +++ b/content/browser/service_worker/service_worker_job_coordinator.h |
| @@ -5,8 +5,10 @@ |
| #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_JOB_COORDINATOR_H_ |
| #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_JOB_COORDINATOR_H_ |
| +#include <deque> |
| +#include <map> |
| + |
| #include "base/bind.h" |
| -#include "base/memory/scoped_vector.h" |
| #include "content/browser/service_worker/service_worker_register_job.h" |
| #include "content/browser/service_worker/service_worker_registration_status.h" |
| #include "content/browser/service_worker/service_worker_storage.h" |
| @@ -21,7 +23,7 @@ class ServiceWorkerRegistration; |
| // operations are run through instances of ServiceWorkerRegisterJob. |
| class CONTENT_EXPORT ServiceWorkerJobCoordinator { |
| public: |
| - ServiceWorkerJobCoordinator(ServiceWorkerStorage* storage); |
| + explicit ServiceWorkerJobCoordinator(ServiceWorkerStorage* storage); |
| ~ServiceWorkerJobCoordinator(); |
| void Register(const GURL& pattern, |
| @@ -32,34 +34,40 @@ class CONTENT_EXPORT ServiceWorkerJobCoordinator { |
| const GURL& pattern, |
| const ServiceWorkerRegisterJob::UnregistrationCallback& callback); |
| + // Jobs are removed whenever they are finished or canceled. |
| + void FinishJob(ServiceWorkerRegisterJob* job); |
| + |
| private: |
| friend class ServiceWorkerRegisterJob; |
| - typedef ScopedVector<ServiceWorkerRegisterJob> RegistrationJobList; |
| + class JobQueue { |
|
kinuko
2014/01/09 10:54:08
Unless we have tests specifically for this class t
alecflett
2014/01/09 21:23:14
The problem is that the enclosing class has a map<
|
| + public: |
| + JobQueue(); |
| + ~JobQueue(); |
| - // Jobs are removed whenever they are finished or canceled. |
| - void EraseJob(ServiceWorkerRegisterJob* job); |
| + void Push( |
| + scoped_ptr<ServiceWorkerRegisterJob> job, |
| + const ServiceWorkerRegisterJob::RegistrationCallback& callback); |
| - // Called at ServiceWorkerRegisterJob completion. |
| - void RegisterComplete( |
| - const ServiceWorkerRegisterJob::RegistrationCallback& callback, |
| - ServiceWorkerRegisterJob* job, |
| - ServiceWorkerRegistrationStatus status, |
| - ServiceWorkerRegistration* registration); |
| + void Pop(ServiceWorkerRegisterJob* job); |
| + |
| + private: |
| + std::deque<ServiceWorkerRegisterJob*> jobs_; |
| + }; |
| + |
| + typedef std::map<GURL, JobQueue> RegistrationJobMap; |
| // Called at ServiceWorkerRegisterJob completion. |
| void UnregisterComplete( |
| const ServiceWorkerRegisterJob::UnregistrationCallback& callback, |
| - ServiceWorkerRegisterJob* job, |
| ServiceWorkerRegistrationStatus status, |
| - ServiceWorkerRegistration* registration); |
| + const scoped_refptr<ServiceWorkerRegistration>& registration); |
| // The ServiceWorkerStorage object should always outlive this |
| ServiceWorkerStorage* storage_; |
| base::WeakPtrFactory<ServiceWorkerJobCoordinator> weak_factory_; |
| - // A list of currently running jobs. This is a temporary structure until we |
| - // start managing overlapping registrations explicitly. |
| - RegistrationJobList registration_jobs_; |
| + |
| + RegistrationJobMap jobs_; |
| DISALLOW_COPY_AND_ASSIGN(ServiceWorkerJobCoordinator); |
| }; |