Implement SSLKEYLOGFILE for OpenSSL.
[chromium-blink-merge.git] / content / browser / service_worker / service_worker_unregister_job.h
blob5e627ae1a4e3a986fcf3ae1607100523e8dacf80
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_UNREGISTER_JOB_H_
6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_UNREGISTER_JOB_H_
8 #include <vector>
10 #include "base/memory/weak_ptr.h"
11 #include "content/browser/service_worker/service_worker_register_job_base.h"
12 #include "content/common/service_worker/service_worker_status_code.h"
13 #include "url/gurl.h"
15 namespace content {
17 class EmbeddedWorkerRegistry;
18 class ServiceWorkerContextCore;
19 class ServiceWorkerJobCoordinator;
20 class ServiceWorkerRegistration;
21 class ServiceWorkerStorage;
23 // Handles the unregistration of a Service Worker.
25 // The unregistration process is primarily cleanup, removing everything that was
26 // created during the registration process, including the
27 // ServiceWorkerRegistration itself.
28 class ServiceWorkerUnregisterJob : public ServiceWorkerRegisterJobBase {
29 public:
30 typedef base::Callback<void(ServiceWorkerStatusCode status)>
31 UnregistrationCallback;
33 ServiceWorkerUnregisterJob(base::WeakPtr<ServiceWorkerContextCore> context,
34 const GURL& pattern);
35 virtual ~ServiceWorkerUnregisterJob();
37 // Registers a callback to be called when the job completes (whether
38 // successfully or not). Multiple callbacks may be registered.
39 void AddCallback(const UnregistrationCallback& callback);
41 // ServiceWorkerRegisterJobBase implementation:
42 virtual void Start() OVERRIDE;
43 virtual void Abort() OVERRIDE;
44 virtual bool Equals(ServiceWorkerRegisterJobBase* job) OVERRIDE;
45 virtual RegistrationJobType GetType() OVERRIDE;
47 private:
48 void OnRegistrationFound(
49 ServiceWorkerStatusCode status,
50 const scoped_refptr<ServiceWorkerRegistration>& registration);
51 void Complete(ServiceWorkerStatusCode status);
52 void CompleteInternal(ServiceWorkerStatusCode status);
53 void ResolvePromise(ServiceWorkerStatusCode status);
55 base::WeakPtr<ServiceWorkerContextCore> context_;
56 const GURL pattern_;
57 std::vector<UnregistrationCallback> callbacks_;
58 bool is_promise_resolved_;
59 base::WeakPtrFactory<ServiceWorkerUnregisterJob> weak_factory_;
61 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerUnregisterJob);
63 } // namespace content
65 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_UNREGISTER_JOB_H_