| 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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 // added via AddProcessToWorker to the ServiceWorkerVersion created by the | 47 // added via AddProcessToWorker to the ServiceWorkerVersion created by the |
| 48 // registration job. | 48 // registration job. |
| 49 void AddCallback(const RegistrationCallback& callback, int process_id); | 49 void AddCallback(const RegistrationCallback& callback, int process_id); |
| 50 | 50 |
| 51 // ServiceWorkerRegisterJobBase implementation: | 51 // ServiceWorkerRegisterJobBase implementation: |
| 52 virtual void Start() OVERRIDE; | 52 virtual void Start() OVERRIDE; |
| 53 virtual bool Equals(ServiceWorkerRegisterJobBase* job) OVERRIDE; | 53 virtual bool Equals(ServiceWorkerRegisterJobBase* job) OVERRIDE; |
| 54 virtual RegistrationJobType GetType() OVERRIDE; | 54 virtual RegistrationJobType GetType() OVERRIDE; |
| 55 | 55 |
| 56 private: | 56 private: |
| 57 enum Phase { |
| 58 INITIAL, |
| 59 START, |
| 60 REGISTER, |
| 61 UPDATE, |
| 62 INSTALL, |
| 63 ACTIVATE, |
| 64 COMPLETE |
| 65 }; |
| 66 |
| 67 struct ServiceWorkerRegisterJobInternal { |
| 68 ServiceWorkerRegisterJobInternal() |
| 69 : registration_(NULL), pending_version_(NULL) {} |
| 70 |
| 71 scoped_refptr<ServiceWorkerRegistration> registration_; |
| 72 scoped_refptr<ServiceWorkerVersion> pending_version_; |
| 73 }; |
| 74 |
| 75 void set_registration(ServiceWorkerRegistration* registration); |
| 76 ServiceWorkerRegistration* registration(); |
| 77 void set_pending_version(ServiceWorkerVersion* version); |
| 78 ServiceWorkerVersion* pending_version(); |
| 79 |
| 57 void HandleExistingRegistrationAndContinue( | 80 void HandleExistingRegistrationAndContinue( |
| 58 ServiceWorkerStatusCode status, | 81 ServiceWorkerStatusCode status, |
| 59 const scoped_refptr<ServiceWorkerRegistration>& registration); | 82 const scoped_refptr<ServiceWorkerRegistration>& registration); |
| 60 void RegisterAndContinue(ServiceWorkerStatusCode status); | 83 void RegisterAndContinue(ServiceWorkerStatusCode status); |
| 61 void UpdateAndContinue(ServiceWorkerStatusCode status); | 84 void UpdateAndContinue(ServiceWorkerStatusCode status); |
| 62 void OnStartWorkerFinished(ServiceWorkerStatusCode status); | 85 void OnStartWorkerFinished(ServiceWorkerStatusCode status); |
| 63 void InstallAndContinue(); | 86 void InstallAndContinue(); |
| 64 void OnInstallFinished(ServiceWorkerStatusCode status); | 87 void OnInstallFinished(ServiceWorkerStatusCode status); |
| 65 void ActivateAndContinue(); | 88 void ActivateAndContinue(); |
| 66 void Complete(ServiceWorkerStatusCode status); | 89 void Complete(ServiceWorkerStatusCode status); |
| 67 | 90 |
| 68 void RunCallbacks(ServiceWorkerStatusCode status, | 91 void RunCallbacks(ServiceWorkerStatusCode status, |
| 69 ServiceWorkerVersion* version); | 92 ServiceWorkerVersion* version); |
| 70 | 93 |
| 71 // The ServiceWorkerStorage object should always outlive this. | 94 // The ServiceWorkerContextCore object should always outlive this. |
| 72 base::WeakPtr<ServiceWorkerContextCore> context_; | 95 base::WeakPtr<ServiceWorkerContextCore> context_; |
| 73 scoped_refptr<ServiceWorkerRegistration> registration_; | 96 |
| 74 scoped_refptr<ServiceWorkerVersion> pending_version_; | |
| 75 const GURL pattern_; | 97 const GURL pattern_; |
| 76 const GURL script_url_; | 98 const GURL script_url_; |
| 77 std::vector<RegistrationCallback> callbacks_; | 99 std::vector<RegistrationCallback> callbacks_; |
| 78 std::vector<int> pending_process_ids_; | 100 std::vector<int> pending_process_ids_; |
| 101 Phase phase_; |
| 102 ServiceWorkerRegisterJobInternal internal_; |
| 79 base::WeakPtrFactory<ServiceWorkerRegisterJob> weak_factory_; | 103 base::WeakPtrFactory<ServiceWorkerRegisterJob> weak_factory_; |
| 80 | 104 |
| 81 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerRegisterJob); | 105 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerRegisterJob); |
| 82 }; | 106 }; |
| 83 | 107 |
| 84 } // namespace content | 108 } // namespace content |
| 85 | 109 |
| 86 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_REGISTER_JOB_H_ | 110 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_REGISTER_JOB_H_ |
| OLD | NEW |