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 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
366 if (!context_) | 366 if (!context_) |
367 return false; | 367 return false; |
368 if (running_hosted_version_.get()) | 368 if (running_hosted_version_.get()) |
369 return false; | 369 return false; |
370 if (!registration || associated_registration_.get() || !allow_association_) | 370 if (!registration || associated_registration_.get() || !allow_association_) |
371 return false; | 371 return false; |
372 return true; | 372 return true; |
373 } | 373 } |
374 | 374 |
375 void ServiceWorkerProviderHost::PostMessage( | 375 void ServiceWorkerProviderHost::PostMessage( |
| 376 ServiceWorkerVersion* version, |
376 const base::string16& message, | 377 const base::string16& message, |
377 const std::vector<TransferredMessagePort>& sent_message_ports) { | 378 const std::vector<TransferredMessagePort>& sent_message_ports) { |
378 if (!dispatcher_host_) | 379 if (!dispatcher_host_) |
379 return; // Could be NULL in some tests. | 380 return; // Could be NULL in some tests. |
380 | 381 |
381 std::vector<int> new_routing_ids; | 382 std::vector<int> new_routing_ids; |
382 dispatcher_host_->message_port_message_filter()-> | 383 dispatcher_host_->message_port_message_filter()-> |
383 UpdateMessagePortsWithNewRoutes(sent_message_ports, | 384 UpdateMessagePortsWithNewRoutes(sent_message_ports, |
384 &new_routing_ids); | 385 &new_routing_ids); |
385 | 386 |
386 Send(new ServiceWorkerMsg_MessageToDocument( | 387 ServiceWorkerMsg_MessageToDocument_Params params; |
387 kDocumentMainThreadId, provider_id(), | 388 params.thread_id = kDocumentMainThreadId; |
388 message, | 389 params.provider_id = provider_id(); |
389 sent_message_ports, | 390 params.service_worker_info = GetOrCreateServiceWorkerHandle(version); |
390 new_routing_ids)); | 391 params.message = message; |
| 392 params.message_ports = sent_message_ports; |
| 393 params.new_routing_ids = new_routing_ids; |
| 394 Send(new ServiceWorkerMsg_MessageToDocument(params)); |
391 } | 395 } |
392 | 396 |
393 void ServiceWorkerProviderHost::Focus(const GetClientInfoCallback& callback) { | 397 void ServiceWorkerProviderHost::Focus(const GetClientInfoCallback& callback) { |
394 if (provider_type_ != SERVICE_WORKER_PROVIDER_FOR_WINDOW) { | 398 if (provider_type_ != SERVICE_WORKER_PROVIDER_FOR_WINDOW) { |
395 callback.Run(ServiceWorkerClientInfo()); | 399 callback.Run(ServiceWorkerClientInfo()); |
396 return; | 400 return; |
397 } | 401 } |
398 BrowserThread::PostTaskAndReplyWithResult( | 402 BrowserThread::PostTaskAndReplyWithResult( |
399 BrowserThread::UI, FROM_HERE, | 403 BrowserThread::UI, FROM_HERE, |
400 base::Bind(&FocusOnUIThread, render_process_id_, route_id_), callback); | 404 base::Bind(&FocusOnUIThread, render_process_id_, route_id_), callback); |
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
660 return context_ != NULL; | 664 return context_ != NULL; |
661 } | 665 } |
662 | 666 |
663 void ServiceWorkerProviderHost::Send(IPC::Message* message) const { | 667 void ServiceWorkerProviderHost::Send(IPC::Message* message) const { |
664 DCHECK(dispatcher_host_); | 668 DCHECK(dispatcher_host_); |
665 DCHECK(IsReadyToSendMessages()); | 669 DCHECK(IsReadyToSendMessages()); |
666 dispatcher_host_->Send(message); | 670 dispatcher_host_->Send(message); |
667 } | 671 } |
668 | 672 |
669 } // namespace content | 673 } // namespace content |
OLD | NEW |