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 <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
(...skipping 16 matching lines...) Expand all Loading... |
27 // - creating a ServiceWorkerVersion for the new registration instance. | 27 // - creating a ServiceWorkerVersion for the new registration instance. |
28 // - starting a worker for the ServiceWorkerVersion | 28 // - starting a worker for the ServiceWorkerVersion |
29 // - telling the Version to evaluate the script | 29 // - telling the Version to evaluate the script |
30 // - firing the 'install' event at the ServiceWorkerVersion | 30 // - firing the 'install' event at the ServiceWorkerVersion |
31 // - firing the 'activate' event at the ServiceWorkerVersion | 31 // - firing the 'activate' event at the ServiceWorkerVersion |
32 // - waiting for older ServiceWorkerVersions to deactivate | 32 // - waiting for older ServiceWorkerVersions to deactivate |
33 // - designating the new version to be the 'active' version | 33 // - designating the new version to be the 'active' version |
34 class ServiceWorkerRegisterJob : public ServiceWorkerRegisterJobBase { | 34 class ServiceWorkerRegisterJob : public ServiceWorkerRegisterJobBase { |
35 public: | 35 public: |
36 typedef base::Callback<void(ServiceWorkerStatusCode status, | 36 typedef base::Callback<void(ServiceWorkerStatusCode status, |
| 37 ServiceWorkerRegistration* registration, |
37 ServiceWorkerVersion* version)> | 38 ServiceWorkerVersion* version)> |
38 RegistrationCallback; | 39 RegistrationCallback; |
39 | 40 |
40 ServiceWorkerRegisterJob(base::WeakPtr<ServiceWorkerContextCore> context, | 41 ServiceWorkerRegisterJob(base::WeakPtr<ServiceWorkerContextCore> context, |
41 const GURL& pattern, | 42 const GURL& pattern, |
42 const GURL& script_url); | 43 const GURL& script_url); |
43 virtual ~ServiceWorkerRegisterJob(); | 44 virtual ~ServiceWorkerRegisterJob(); |
44 | 45 |
45 // Registers a callback to be called when the job completes (whether | 46 // Registers a callback to be called when the job completes (whether |
46 // successfully or not). Multiple callbacks may be registered. |process_id| is | 47 // successfully or not). Multiple callbacks may be registered. |process_id| is |
(...skipping 12 matching lines...) Expand all Loading... |
59 const scoped_refptr<ServiceWorkerRegistration>& registration); | 60 const scoped_refptr<ServiceWorkerRegistration>& registration); |
60 void RegisterAndContinue(ServiceWorkerStatusCode status); | 61 void RegisterAndContinue(ServiceWorkerStatusCode status); |
61 void UpdateAndContinue(ServiceWorkerStatusCode status); | 62 void UpdateAndContinue(ServiceWorkerStatusCode status); |
62 void OnStartWorkerFinished(ServiceWorkerStatusCode status); | 63 void OnStartWorkerFinished(ServiceWorkerStatusCode status); |
63 void InstallAndContinue(); | 64 void InstallAndContinue(); |
64 void OnInstallFinished(ServiceWorkerStatusCode status); | 65 void OnInstallFinished(ServiceWorkerStatusCode status); |
65 void ActivateAndContinue(); | 66 void ActivateAndContinue(); |
66 void Complete(ServiceWorkerStatusCode status); | 67 void Complete(ServiceWorkerStatusCode status); |
67 | 68 |
68 void RunCallbacks(ServiceWorkerStatusCode status, | 69 void RunCallbacks(ServiceWorkerStatusCode status, |
| 70 ServiceWorkerRegistration* registration, |
69 ServiceWorkerVersion* version); | 71 ServiceWorkerVersion* version); |
70 | 72 |
71 // The ServiceWorkerStorage object should always outlive this. | 73 // The ServiceWorkerStorage object should always outlive this. |
72 base::WeakPtr<ServiceWorkerContextCore> context_; | 74 base::WeakPtr<ServiceWorkerContextCore> context_; |
73 scoped_refptr<ServiceWorkerRegistration> registration_; | 75 scoped_refptr<ServiceWorkerRegistration> registration_; |
74 scoped_refptr<ServiceWorkerVersion> pending_version_; | 76 scoped_refptr<ServiceWorkerVersion> pending_version_; |
75 const GURL pattern_; | 77 const GURL pattern_; |
76 const GURL script_url_; | 78 const GURL script_url_; |
77 std::vector<RegistrationCallback> callbacks_; | 79 std::vector<RegistrationCallback> callbacks_; |
78 std::vector<int> pending_process_ids_; | 80 std::vector<int> pending_process_ids_; |
79 base::WeakPtrFactory<ServiceWorkerRegisterJob> weak_factory_; | 81 base::WeakPtrFactory<ServiceWorkerRegisterJob> weak_factory_; |
80 | 82 |
81 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerRegisterJob); | 83 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerRegisterJob); |
82 }; | 84 }; |
83 | 85 |
84 } // namespace content | 86 } // namespace content |
85 | 87 |
86 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_REGISTER_JOB_H_ | 88 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_REGISTER_JOB_H_ |
OLD | NEW |