| 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
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..e57ae7eb131681a12287e80bd11bb3e7138458e3
|
| --- /dev/null
|
| +++ b/content/browser/service_worker/service_worker_job_coordinator.h
|
| @@ -0,0 +1,69 @@
|
| +// Copyright 2013 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_JOB_COORDINATOR_H_
|
| +#define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_JOB_COORDINATOR_H_
|
| +
|
| +#include "base/bind.h"
|
| +#include "base/memory/scoped_vector.h"
|
| +#include "content/browser/service_worker/service_worker_registration_status.h"
|
| +#include "content/browser/service_worker/service_worker_storage.h"
|
| +#include "content/common/content_export.h"
|
| +#include "url/gurl.h"
|
| +
|
| +namespace content {
|
| +
|
| +class ServiceWorkerRegisterJob;
|
| +class ServiceWorkerRegistration;
|
| +
|
| +// This class manages all in-flight jobs. Any asynchronous
|
| +// operations are run through instances of ServiceWorkerRegisterJob.
|
| +class CONTENT_EXPORT ServiceWorkerJobCoordinator {
|
| + public:
|
| + ServiceWorkerJobCoordinator(
|
| + const base::WeakPtr<ServiceWorkerStorage>& storage);
|
| + ~ServiceWorkerJobCoordinator();
|
| +
|
| + typedef base::Callback<void(ServiceWorkerRegistrationStatus status,
|
| + const scoped_refptr<ServiceWorkerRegistration>&
|
| + registration)> RegistrationCallback;
|
| + typedef base::Callback<
|
| + void(ServiceWorkerRegistrationStatus status)> UnregistrationCallback;
|
| +
|
| + void Register(const GURL& pattern,
|
| + const GURL& script_url,
|
| + const RegistrationCallback& callback);
|
| +
|
| + void Unregister(const GURL& pattern, const UnregistrationCallback& callback);
|
| +
|
| + private:
|
| + friend class ServiceWorkerRegisterJob;
|
| +
|
| + typedef ScopedVector<ServiceWorkerRegisterJob> RegistrationJobList;
|
| +
|
| + // Jobs are removed whenever they are finished or canceled.
|
| + void EraseJob(ServiceWorkerRegisterJob* job);
|
| +
|
| + // Called at ServiceWorkerRegisterJob completion.
|
| + void RegisterComplete(const RegistrationCallback& callback,
|
| + ServiceWorkerRegisterJob* job,
|
| + ServiceWorkerRegistrationStatus status,
|
| + ServiceWorkerRegistration* registration);
|
| +
|
| + // Called at ServiceWorkerRegisterJob completion.
|
| + void UnregisterComplete(const UnregistrationCallback& callback,
|
| + ServiceWorkerRegisterJob* job,
|
| + ServiceWorkerRegistrationStatus status,
|
| + ServiceWorkerRegistration* registration);
|
| +
|
| + const base::WeakPtr<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_;
|
| +};
|
| +
|
| +} // namespace content
|
| +
|
| +#endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_JOB_COORDINATOR_H_
|
|
|