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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 // process to create the Service Worker instance. If there are no existing | 60 // process to create the Service Worker instance. If there are no existing |
61 // clients, a new RenderProcessHost will be created. | 61 // clients, a new RenderProcessHost will be created. |
62 void AddCallback(const RegistrationCallback& callback, int process_id); | 62 void AddCallback(const RegistrationCallback& callback, int process_id); |
63 | 63 |
64 // ServiceWorkerRegisterJobBase implementation: | 64 // ServiceWorkerRegisterJobBase implementation: |
65 virtual void Start() OVERRIDE; | 65 virtual void Start() OVERRIDE; |
66 virtual void Abort() OVERRIDE; | 66 virtual void Abort() OVERRIDE; |
67 virtual bool Equals(ServiceWorkerRegisterJobBase* job) OVERRIDE; | 67 virtual bool Equals(ServiceWorkerRegisterJobBase* job) OVERRIDE; |
68 virtual RegistrationJobType GetType() OVERRIDE; | 68 virtual RegistrationJobType GetType() OVERRIDE; |
69 | 69 |
70 // TODO(michaeln): Use the registration listerer's OnVersionAttributesChanged | |
71 // method to replace these methods, have the host listen for changes | |
72 // to their registration. | |
73 CONTENT_EXPORT static void AssociateInstallingVersionToDocuments( | |
74 base::WeakPtr<ServiceWorkerContextCore> context, | |
75 ServiceWorkerVersion* version); | |
76 static void AssociateWaitingVersionToDocuments( | |
77 base::WeakPtr<ServiceWorkerContextCore> context, | |
78 ServiceWorkerVersion* version); | |
79 static void AssociateActiveVersionToDocuments( | |
80 base::WeakPtr<ServiceWorkerContextCore> context, | |
81 ServiceWorkerVersion* version); | |
82 CONTENT_EXPORT static void DisassociateVersionFromDocuments( | |
83 base::WeakPtr<ServiceWorkerContextCore> context, | |
84 ServiceWorkerVersion* version); | |
85 | |
86 private: | 70 private: |
87 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerProviderHostWaitingVersionTest, | 71 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerProviderHostWaitingVersionTest, |
88 AssociateInstallingVersionToDocuments); | 72 AssociateInstallingVersionToDocuments); |
89 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerProviderHostWaitingVersionTest, | 73 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerProviderHostWaitingVersionTest, |
90 DisassociateVersionFromDocuments); | 74 DisassociateVersionFromDocuments); |
91 | 75 |
92 enum Phase { | 76 enum Phase { |
93 INITIAL, | 77 INITIAL, |
94 START, | 78 START, |
95 REGISTER, | 79 REGISTER, |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 | 125 |
142 // EmbeddedWorkerInstance::Listener override of OnPausedAfterDownload. | 126 // EmbeddedWorkerInstance::Listener override of OnPausedAfterDownload. |
143 virtual void OnPausedAfterDownload() OVERRIDE; | 127 virtual void OnPausedAfterDownload() OVERRIDE; |
144 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | 128 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
145 | 129 |
146 void OnCompareScriptResourcesComplete( | 130 void OnCompareScriptResourcesComplete( |
147 ServiceWorkerVersion* current_version, | 131 ServiceWorkerVersion* current_version, |
148 ServiceWorkerStatusCode status, | 132 ServiceWorkerStatusCode status, |
149 bool are_equal); | 133 bool are_equal); |
150 | 134 |
| 135 void AssociateProviderHostsToRegistration( |
| 136 ServiceWorkerRegistration* registration); |
| 137 |
151 // The ServiceWorkerContextCore object should always outlive this. | 138 // The ServiceWorkerContextCore object should always outlive this. |
152 base::WeakPtr<ServiceWorkerContextCore> context_; | 139 base::WeakPtr<ServiceWorkerContextCore> context_; |
153 | 140 |
154 RegistrationJobType job_type_; | 141 RegistrationJobType job_type_; |
155 const GURL pattern_; | 142 const GURL pattern_; |
156 const GURL script_url_; | 143 const GURL script_url_; |
157 std::vector<RegistrationCallback> callbacks_; | 144 std::vector<RegistrationCallback> callbacks_; |
158 std::vector<int> pending_process_ids_; | 145 std::vector<int> pending_process_ids_; |
159 Phase phase_; | 146 Phase phase_; |
160 Internal internal_; | 147 Internal internal_; |
161 bool is_promise_resolved_; | 148 bool is_promise_resolved_; |
162 ServiceWorkerStatusCode promise_resolved_status_; | 149 ServiceWorkerStatusCode promise_resolved_status_; |
163 scoped_refptr<ServiceWorkerRegistration> promise_resolved_registration_; | 150 scoped_refptr<ServiceWorkerRegistration> promise_resolved_registration_; |
164 scoped_refptr<ServiceWorkerVersion> promise_resolved_version_; | 151 scoped_refptr<ServiceWorkerVersion> promise_resolved_version_; |
165 base::WeakPtrFactory<ServiceWorkerRegisterJob> weak_factory_; | 152 base::WeakPtrFactory<ServiceWorkerRegisterJob> weak_factory_; |
166 | 153 |
167 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerRegisterJob); | 154 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerRegisterJob); |
168 }; | 155 }; |
169 | 156 |
170 } // namespace content | 157 } // namespace content |
171 | 158 |
172 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_REGISTER_JOB_H_ | 159 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_REGISTER_JOB_H_ |
OLD | NEW |