| 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 | 46 |
| 47 // Registers a callback to be called when the promise would resolve (whether | 47 // Registers a callback to be called when the promise would resolve (whether |
| 48 // successfully or not). Multiple callbacks may be registered. If |process_id| | 48 // successfully or not). Multiple callbacks may be registered. If |process_id| |
| 49 // is not -1, it's added to the existing clients when deciding in which | 49 // is not -1, it's added to the existing clients when deciding in which |
| 50 // process to create the Service Worker instance. If there are no existing | 50 // process to create the Service Worker instance. If there are no existing |
| 51 // clients, a new RenderProcessHost will be created. | 51 // clients, a new RenderProcessHost will be created. |
| 52 void AddCallback(const RegistrationCallback& callback, int process_id); | 52 void AddCallback(const RegistrationCallback& callback, int process_id); |
| 53 | 53 |
| 54 // ServiceWorkerRegisterJobBase implementation: | 54 // ServiceWorkerRegisterJobBase implementation: |
| 55 virtual void Start() OVERRIDE; | 55 virtual void Start() OVERRIDE; |
| 56 virtual void Abort() OVERRIDE; |
| 56 virtual bool Equals(ServiceWorkerRegisterJobBase* job) OVERRIDE; | 57 virtual bool Equals(ServiceWorkerRegisterJobBase* job) OVERRIDE; |
| 57 virtual RegistrationJobType GetType() OVERRIDE; | 58 virtual RegistrationJobType GetType() OVERRIDE; |
| 58 | 59 |
| 59 private: | 60 private: |
| 60 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerProviderHostWaitingVersionTest, | 61 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerProviderHostWaitingVersionTest, |
| 61 AssociateWaitingVersionToDocuments); | 62 AssociateWaitingVersionToDocuments); |
| 62 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerProviderHostWaitingVersionTest, | 63 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerProviderHostWaitingVersionTest, |
| 63 DisassociateWaitingVersionFromDocuments); | 64 DisassociateWaitingVersionFromDocuments); |
| 64 | 65 |
| 65 enum Phase { | 66 enum Phase { |
| 66 INITIAL, | 67 INITIAL, |
| 67 START, | 68 START, |
| 68 REGISTER, | 69 REGISTER, |
| 69 UPDATE, | 70 UPDATE, |
| 70 INSTALL, | 71 INSTALL, |
| 71 STORE, | 72 STORE, |
| 72 ACTIVATE, | 73 ACTIVATE, |
| 73 COMPLETE | 74 COMPLETE, |
| 75 ABORT, |
| 74 }; | 76 }; |
| 75 | 77 |
| 76 // Holds internal state of ServiceWorkerRegistrationJob, to compel use of the | 78 // Holds internal state of ServiceWorkerRegistrationJob, to compel use of the |
| 77 // getter/setter functions. | 79 // getter/setter functions. |
| 78 struct Internal { | 80 struct Internal { |
| 79 Internal(); | 81 Internal(); |
| 80 ~Internal(); | 82 ~Internal(); |
| 81 scoped_refptr<ServiceWorkerRegistration> registration; | 83 scoped_refptr<ServiceWorkerRegistration> registration; |
| 82 | 84 |
| 83 // Holds 'installing' or 'waiting' version depending on the phase. | 85 // Holds 'installing' or 'waiting' version depending on the phase. |
| (...skipping 12 matching lines...) Expand all Loading... |
| 96 const scoped_refptr<ServiceWorkerRegistration>& registration); | 98 const scoped_refptr<ServiceWorkerRegistration>& registration); |
| 97 void RegisterAndContinue(ServiceWorkerStatusCode status); | 99 void RegisterAndContinue(ServiceWorkerStatusCode status); |
| 98 void UpdateAndContinue(ServiceWorkerStatusCode status); | 100 void UpdateAndContinue(ServiceWorkerStatusCode status); |
| 99 void OnStartWorkerFinished(ServiceWorkerStatusCode status); | 101 void OnStartWorkerFinished(ServiceWorkerStatusCode status); |
| 100 void OnStoreRegistrationComplete(ServiceWorkerStatusCode status); | 102 void OnStoreRegistrationComplete(ServiceWorkerStatusCode status); |
| 101 void InstallAndContinue(); | 103 void InstallAndContinue(); |
| 102 void OnInstallFinished(ServiceWorkerStatusCode status); | 104 void OnInstallFinished(ServiceWorkerStatusCode status); |
| 103 void ActivateAndContinue(); | 105 void ActivateAndContinue(); |
| 104 void OnActivateFinished(ServiceWorkerStatusCode status); | 106 void OnActivateFinished(ServiceWorkerStatusCode status); |
| 105 void Complete(ServiceWorkerStatusCode status); | 107 void Complete(ServiceWorkerStatusCode status); |
| 108 void CompleteInternal(ServiceWorkerStatusCode status); |
| 106 | 109 |
| 107 void ResolvePromise(ServiceWorkerStatusCode status, | 110 void ResolvePromise(ServiceWorkerStatusCode status, |
| 108 ServiceWorkerRegistration* registration, | 111 ServiceWorkerRegistration* registration, |
| 109 ServiceWorkerVersion* version); | 112 ServiceWorkerVersion* version); |
| 110 | 113 |
| 111 // Associates a waiting version to documents matched with a scope of the | 114 // Associates a waiting version to documents matched with a scope of the |
| 112 // version. | 115 // version. |
| 113 CONTENT_EXPORT static void AssociateWaitingVersionToDocuments( | 116 CONTENT_EXPORT static void AssociateWaitingVersionToDocuments( |
| 114 base::WeakPtr<ServiceWorkerContextCore> context, | 117 base::WeakPtr<ServiceWorkerContextCore> context, |
| 115 ServiceWorkerVersion* version); | 118 ServiceWorkerVersion* version); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 133 scoped_refptr<ServiceWorkerRegistration> promise_resolved_registration_; | 136 scoped_refptr<ServiceWorkerRegistration> promise_resolved_registration_; |
| 134 scoped_refptr<ServiceWorkerVersion> promise_resolved_version_; | 137 scoped_refptr<ServiceWorkerVersion> promise_resolved_version_; |
| 135 base::WeakPtrFactory<ServiceWorkerRegisterJob> weak_factory_; | 138 base::WeakPtrFactory<ServiceWorkerRegisterJob> weak_factory_; |
| 136 | 139 |
| 137 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerRegisterJob); | 140 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerRegisterJob); |
| 138 }; | 141 }; |
| 139 | 142 |
| 140 } // namespace content | 143 } // namespace content |
| 141 | 144 |
| 142 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_REGISTER_JOB_H_ | 145 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_REGISTER_JOB_H_ |
| OLD | NEW |