Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(251)

Side by Side Diff: content/browser/service_worker/service_worker_provider_host.h

Issue 855383006: ServiceWorker: Enqueue state change events until the worker thread gets ready (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix content_unittests Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_PROVIDER_HOST_H_ 5 #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_PROVIDER_HOST_H_
6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_PROVIDER_HOST_H_ 6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_PROVIDER_HOST_H_
7 7
8 #include <set> 8 #include <set>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 27 matching lines...) Expand all
38 // object is tied to the lifetime of its document in the renderer process. 38 // object is tied to the lifetime of its document in the renderer process.
39 // This class holds service worker state that is scoped to an individual 39 // This class holds service worker state that is scoped to an individual
40 // document. 40 // document.
41 // 41 //
42 // Note this class can also host a running service worker, in which 42 // Note this class can also host a running service worker, in which
43 // case it will observe resource loads made directly by the service worker. 43 // case it will observe resource loads made directly by the service worker.
44 class CONTENT_EXPORT ServiceWorkerProviderHost 44 class CONTENT_EXPORT ServiceWorkerProviderHost
45 : public NON_EXPORTED_BASE(ServiceWorkerRegistration::Listener), 45 : public NON_EXPORTED_BASE(ServiceWorkerRegistration::Listener),
46 public base::SupportsWeakPtr<ServiceWorkerProviderHost> { 46 public base::SupportsWeakPtr<ServiceWorkerProviderHost> {
47 public: 47 public:
48 typedef ServiceWorkerProviderHost self;
falken 2015/01/28 13:42:09 comment: This pattern doesn't look idiomatic in Ch
nhiroki 2015/01/28 14:08:30 To wrap the line at 80 columns, I just copied it f
48 typedef base::Callback<void(bool)> FocusCallback; 49 typedef base::Callback<void(bool)> FocusCallback;
49 50
50 ServiceWorkerProviderHost(int render_process_id, 51 ServiceWorkerProviderHost(int render_process_id,
51 int render_frame_id, 52 int render_frame_id,
52 int provider_id, 53 int provider_id,
53 base::WeakPtr<ServiceWorkerContextCore> context, 54 base::WeakPtr<ServiceWorkerContextCore> context,
54 ServiceWorkerDispatcherHost* dispatcher_host); 55 ServiceWorkerDispatcherHost* dispatcher_host);
55 virtual ~ServiceWorkerProviderHost(); 56 virtual ~ServiceWorkerProviderHost();
56 57
57 int process_id() const { return render_process_id_; } 58 int process_id() const { return render_process_id_; }
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 void PrepareForCrossSiteTransfer(); 155 void PrepareForCrossSiteTransfer();
155 void CompleteCrossSiteTransfer( 156 void CompleteCrossSiteTransfer(
156 int new_process_id, 157 int new_process_id,
157 int new_frame_id, 158 int new_frame_id,
158 int new_provider_id, 159 int new_provider_id,
159 ServiceWorkerDispatcherHost* dispatcher_host); 160 ServiceWorkerDispatcherHost* dispatcher_host);
160 ServiceWorkerDispatcherHost* dispatcher_host() const { 161 ServiceWorkerDispatcherHost* dispatcher_host() const {
161 return dispatcher_host_; 162 return dispatcher_host_;
162 } 163 }
163 164
164 // Called from ServiceWorkerRegistrationHandle. 165 // Called from ServiceWorkerRegistrationHandle.
kinuko 2015/01/28 07:13:11 Can we put a bit more descriptive comments for the
nhiroki 2015/01/28 13:43:22 Done.
165 void SendUpdateFoundMessage( 166 void SendUpdateFoundMessage(
166 const ServiceWorkerRegistrationObjectInfo& object_info); 167 const ServiceWorkerRegistrationObjectInfo& object_info);
167 void SendSetVersionAttributesMessage( 168 void SendSetVersionAttributesMessage(
168 int registration_handle_id, 169 int registration_handle_id,
169 ChangedVersionAttributesMask changed_mask, 170 ChangedVersionAttributesMask changed_mask,
170 ServiceWorkerVersion* installing_version, 171 ServiceWorkerVersion* installing_version,
171 ServiceWorkerVersion* waiting_version, 172 ServiceWorkerVersion* waiting_version,
172 ServiceWorkerVersion* active_version); 173 ServiceWorkerVersion* active_version);
173 174
174 // Called from ServiceWorkerHandle. 175 // Called from ServiceWorkerHandle.
175 void SendServiceWorkerStateChangedMessage( 176 void SendServiceWorkerStateChangedMessage(
176 int worker_handle_id, 177 int worker_handle_id,
177 blink::WebServiceWorkerState state); 178 blink::WebServiceWorkerState state);
178 179
180 // Sets the thread id and flushes queued events.
181 void SetReadyToSend(int render_thread_id);
kinuko 2015/01/28 07:13:11 SetReadyToSendMessagesToRenderer ? (or ToWorker, m
falken 2015/01/28 13:42:09 +1, it'd be nice to have a more descriptive name a
nhiroki 2015/01/28 13:43:22 Done.
nhiroki 2015/01/28 14:08:30 Updated.
182
179 private: 183 private:
180 friend class ServiceWorkerProviderHostTest; 184 friend class ServiceWorkerProviderHostTest;
181 friend class ServiceWorkerWriteToCacheJobTest; 185 friend class ServiceWorkerWriteToCacheJobTest;
182 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerContextRequestHandlerTest, 186 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerContextRequestHandlerTest,
183 UpdateBefore24Hours); 187 UpdateBefore24Hours);
184 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerContextRequestHandlerTest, 188 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerContextRequestHandlerTest,
185 UpdateAfter24Hours); 189 UpdateAfter24Hours);
186 190
187 // ServiceWorkerRegistration::Listener overrides. 191 // ServiceWorkerRegistration::Listener overrides.
188 void OnRegistrationFailed(ServiceWorkerRegistration* registration) override; 192 void OnRegistrationFailed(ServiceWorkerRegistration* registration) override;
189 void OnSkippedWaiting(ServiceWorkerRegistration* registration) override; 193 void OnSkippedWaiting(ServiceWorkerRegistration* registration) override;
190 194
191 // Sets the controller version field to |version| or if |version| is NULL, 195 // Sets the controller version field to |version| or if |version| is NULL,
192 // clears the field. 196 // clears the field.
193 void SetControllerVersionAttribute(ServiceWorkerVersion* version); 197 void SetControllerVersionAttribute(ServiceWorkerVersion* version);
194 198
195 void SendAssociateRegistrationMessage(); 199 void SendAssociateRegistrationMessage();
196 200
197 // Increase/decrease this host's process reference for |pattern|. 201 // Increase/decrease this host's process reference for |pattern|.
198 void IncreaseProcessReference(const GURL& pattern); 202 void IncreaseProcessReference(const GURL& pattern);
199 void DecreaseProcessReference(const GURL& pattern); 203 void DecreaseProcessReference(const GURL& pattern);
200 204
205 bool IsReadyToSend() const;
206 void Send(IPC::Message* message) const;
207
201 int render_process_id_; 208 int render_process_id_;
202 int render_frame_id_; 209 int render_frame_id_;
210 int render_thread_id_;
203 int provider_id_; 211 int provider_id_;
204 GURL document_url_; 212 GURL document_url_;
205 GURL topmost_frame_url_; 213 GURL topmost_frame_url_;
206 214
207 std::vector<GURL> associated_patterns_; 215 std::vector<GURL> associated_patterns_;
208 scoped_refptr<ServiceWorkerRegistration> associated_registration_; 216 scoped_refptr<ServiceWorkerRegistration> associated_registration_;
209 217
210 scoped_refptr<ServiceWorkerVersion> controlling_version_; 218 scoped_refptr<ServiceWorkerVersion> controlling_version_;
211 scoped_refptr<ServiceWorkerVersion> running_hosted_version_; 219 scoped_refptr<ServiceWorkerVersion> running_hosted_version_;
212 base::WeakPtr<ServiceWorkerContextCore> context_; 220 base::WeakPtr<ServiceWorkerContextCore> context_;
213 ServiceWorkerDispatcherHost* dispatcher_host_; 221 ServiceWorkerDispatcherHost* dispatcher_host_;
214 bool allow_association_; 222 bool allow_association_;
215 223
224 std::vector<base::Closure> queued_events_;
225
216 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerProviderHost); 226 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerProviderHost);
217 }; 227 };
218 228
219 } // namespace content 229 } // namespace content
220 230
221 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_PROVIDER_HOST_H_ 231 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_PROVIDER_HOST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698