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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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 bool Equals(ServiceWorkerRegisterJobBase* job) OVERRIDE; | 56 virtual bool Equals(ServiceWorkerRegisterJobBase* job) OVERRIDE; |
57 virtual RegistrationJobType GetType() OVERRIDE; | 57 virtual RegistrationJobType GetType() OVERRIDE; |
58 | 58 |
59 private: | 59 private: |
60 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerRegisterJobAndProviderHostTest, | 60 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerRegisterJobAndProviderHostTest, |
61 AssociatePendingVersionToDocuments); | 61 AssociateWaitingVersionToDocuments); |
62 | 62 |
63 enum Phase { | 63 enum Phase { |
64 INITIAL, | 64 INITIAL, |
65 START, | 65 START, |
66 REGISTER, | 66 REGISTER, |
67 UPDATE, | 67 UPDATE, |
68 INSTALL, | 68 INSTALL, |
69 STORE, | 69 STORE, |
70 ACTIVATE, | 70 ACTIVATE, |
71 COMPLETE | 71 COMPLETE |
72 }; | 72 }; |
73 | 73 |
74 // Holds internal state of ServiceWorkerRegistrationJob, to compel use of the | 74 // Holds internal state of ServiceWorkerRegistrationJob, to compel use of the |
75 // getter/setter functions. | 75 // getter/setter functions. |
76 struct Internal { | 76 struct Internal { |
77 Internal(); | 77 Internal(); |
78 ~Internal(); | 78 ~Internal(); |
79 scoped_refptr<ServiceWorkerRegistration> registration; | 79 scoped_refptr<ServiceWorkerRegistration> registration; |
80 scoped_refptr<ServiceWorkerVersion> pending_version; | 80 scoped_refptr<ServiceWorkerVersion> waiting_version; |
falken
2014/05/29 07:23:34
pending_version here doesn't necessarily correspon
michaeln1
2014/05/29 21:16:52
+1 keeping this as "pending" (or something else th
nhiroki
2014/05/30 00:38:20
Reverted this to 'pending' and added comment.
| |
81 }; | 81 }; |
82 | 82 |
83 void set_registration(ServiceWorkerRegistration* registration); | 83 void set_registration(ServiceWorkerRegistration* registration); |
84 ServiceWorkerRegistration* registration(); | 84 ServiceWorkerRegistration* registration(); |
85 void set_pending_version(ServiceWorkerVersion* version); | 85 void set_waiting_version(ServiceWorkerVersion* version); |
86 ServiceWorkerVersion* pending_version(); | 86 ServiceWorkerVersion* waiting_version(); |
87 | 87 |
88 void SetPhase(Phase phase); | 88 void SetPhase(Phase phase); |
89 | 89 |
90 void HandleExistingRegistrationAndContinue( | 90 void HandleExistingRegistrationAndContinue( |
91 ServiceWorkerStatusCode status, | 91 ServiceWorkerStatusCode status, |
92 const scoped_refptr<ServiceWorkerRegistration>& registration); | 92 const scoped_refptr<ServiceWorkerRegistration>& registration); |
93 void RegisterAndContinue(ServiceWorkerStatusCode status); | 93 void RegisterAndContinue(ServiceWorkerStatusCode status); |
94 void UpdateAndContinue(ServiceWorkerStatusCode status); | 94 void UpdateAndContinue(ServiceWorkerStatusCode status); |
95 void OnStartWorkerFinished(ServiceWorkerStatusCode status); | 95 void OnStartWorkerFinished(ServiceWorkerStatusCode status); |
96 void OnStoreRegistrationComplete(ServiceWorkerStatusCode status); | 96 void OnStoreRegistrationComplete(ServiceWorkerStatusCode status); |
97 void InstallAndContinue(); | 97 void InstallAndContinue(); |
98 void OnInstallFinished(ServiceWorkerStatusCode status); | 98 void OnInstallFinished(ServiceWorkerStatusCode status); |
99 void ActivateAndContinue(); | 99 void ActivateAndContinue(); |
100 void OnActivateFinished(ServiceWorkerStatusCode status); | 100 void OnActivateFinished(ServiceWorkerStatusCode status); |
101 void Complete(ServiceWorkerStatusCode status); | 101 void Complete(ServiceWorkerStatusCode status); |
102 | 102 |
103 void ResolvePromise(ServiceWorkerStatusCode status, | 103 void ResolvePromise(ServiceWorkerStatusCode status, |
104 ServiceWorkerRegistration* registration, | 104 ServiceWorkerRegistration* registration, |
105 ServiceWorkerVersion* version); | 105 ServiceWorkerVersion* version); |
106 | 106 |
107 CONTENT_EXPORT void AssociatePendingVersionToDocuments( | 107 CONTENT_EXPORT void AssociateWaitingVersionToDocuments( |
108 ServiceWorkerVersion* version); | 108 ServiceWorkerVersion* version); |
109 | 109 |
110 // The ServiceWorkerContextCore object should always outlive this. | 110 // The ServiceWorkerContextCore object should always outlive this. |
111 base::WeakPtr<ServiceWorkerContextCore> context_; | 111 base::WeakPtr<ServiceWorkerContextCore> context_; |
112 | 112 |
113 const GURL pattern_; | 113 const GURL pattern_; |
114 const GURL script_url_; | 114 const GURL script_url_; |
115 std::vector<RegistrationCallback> callbacks_; | 115 std::vector<RegistrationCallback> callbacks_; |
116 std::vector<int> pending_process_ids_; | 116 std::vector<int> pending_process_ids_; |
117 Phase phase_; | 117 Phase phase_; |
118 Internal internal_; | 118 Internal internal_; |
119 bool is_promise_resolved_; | 119 bool is_promise_resolved_; |
120 ServiceWorkerStatusCode promise_resolved_status_; | 120 ServiceWorkerStatusCode promise_resolved_status_; |
121 scoped_refptr<ServiceWorkerRegistration> promise_resolved_registration_; | 121 scoped_refptr<ServiceWorkerRegistration> promise_resolved_registration_; |
122 scoped_refptr<ServiceWorkerVersion> promise_resolved_version_; | 122 scoped_refptr<ServiceWorkerVersion> promise_resolved_version_; |
123 base::WeakPtrFactory<ServiceWorkerRegisterJob> weak_factory_; | 123 base::WeakPtrFactory<ServiceWorkerRegisterJob> weak_factory_; |
124 | 124 |
125 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerRegisterJob); | 125 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerRegisterJob); |
126 }; | 126 }; |
127 | 127 |
128 } // namespace content | 128 } // namespace content |
129 | 129 |
130 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_REGISTER_JOB_H_ | 130 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_REGISTER_JOB_H_ |
OLD | NEW |