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

Side by Side Diff: content/browser/service_worker/service_worker_unregister_job.h

Issue 788073007: Cleanup geofence registrations when a service worker is unregistered. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: slightly improve mock usage in test Created 5 years, 12 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 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_UNREGISTER_JOB_H_ 5 #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_UNREGISTER_JOB_H_
6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_UNREGISTER_JOB_H_ 6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_UNREGISTER_JOB_H_
7 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/memory/weak_ptr.h" 10 #include "base/memory/weak_ptr.h"
11 #include "content/browser/service_worker/service_worker_register_job_base.h" 11 #include "content/browser/service_worker/service_worker_register_job_base.h"
12 #include "content/common/service_worker/service_worker_status_code.h" 12 #include "content/common/service_worker/service_worker_status_code.h"
13 #include "url/gurl.h" 13 #include "url/gurl.h"
14 14
15 namespace content { 15 namespace content {
16 16
17 class EmbeddedWorkerRegistry; 17 class EmbeddedWorkerRegistry;
18 class ServiceWorkerContextCore; 18 class ServiceWorkerContextCore;
19 class ServiceWorkerJobCoordinator; 19 class ServiceWorkerJobCoordinator;
20 class ServiceWorkerRegistration; 20 class ServiceWorkerRegistration;
21 class ServiceWorkerStorage; 21 class ServiceWorkerStorage;
22 22
23 // Handles the unregistration of a Service Worker. 23 // Handles the unregistration of a Service Worker.
24 // 24 //
25 // The unregistration process is primarily cleanup, removing everything that was 25 // The unregistration process is primarily cleanup, removing everything that was
26 // created during the registration process, including the 26 // created during the registration process, including the
27 // ServiceWorkerRegistration itself. 27 // ServiceWorkerRegistration itself.
28 class ServiceWorkerUnregisterJob : public ServiceWorkerRegisterJobBase { 28 class ServiceWorkerUnregisterJob : public ServiceWorkerRegisterJobBase {
29 public: 29 public:
30 typedef base::Callback<void(ServiceWorkerStatusCode status)> 30 typedef base::Callback<void(int64 registration_id,
31 ServiceWorkerStatusCode status)>
31 UnregistrationCallback; 32 UnregistrationCallback;
32 33
33 ServiceWorkerUnregisterJob(base::WeakPtr<ServiceWorkerContextCore> context, 34 ServiceWorkerUnregisterJob(base::WeakPtr<ServiceWorkerContextCore> context,
34 const GURL& pattern); 35 const GURL& pattern);
35 ~ServiceWorkerUnregisterJob() override; 36 ~ServiceWorkerUnregisterJob() override;
36 37
37 // Registers a callback to be called when the job completes (whether 38 // Registers a callback to be called when the job completes (whether
38 // successfully or not). Multiple callbacks may be registered. 39 // successfully or not). Multiple callbacks may be registered.
39 void AddCallback(const UnregistrationCallback& callback); 40 void AddCallback(const UnregistrationCallback& callback);
40 41
41 // ServiceWorkerRegisterJobBase implementation: 42 // ServiceWorkerRegisterJobBase implementation:
42 void Start() override; 43 void Start() override;
43 void Abort() override; 44 void Abort() override;
44 bool Equals(ServiceWorkerRegisterJobBase* job) override; 45 bool Equals(ServiceWorkerRegisterJobBase* job) override;
45 RegistrationJobType GetType() override; 46 RegistrationJobType GetType() override;
46 47
47 private: 48 private:
48 void OnRegistrationFound( 49 void OnRegistrationFound(
49 ServiceWorkerStatusCode status, 50 ServiceWorkerStatusCode status,
50 const scoped_refptr<ServiceWorkerRegistration>& registration); 51 const scoped_refptr<ServiceWorkerRegistration>& registration);
51 void Complete(ServiceWorkerStatusCode status); 52 void Complete(int64 registration_id, ServiceWorkerStatusCode status);
52 void CompleteInternal(ServiceWorkerStatusCode status); 53 void CompleteInternal(int64 registration_id, ServiceWorkerStatusCode status);
53 void ResolvePromise(ServiceWorkerStatusCode status); 54 void ResolvePromise(int64 registration_id, ServiceWorkerStatusCode status);
54 55
55 base::WeakPtr<ServiceWorkerContextCore> context_; 56 base::WeakPtr<ServiceWorkerContextCore> context_;
56 const GURL pattern_; 57 const GURL pattern_;
57 std::vector<UnregistrationCallback> callbacks_; 58 std::vector<UnregistrationCallback> callbacks_;
58 bool is_promise_resolved_; 59 bool is_promise_resolved_;
59 base::WeakPtrFactory<ServiceWorkerUnregisterJob> weak_factory_; 60 base::WeakPtrFactory<ServiceWorkerUnregisterJob> weak_factory_;
60 61
61 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerUnregisterJob); 62 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerUnregisterJob);
62 }; 63 };
63 } // namespace content 64 } // namespace content
64 65
65 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_UNREGISTER_JOB_H_ 66 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_UNREGISTER_JOB_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698