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/guid.h" | 7 #include "base/guid.h" |
8 #include "base/stl_util.h" | 8 #include "base/stl_util.h" |
9 #include "content/browser/frame_host/frame_tree.h" | 9 #include "content/browser/frame_host/frame_tree.h" |
10 #include "content/browser/frame_host/frame_tree_node.h" | 10 #include "content/browser/frame_host/frame_tree_node.h" |
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
361 if (!context_) | 361 if (!context_) |
362 return false; | 362 return false; |
363 if (running_hosted_version_.get()) | 363 if (running_hosted_version_.get()) |
364 return false; | 364 return false; |
365 if (!registration || associated_registration_.get() || !allow_association_) | 365 if (!registration || associated_registration_.get() || !allow_association_) |
366 return false; | 366 return false; |
367 return true; | 367 return true; |
368 } | 368 } |
369 | 369 |
370 void ServiceWorkerProviderHost::PostMessage( | 370 void ServiceWorkerProviderHost::PostMessage( |
| 371 ServiceWorkerVersion* version, |
371 const base::string16& message, | 372 const base::string16& message, |
372 const std::vector<TransferredMessagePort>& sent_message_ports) { | 373 const std::vector<TransferredMessagePort>& sent_message_ports) { |
373 if (!dispatcher_host_) | 374 if (!dispatcher_host_) |
374 return; // Could be NULL in some tests. | 375 return; // Could be NULL in some tests. |
375 | 376 |
376 std::vector<int> new_routing_ids; | 377 std::vector<int> new_routing_ids; |
377 dispatcher_host_->message_port_message_filter()-> | 378 dispatcher_host_->message_port_message_filter()-> |
378 UpdateMessagePortsWithNewRoutes(sent_message_ports, | 379 UpdateMessagePortsWithNewRoutes(sent_message_ports, |
379 &new_routing_ids); | 380 &new_routing_ids); |
380 | 381 |
381 Send(new ServiceWorkerMsg_MessageToDocument( | 382 ServiceWorkerMsg_MessageToDocument_Params params; |
382 kDocumentMainThreadId, provider_id(), | 383 params.thread_id = kDocumentMainThreadId; |
383 message, | 384 params.provider_id = provider_id(); |
384 sent_message_ports, | 385 params.service_worker_info = GetOrCreateServiceWorkerHandle(version); |
385 new_routing_ids)); | 386 params.message = message; |
| 387 params.message_ports = sent_message_ports; |
| 388 params.new_routing_ids = new_routing_ids; |
| 389 Send(new ServiceWorkerMsg_MessageToDocument(params)); |
386 } | 390 } |
387 | 391 |
388 void ServiceWorkerProviderHost::Focus(const GetClientInfoCallback& callback) { | 392 void ServiceWorkerProviderHost::Focus(const GetClientInfoCallback& callback) { |
389 BrowserThread::PostTaskAndReplyWithResult( | 393 BrowserThread::PostTaskAndReplyWithResult( |
390 BrowserThread::UI, FROM_HERE, | 394 BrowserThread::UI, FROM_HERE, |
391 base::Bind(&FocusOnUIThread, | 395 base::Bind(&FocusOnUIThread, |
392 render_process_id_, | 396 render_process_id_, |
393 render_frame_id_), | 397 render_frame_id_), |
394 callback); | 398 callback); |
395 } | 399 } |
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
650 return context_ != NULL; | 654 return context_ != NULL; |
651 } | 655 } |
652 | 656 |
653 void ServiceWorkerProviderHost::Send(IPC::Message* message) const { | 657 void ServiceWorkerProviderHost::Send(IPC::Message* message) const { |
654 DCHECK(dispatcher_host_); | 658 DCHECK(dispatcher_host_); |
655 DCHECK(IsReadyToSendMessages()); | 659 DCHECK(IsReadyToSendMessages()); |
656 dispatcher_host_->Send(message); | 660 dispatcher_host_->Send(message); |
657 } | 661 } |
658 | 662 |
659 } // namespace content | 663 } // namespace content |
OLD | NEW |