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 #include "content/browser/service_worker/service_worker_provider_host.h" | 5 #include "content/browser/service_worker/service_worker_provider_host.h" |
6 | 6 |
7 #include "base/stl_util.h" | 7 #include "base/stl_util.h" |
8 #include "content/browser/message_port_message_filter.h" | 8 #include "content/browser/message_port_message_filter.h" |
9 #include "content/browser/service_worker/service_worker_context_core.h" | 9 #include "content/browser/service_worker/service_worker_context_core.h" |
10 #include "content/browser/service_worker/service_worker_context_request_handler. h" | 10 #include "content/browser/service_worker/service_worker_context_request_handler. h" |
(...skipping 28 matching lines...) Expand all Loading... | |
39 web_contents->GetDelegate()->ActivateContents(web_contents); | 39 web_contents->GetDelegate()->ActivateContents(web_contents); |
40 } | 40 } |
41 | 41 |
42 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, | 42 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, |
43 base::Bind(callback, result)); | 43 base::Bind(callback, result)); |
44 } | 44 } |
45 | 45 |
46 } // anonymous namespace | 46 } // anonymous namespace |
47 | 47 |
48 ServiceWorkerProviderHost::ServiceWorkerProviderHost( | 48 ServiceWorkerProviderHost::ServiceWorkerProviderHost( |
49 int render_process_id, int render_frame_id, int provider_id, | 49 int render_process_id, |
50 int render_frame_id, | |
51 int provider_id, | |
50 base::WeakPtr<ServiceWorkerContextCore> context, | 52 base::WeakPtr<ServiceWorkerContextCore> context, |
51 ServiceWorkerDispatcherHost* dispatcher_host) | 53 ServiceWorkerDispatcherHost* dispatcher_host) |
52 : render_process_id_(render_process_id), | 54 : render_process_id_(render_process_id), |
53 render_frame_id_(render_frame_id), | 55 render_frame_id_(render_frame_id), |
56 render_thread_id_(kInvalidEmbeddedWorkerThreadId), | |
54 provider_id_(provider_id), | 57 provider_id_(provider_id), |
55 context_(context), | 58 context_(context), |
56 dispatcher_host_(dispatcher_host), | 59 dispatcher_host_(dispatcher_host), |
57 allow_association_(true) { | 60 allow_association_(true) { |
58 DCHECK_NE(ChildProcessHost::kInvalidUniqueID, render_process_id_); | 61 DCHECK_NE(ChildProcessHost::kInvalidUniqueID, render_process_id_); |
62 | |
63 // If |render_frame_id| is not MSG_ROUTING_NONE, this provider host works for | |
64 // the document context and its thread in the child process should be the main | |
65 // thread. For the worker context, the corresponding thread is notified when | |
66 // the worker context gets started via SetReadyToSend(). | |
kinuko
2015/01/28 07:13:11
I think part of this comment should be probably in
nhiroki
2015/01/28 13:43:22
Done.
| |
67 if (render_frame_id != MSG_ROUTING_NONE) | |
68 render_thread_id_ = kDocumentMainThreadId; | |
kinuko
2015/01/28 07:13:11
Doing the opposite might feel more natural /easier
nhiroki
2015/01/28 13:43:22
Done.
| |
59 } | 69 } |
60 | 70 |
61 ServiceWorkerProviderHost::~ServiceWorkerProviderHost() { | 71 ServiceWorkerProviderHost::~ServiceWorkerProviderHost() { |
62 // Clear docurl so the deferred activation of a waiting worker | 72 // Clear docurl so the deferred activation of a waiting worker |
63 // won't associate the new version with a provider being destroyed. | 73 // won't associate the new version with a provider being destroyed. |
64 document_url_ = GURL(); | 74 document_url_ = GURL(); |
65 if (controlling_version_.get()) | 75 if (controlling_version_.get()) |
66 controlling_version_->RemoveControllee(this); | 76 controlling_version_->RemoveControllee(this); |
67 if (associated_registration_.get()) { | 77 if (associated_registration_.get()) { |
68 DecreaseProcessReference(associated_registration_->pattern()); | 78 DecreaseProcessReference(associated_registration_->pattern()); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
112 version->AddControllee(this); | 122 version->AddControllee(this); |
113 if (previous_version.get()) | 123 if (previous_version.get()) |
114 previous_version->RemoveControllee(this); | 124 previous_version->RemoveControllee(this); |
115 | 125 |
116 if (!dispatcher_host_) | 126 if (!dispatcher_host_) |
117 return; // Could be NULL in some tests. | 127 return; // Could be NULL in some tests. |
118 | 128 |
119 bool should_notify_controllerchange = | 129 bool should_notify_controllerchange = |
120 previous_version && version && version->skip_waiting(); | 130 previous_version && version && version->skip_waiting(); |
121 | 131 |
122 dispatcher_host_->Send(new ServiceWorkerMsg_SetControllerServiceWorker( | 132 // SetController message should be sent only for the document context. |
123 kDocumentMainThreadId, provider_id(), | 133 DCHECK_EQ(kDocumentMainThreadId, render_thread_id_); |
134 Send(new ServiceWorkerMsg_SetControllerServiceWorker( | |
135 render_thread_id_, provider_id(), | |
124 CreateAndRegisterServiceWorkerHandle(version), | 136 CreateAndRegisterServiceWorkerHandle(version), |
125 should_notify_controllerchange)); | 137 should_notify_controllerchange)); |
126 } | 138 } |
127 | 139 |
128 bool ServiceWorkerProviderHost::SetHostedVersionId(int64 version_id) { | 140 bool ServiceWorkerProviderHost::SetHostedVersionId(int64 version_id) { |
129 if (!context_) | 141 if (!context_) |
130 return true; // System is shutting down. | 142 return true; // System is shutting down. |
131 if (active_version()) | 143 if (active_version()) |
132 return false; // Unexpected bad message. | 144 return false; // Unexpected bad message. |
133 | 145 |
(...skipping 20 matching lines...) Expand all Loading... | |
154 DecreaseProcessReference(associated_registration_->pattern()); | 166 DecreaseProcessReference(associated_registration_->pattern()); |
155 IncreaseProcessReference(registration->pattern()); | 167 IncreaseProcessReference(registration->pattern()); |
156 | 168 |
157 associated_registration_ = registration; | 169 associated_registration_ = registration; |
158 associated_registration_->AddListener(this); | 170 associated_registration_->AddListener(this); |
159 SendAssociateRegistrationMessage(); | 171 SendAssociateRegistrationMessage(); |
160 SetControllerVersionAttribute(registration->active_version()); | 172 SetControllerVersionAttribute(registration->active_version()); |
161 } | 173 } |
162 | 174 |
163 void ServiceWorkerProviderHost::DisassociateRegistration() { | 175 void ServiceWorkerProviderHost::DisassociateRegistration() { |
176 queued_events_.clear(); | |
164 if (!associated_registration_.get()) | 177 if (!associated_registration_.get()) |
165 return; | 178 return; |
166 DecreaseProcessReference(associated_registration_->pattern()); | 179 DecreaseProcessReference(associated_registration_->pattern()); |
167 associated_registration_->RemoveListener(this); | 180 associated_registration_->RemoveListener(this); |
168 associated_registration_ = NULL; | 181 associated_registration_ = NULL; |
169 SetControllerVersionAttribute(NULL); | 182 SetControllerVersionAttribute(NULL); |
170 | 183 |
171 if (dispatcher_host_) { | 184 if (!dispatcher_host_) |
172 dispatcher_host_->Send(new ServiceWorkerMsg_DisassociateRegistration( | 185 return; |
173 kDocumentMainThreadId, provider_id())); | 186 |
174 } | 187 // Disassociation message should be sent only for the document context. |
188 DCHECK_EQ(kDocumentMainThreadId, render_thread_id_); | |
189 Send(new ServiceWorkerMsg_DisassociateRegistration( | |
190 render_thread_id_, provider_id())); | |
175 } | 191 } |
176 | 192 |
177 scoped_ptr<ServiceWorkerRequestHandler> | 193 scoped_ptr<ServiceWorkerRequestHandler> |
178 ServiceWorkerProviderHost::CreateRequestHandler( | 194 ServiceWorkerProviderHost::CreateRequestHandler( |
179 FetchRequestMode request_mode, | 195 FetchRequestMode request_mode, |
180 FetchCredentialsMode credentials_mode, | 196 FetchCredentialsMode credentials_mode, |
181 ResourceType resource_type, | 197 ResourceType resource_type, |
182 RequestContextType request_context_type, | 198 RequestContextType request_context_type, |
183 RequestContextFrameType frame_type, | 199 RequestContextFrameType frame_type, |
184 base::WeakPtr<storage::BlobStorageContext> blob_storage_context, | 200 base::WeakPtr<storage::BlobStorageContext> blob_storage_context, |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
233 const base::string16& message, | 249 const base::string16& message, |
234 const std::vector<int>& sent_message_port_ids) { | 250 const std::vector<int>& sent_message_port_ids) { |
235 if (!dispatcher_host_) | 251 if (!dispatcher_host_) |
236 return; // Could be NULL in some tests. | 252 return; // Could be NULL in some tests. |
237 | 253 |
238 std::vector<int> new_routing_ids; | 254 std::vector<int> new_routing_ids; |
239 dispatcher_host_->message_port_message_filter()-> | 255 dispatcher_host_->message_port_message_filter()-> |
240 UpdateMessagePortsWithNewRoutes(sent_message_port_ids, | 256 UpdateMessagePortsWithNewRoutes(sent_message_port_ids, |
241 &new_routing_ids); | 257 &new_routing_ids); |
242 | 258 |
243 dispatcher_host_->Send( | 259 Send(new ServiceWorkerMsg_MessageToDocument( |
244 new ServiceWorkerMsg_MessageToDocument( | 260 kDocumentMainThreadId, provider_id(), |
245 kDocumentMainThreadId, provider_id(), | 261 message, |
246 message, | 262 sent_message_port_ids, |
247 sent_message_port_ids, | 263 new_routing_ids)); |
248 new_routing_ids)); | |
249 } | 264 } |
250 | 265 |
251 void ServiceWorkerProviderHost::Focus(const FocusCallback& callback) { | 266 void ServiceWorkerProviderHost::Focus(const FocusCallback& callback) { |
252 BrowserThread::PostTask( | 267 BrowserThread::PostTask( |
253 BrowserThread::UI, FROM_HERE, | 268 BrowserThread::UI, FROM_HERE, |
254 base::Bind(&FocusOnUIThread, | 269 base::Bind(&FocusOnUIThread, |
255 render_process_id_, | 270 render_process_id_, |
256 render_frame_id_, | 271 render_frame_id_, |
257 callback)); | 272 callback)); |
258 } | 273 } |
259 | 274 |
260 void ServiceWorkerProviderHost::GetClientInfo( | 275 void ServiceWorkerProviderHost::GetClientInfo( |
261 int embedded_worker_id, | 276 int embedded_worker_id, |
262 int request_id) { | 277 int request_id) { |
263 dispatcher_host_->Send(new ServiceWorkerMsg_GetClientInfo( | 278 Send(new ServiceWorkerMsg_GetClientInfo( |
264 kDocumentMainThreadId, embedded_worker_id, request_id, provider_id())); | 279 kDocumentMainThreadId, embedded_worker_id, request_id, provider_id())); |
265 } | 280 } |
266 | 281 |
267 void ServiceWorkerProviderHost::AddScopedProcessReferenceToPattern( | 282 void ServiceWorkerProviderHost::AddScopedProcessReferenceToPattern( |
268 const GURL& pattern) { | 283 const GURL& pattern) { |
269 associated_patterns_.push_back(pattern); | 284 associated_patterns_.push_back(pattern); |
270 IncreaseProcessReference(pattern); | 285 IncreaseProcessReference(pattern); |
271 } | 286 } |
272 | 287 |
273 void ServiceWorkerProviderHost::PrepareForCrossSiteTransfer() { | 288 void ServiceWorkerProviderHost::PrepareForCrossSiteTransfer() { |
274 DCHECK_NE(ChildProcessHost::kInvalidUniqueID, render_process_id_); | 289 DCHECK_NE(ChildProcessHost::kInvalidUniqueID, render_process_id_); |
290 DCHECK_NE(MSG_ROUTING_NONE, render_frame_id_); | |
291 DCHECK_EQ(kDocumentMainThreadId, render_thread_id_); | |
275 | 292 |
276 for (const GURL& pattern : associated_patterns_) | 293 for (const GURL& pattern : associated_patterns_) |
277 DecreaseProcessReference(pattern); | 294 DecreaseProcessReference(pattern); |
278 | 295 |
279 if (associated_registration_.get()) { | 296 if (associated_registration_.get()) { |
280 DecreaseProcessReference(associated_registration_->pattern()); | 297 DecreaseProcessReference(associated_registration_->pattern()); |
281 if (dispatcher_host_) { | 298 if (dispatcher_host_) { |
282 dispatcher_host_->Send(new ServiceWorkerMsg_DisassociateRegistration( | 299 Send(new ServiceWorkerMsg_DisassociateRegistration( |
283 kDocumentMainThreadId, provider_id())); | 300 render_thread_id_, provider_id())); |
284 } | 301 } |
285 } | 302 } |
286 | 303 |
287 render_process_id_ = ChildProcessHost::kInvalidUniqueID; | 304 render_process_id_ = ChildProcessHost::kInvalidUniqueID; |
288 render_frame_id_ = MSG_ROUTING_NONE; | 305 render_frame_id_ = MSG_ROUTING_NONE; |
306 render_thread_id_ = kInvalidEmbeddedWorkerThreadId; | |
289 provider_id_ = kInvalidServiceWorkerProviderId; | 307 provider_id_ = kInvalidServiceWorkerProviderId; |
290 dispatcher_host_ = nullptr; | 308 dispatcher_host_ = nullptr; |
291 } | 309 } |
292 | 310 |
293 void ServiceWorkerProviderHost::CompleteCrossSiteTransfer( | 311 void ServiceWorkerProviderHost::CompleteCrossSiteTransfer( |
294 int new_process_id, | 312 int new_process_id, |
295 int new_frame_id, | 313 int new_frame_id, |
296 int new_provider_id, | 314 int new_provider_id, |
297 ServiceWorkerDispatcherHost* new_dispatcher_host) { | 315 ServiceWorkerDispatcherHost* new_dispatcher_host) { |
298 DCHECK_EQ(ChildProcessHost::kInvalidUniqueID, render_process_id_); | 316 DCHECK_EQ(ChildProcessHost::kInvalidUniqueID, render_process_id_); |
299 DCHECK_NE(ChildProcessHost::kInvalidUniqueID, new_process_id); | 317 DCHECK_NE(ChildProcessHost::kInvalidUniqueID, new_process_id); |
318 DCHECK_NE(MSG_ROUTING_NONE, new_frame_id); | |
300 | 319 |
301 render_process_id_ = new_process_id; | 320 render_process_id_ = new_process_id; |
302 render_frame_id_ = new_frame_id; | 321 render_frame_id_ = new_frame_id; |
322 render_thread_id_ = kDocumentMainThreadId; | |
303 provider_id_ = new_provider_id; | 323 provider_id_ = new_provider_id; |
304 dispatcher_host_ = new_dispatcher_host; | 324 dispatcher_host_ = new_dispatcher_host; |
305 | 325 |
306 for (const GURL& pattern : associated_patterns_) | 326 for (const GURL& pattern : associated_patterns_) |
307 IncreaseProcessReference(pattern); | 327 IncreaseProcessReference(pattern); |
308 | 328 |
309 if (associated_registration_.get()) { | 329 if (associated_registration_.get()) { |
310 IncreaseProcessReference(associated_registration_->pattern()); | 330 IncreaseProcessReference(associated_registration_->pattern()); |
311 SendAssociateRegistrationMessage(); | 331 SendAssociateRegistrationMessage(); |
312 if (dispatcher_host_ && associated_registration_->active_version()) { | 332 if (dispatcher_host_ && associated_registration_->active_version()) { |
313 dispatcher_host_->Send(new ServiceWorkerMsg_SetControllerServiceWorker( | 333 Send(new ServiceWorkerMsg_SetControllerServiceWorker( |
314 kDocumentMainThreadId, provider_id(), | 334 render_thread_id_, provider_id(), |
315 CreateAndRegisterServiceWorkerHandle( | 335 CreateAndRegisterServiceWorkerHandle( |
316 associated_registration_->active_version()), | 336 associated_registration_->active_version()), |
317 false /* shouldNotifyControllerChange */)); | 337 false /* shouldNotifyControllerChange */)); |
318 } | 338 } |
319 } | 339 } |
320 } | 340 } |
321 | 341 |
322 void ServiceWorkerProviderHost::SendUpdateFoundMessage( | 342 void ServiceWorkerProviderHost::SendUpdateFoundMessage( |
323 const ServiceWorkerRegistrationObjectInfo& object_info) { | 343 const ServiceWorkerRegistrationObjectInfo& object_info) { |
324 if (!dispatcher_host_) | 344 if (!dispatcher_host_) |
325 return; // Could be nullptr in some tests. | 345 return; // Could be nullptr in some tests. |
326 | 346 |
327 // TODO(nhiroki): Queue the message if a receiver's thread is not ready yet | 347 if (!IsReadyToSend()) { |
328 // (http://crbug.com/437677). | 348 queued_events_.push_back( |
329 dispatcher_host_->Send(new ServiceWorkerMsg_UpdateFound( | 349 base::Bind(&self::SendUpdateFoundMessage, AsWeakPtr(), object_info)); |
330 kDocumentMainThreadId, object_info)); | 350 return; |
351 } | |
352 | |
353 Send(new ServiceWorkerMsg_UpdateFound(render_thread_id_, object_info)); | |
331 } | 354 } |
332 | 355 |
333 void ServiceWorkerProviderHost::SendSetVersionAttributesMessage( | 356 void ServiceWorkerProviderHost::SendSetVersionAttributesMessage( |
334 int registration_handle_id, | 357 int registration_handle_id, |
335 ChangedVersionAttributesMask changed_mask, | 358 ChangedVersionAttributesMask changed_mask, |
336 ServiceWorkerVersion* installing_version, | 359 ServiceWorkerVersion* installing_version, |
337 ServiceWorkerVersion* waiting_version, | 360 ServiceWorkerVersion* waiting_version, |
338 ServiceWorkerVersion* active_version) { | 361 ServiceWorkerVersion* active_version) { |
339 if (!dispatcher_host_) | 362 if (!dispatcher_host_) |
340 return; // Could be nullptr in some tests. | 363 return; // Could be nullptr in some tests. |
341 if (!changed_mask.changed()) | 364 if (!changed_mask.changed()) |
342 return; | 365 return; |
343 | 366 |
367 if (!IsReadyToSend()) { | |
368 queued_events_.push_back( | |
369 base::Bind(&self::SendSetVersionAttributesMessage, | |
370 AsWeakPtr(), registration_handle_id, changed_mask, | |
371 make_scoped_refptr(installing_version), | |
372 make_scoped_refptr(waiting_version), | |
373 make_scoped_refptr(active_version))); | |
374 return; | |
375 } | |
376 | |
344 ServiceWorkerVersionAttributes attrs; | 377 ServiceWorkerVersionAttributes attrs; |
345 if (changed_mask.installing_changed()) | 378 if (changed_mask.installing_changed()) |
346 attrs.installing = CreateAndRegisterServiceWorkerHandle(installing_version); | 379 attrs.installing = CreateAndRegisterServiceWorkerHandle(installing_version); |
347 if (changed_mask.waiting_changed()) | 380 if (changed_mask.waiting_changed()) |
348 attrs.waiting = CreateAndRegisterServiceWorkerHandle(waiting_version); | 381 attrs.waiting = CreateAndRegisterServiceWorkerHandle(waiting_version); |
349 if (changed_mask.active_changed()) | 382 if (changed_mask.active_changed()) |
350 attrs.active = CreateAndRegisterServiceWorkerHandle(active_version); | 383 attrs.active = CreateAndRegisterServiceWorkerHandle(active_version); |
351 | 384 |
352 // TODO(nhiroki): Queue the message if a receiver's thread is not ready yet | 385 Send(new ServiceWorkerMsg_SetVersionAttributes( |
353 // (http://crbug.com/437677). | 386 render_thread_id_, provider_id_, registration_handle_id, |
354 dispatcher_host_->Send(new ServiceWorkerMsg_SetVersionAttributes( | |
355 kDocumentMainThreadId, provider_id_, registration_handle_id, | |
356 changed_mask.changed(), attrs)); | 387 changed_mask.changed(), attrs)); |
357 } | 388 } |
358 | 389 |
359 void ServiceWorkerProviderHost::SendServiceWorkerStateChangedMessage( | 390 void ServiceWorkerProviderHost::SendServiceWorkerStateChangedMessage( |
360 int worker_handle_id, | 391 int worker_handle_id, |
361 blink::WebServiceWorkerState state) { | 392 blink::WebServiceWorkerState state) { |
362 if (!dispatcher_host_) | 393 if (!dispatcher_host_) |
363 return; | 394 return; |
364 | 395 |
365 // TODO(nhiroki): Queue the message if a receiver's thread is not ready yet | 396 if (!IsReadyToSend()) { |
366 // (http://crbug.com/437677). | 397 queued_events_.push_back( |
367 dispatcher_host_->Send(new ServiceWorkerMsg_ServiceWorkerStateChanged( | 398 base::Bind(&self::SendServiceWorkerStateChangedMessage, |
368 kDocumentMainThreadId, worker_handle_id, state)); | 399 AsWeakPtr(), worker_handle_id, state)); |
400 return; | |
401 } | |
402 | |
403 Send(new ServiceWorkerMsg_ServiceWorkerStateChanged( | |
404 render_thread_id_, worker_handle_id, state)); | |
405 } | |
406 | |
407 void ServiceWorkerProviderHost::SetReadyToSend(int render_thread_id) { | |
408 DCHECK(!IsReadyToSend()); | |
409 render_thread_id_ = render_thread_id; | |
410 | |
411 for (const auto& event : queued_events_) | |
412 event.Run(); | |
413 queued_events_.clear(); | |
369 } | 414 } |
370 | 415 |
371 void ServiceWorkerProviderHost::SendAssociateRegistrationMessage() { | 416 void ServiceWorkerProviderHost::SendAssociateRegistrationMessage() { |
372 if (!dispatcher_host_) | 417 if (!dispatcher_host_) |
373 return; | 418 return; |
374 | 419 |
375 ServiceWorkerRegistrationHandle* handle = | 420 ServiceWorkerRegistrationHandle* handle = |
376 dispatcher_host_->GetOrCreateRegistrationHandle( | 421 dispatcher_host_->GetOrCreateRegistrationHandle( |
377 AsWeakPtr(), associated_registration_.get()); | 422 AsWeakPtr(), associated_registration_.get()); |
378 | 423 |
379 ServiceWorkerVersionAttributes attrs; | 424 ServiceWorkerVersionAttributes attrs; |
380 attrs.installing = CreateAndRegisterServiceWorkerHandle( | 425 attrs.installing = CreateAndRegisterServiceWorkerHandle( |
381 associated_registration_->installing_version()); | 426 associated_registration_->installing_version()); |
382 attrs.waiting = CreateAndRegisterServiceWorkerHandle( | 427 attrs.waiting = CreateAndRegisterServiceWorkerHandle( |
383 associated_registration_->waiting_version()); | 428 associated_registration_->waiting_version()); |
384 attrs.active = CreateAndRegisterServiceWorkerHandle( | 429 attrs.active = CreateAndRegisterServiceWorkerHandle( |
385 associated_registration_->active_version()); | 430 associated_registration_->active_version()); |
386 | 431 |
432 // Association message should be sent only for the document context. | |
433 DCHECK_EQ(kDocumentMainThreadId, render_thread_id_); | |
387 dispatcher_host_->Send(new ServiceWorkerMsg_AssociateRegistration( | 434 dispatcher_host_->Send(new ServiceWorkerMsg_AssociateRegistration( |
388 kDocumentMainThreadId, provider_id(), handle->GetObjectInfo(), attrs)); | 435 render_thread_id_, provider_id(), handle->GetObjectInfo(), attrs)); |
389 } | 436 } |
390 | 437 |
391 void ServiceWorkerProviderHost::IncreaseProcessReference( | 438 void ServiceWorkerProviderHost::IncreaseProcessReference( |
392 const GURL& pattern) { | 439 const GURL& pattern) { |
393 if (context_ && context_->process_manager()) { | 440 if (context_ && context_->process_manager()) { |
394 context_->process_manager()->AddProcessReferenceToPattern( | 441 context_->process_manager()->AddProcessReferenceToPattern( |
395 pattern, render_process_id_); | 442 pattern, render_process_id_); |
396 } | 443 } |
397 } | 444 } |
398 | 445 |
399 void ServiceWorkerProviderHost::DecreaseProcessReference( | 446 void ServiceWorkerProviderHost::DecreaseProcessReference( |
400 const GURL& pattern) { | 447 const GURL& pattern) { |
401 if (context_ && context_->process_manager()) { | 448 if (context_ && context_->process_manager()) { |
402 context_->process_manager()->RemoveProcessReferenceFromPattern( | 449 context_->process_manager()->RemoveProcessReferenceFromPattern( |
403 pattern, render_process_id_); | 450 pattern, render_process_id_); |
404 } | 451 } |
405 } | 452 } |
406 | 453 |
454 bool ServiceWorkerProviderHost::IsReadyToSend() const { | |
455 return render_thread_id_ != kInvalidEmbeddedWorkerThreadId; | |
456 } | |
457 | |
407 bool ServiceWorkerProviderHost::IsContextAlive() { | 458 bool ServiceWorkerProviderHost::IsContextAlive() { |
408 return context_ != NULL; | 459 return context_ != NULL; |
409 } | 460 } |
410 | 461 |
462 void ServiceWorkerProviderHost::Send(IPC::Message* message) const { | |
463 DCHECK(dispatcher_host_); | |
464 DCHECK(IsReadyToSend()); | |
465 dispatcher_host_->Send(message); | |
466 } | |
467 | |
411 } // namespace content | 468 } // namespace content |
OLD | NEW |