| 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 <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
| 13 #include "base/time/time.h" | 13 #include "base/time/time.h" |
| 14 #include "content/browser/service_worker/embedded_worker_instance.h" | 14 #include "content/browser/service_worker/embedded_worker_instance.h" |
| 15 #include "content/browser/service_worker/service_worker_register_job_base.h" | 15 #include "content/browser/service_worker/service_worker_register_job_base.h" |
| 16 #include "content/browser/service_worker/service_worker_registration.h" | 16 #include "content/browser/service_worker/service_worker_registration.h" |
| 17 #include "content/common/service_worker/service_worker_status_code.h" | 17 #include "content/common/service_worker/service_worker_status_code.h" |
| 18 #include "url/gurl.h" | 18 #include "url/gurl.h" |
| 19 | 19 |
| 20 namespace content { | 20 namespace content { |
| 21 | 21 |
| 22 namespace { |
| 23 class InstallEventMethodsReceiver; |
| 24 } // namespace |
| 25 |
| 22 // Handles the initial registration of a Service Worker and the | 26 // Handles the initial registration of a Service Worker and the |
| 23 // subsequent update of existing registrations. | 27 // subsequent update of existing registrations. |
| 24 // | 28 // |
| 25 // The control flow includes most or all of the following, | 29 // The control flow includes most or all of the following, |
| 26 // depending on what is already registered: | 30 // depending on what is already registered: |
| 27 // - creating a ServiceWorkerRegistration instance if there isn't | 31 // - creating a ServiceWorkerRegistration instance if there isn't |
| 28 // already something registered | 32 // already something registered |
| 29 // - creating a ServiceWorkerVersion for the new version. | 33 // - creating a ServiceWorkerVersion for the new version. |
| 30 // - starting a worker for the ServiceWorkerVersion | 34 // - starting a worker for the ServiceWorkerVersion |
| 31 // - firing the 'install' event at the ServiceWorkerVersion | 35 // - firing the 'install' event at the ServiceWorkerVersion |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 scoped_refptr<ServiceWorkerRegistration> existing_registration, | 117 scoped_refptr<ServiceWorkerRegistration> existing_registration, |
| 114 ServiceWorkerStatusCode status); | 118 ServiceWorkerStatusCode status); |
| 115 void ContinueWithRegistrationForSameScriptUrl( | 119 void ContinueWithRegistrationForSameScriptUrl( |
| 116 scoped_refptr<ServiceWorkerRegistration> existing_registration, | 120 scoped_refptr<ServiceWorkerRegistration> existing_registration, |
| 117 ServiceWorkerStatusCode status); | 121 ServiceWorkerStatusCode status); |
| 118 void UpdateAndContinue(); | 122 void UpdateAndContinue(); |
| 119 void OnStartWorkerFinished(ServiceWorkerStatusCode status); | 123 void OnStartWorkerFinished(ServiceWorkerStatusCode status); |
| 120 void OnStoreRegistrationComplete(ServiceWorkerStatusCode status); | 124 void OnStoreRegistrationComplete(ServiceWorkerStatusCode status); |
| 121 void InstallAndContinue(); | 125 void InstallAndContinue(); |
| 122 void DispatchInstallEvent(); | 126 void DispatchInstallEvent(); |
| 123 void OnInstallFinished(int request_id, | 127 void OnInstallFinished( |
| 124 blink::WebServiceWorkerEventResult result, | 128 int request_id, |
| 125 bool has_fetch_handler, | 129 std::unique_ptr<InstallEventMethodsReceiver> install_event_methods, |
| 126 base::Time dispatch_event_time); | 130 ServiceWorkerStatusCode status, |
| 131 bool has_fetch_handler, |
| 132 base::Time dispatch_event_time); |
| 127 void OnInstallFailed(ServiceWorkerStatusCode status); | 133 void OnInstallFailed(ServiceWorkerStatusCode status); |
| 128 void Complete(ServiceWorkerStatusCode status); | 134 void Complete(ServiceWorkerStatusCode status); |
| 129 void Complete(ServiceWorkerStatusCode status, | 135 void Complete(ServiceWorkerStatusCode status, |
| 130 const std::string& status_message); | 136 const std::string& status_message); |
| 131 void CompleteInternal(ServiceWorkerStatusCode status, | 137 void CompleteInternal(ServiceWorkerStatusCode status, |
| 132 const std::string& status_message); | 138 const std::string& status_message); |
| 133 void ResolvePromise(ServiceWorkerStatusCode status, | 139 void ResolvePromise(ServiceWorkerStatusCode status, |
| 134 const std::string& status_message, | 140 const std::string& status_message, |
| 135 ServiceWorkerRegistration* registration); | 141 ServiceWorkerRegistration* registration); |
| 136 | 142 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 160 std::string promise_resolved_status_message_; | 166 std::string promise_resolved_status_message_; |
| 161 scoped_refptr<ServiceWorkerRegistration> promise_resolved_registration_; | 167 scoped_refptr<ServiceWorkerRegistration> promise_resolved_registration_; |
| 162 base::WeakPtrFactory<ServiceWorkerRegisterJob> weak_factory_; | 168 base::WeakPtrFactory<ServiceWorkerRegisterJob> weak_factory_; |
| 163 | 169 |
| 164 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerRegisterJob); | 170 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerRegisterJob); |
| 165 }; | 171 }; |
| 166 | 172 |
| 167 } // namespace content | 173 } // namespace content |
| 168 | 174 |
| 169 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_REGISTER_JOB_H_ | 175 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_REGISTER_JOB_H_ |
| OLD | NEW |