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

Side by Side Diff: content/browser/service_worker/service_worker_dispatcher_host.cc

Issue 1701843002: ServiceWorker: Implement 'source' and 'origin' attributes of ExtendableMessageEvent (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@move_focus_into_utils
Patch Set: clean up tests Created 4 years, 9 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 #include "content/browser/service_worker/service_worker_dispatcher_host.h" 5 #include "content/browser/service_worker/service_worker_dispatcher_host.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 658 matching lines...) Expand 10 before | Expand all | Expand 10 after
669 if (!provider_host->GetRegistrationForReady(base::Bind( 669 if (!provider_host->GetRegistrationForReady(base::Bind(
670 &ServiceWorkerDispatcherHost::GetRegistrationForReadyComplete, 670 &ServiceWorkerDispatcherHost::GetRegistrationForReadyComplete,
671 this, thread_id, request_id, provider_host->AsWeakPtr()))) { 671 this, thread_id, request_id, provider_host->AsWeakPtr()))) {
672 bad_message::ReceivedBadMessage( 672 bad_message::ReceivedBadMessage(
673 this, bad_message::SWDH_GET_REGISTRATION_FOR_READY_ALREADY_IN_PROGRESS); 673 this, bad_message::SWDH_GET_REGISTRATION_FOR_READY_ALREADY_IN_PROGRESS);
674 } 674 }
675 } 675 }
676 676
677 void ServiceWorkerDispatcherHost::OnPostMessageToWorker( 677 void ServiceWorkerDispatcherHost::OnPostMessageToWorker(
678 int handle_id, 678 int handle_id,
679 int provider_id,
679 const base::string16& message, 680 const base::string16& message,
681 const url::Origin& source_origin,
680 const std::vector<TransferredMessagePort>& sent_message_ports) { 682 const std::vector<TransferredMessagePort>& sent_message_ports) {
681 TRACE_EVENT0("ServiceWorker", 683 TRACE_EVENT0("ServiceWorker",
682 "ServiceWorkerDispatcherHost::OnPostMessageToWorker"); 684 "ServiceWorkerDispatcherHost::OnPostMessageToWorker");
683 if (!GetContext()) 685 if (!GetContext())
684 return; 686 return;
685 687
686 ServiceWorkerHandle* handle = handles_.Lookup(handle_id); 688 ServiceWorkerHandle* handle = handles_.Lookup(handle_id);
687 if (!handle) { 689 if (!handle) {
688 bad_message::ReceivedBadMessage(this, bad_message::SWDH_POST_MESSAGE); 690 bad_message::ReceivedBadMessage(this, bad_message::SWDH_POST_MESSAGE);
689 return; 691 return;
690 } 692 }
691 693
694 ServiceWorkerProviderHost* sender_provider_host =
695 GetContext()->GetProviderHost(render_process_id_, provider_id);
696 if (!sender_provider_host) {
697 bad_message::ReceivedBadMessage(this, bad_message::SWDH_POST_MESSAGE);
698 return;
699 }
700
692 handle->version()->DispatchExtendableMessageEvent( 701 handle->version()->DispatchExtendableMessageEvent(
693 message, sent_message_ports, 702 sender_provider_host, message, source_origin, sent_message_ports,
694 base::Bind(&ServiceWorkerUtils::NoOpStatusCallback)); 703 base::Bind(&ServiceWorkerUtils::NoOpStatusCallback));
695 } 704 }
696 705
697 void ServiceWorkerDispatcherHost::OnDeprecatedPostMessageToWorker( 706 void ServiceWorkerDispatcherHost::OnDeprecatedPostMessageToWorker(
698 int handle_id, 707 int handle_id,
699 const base::string16& message, 708 const base::string16& message,
700 const std::vector<TransferredMessagePort>& sent_message_ports) { 709 const std::vector<TransferredMessagePort>& sent_message_ports) {
701 TRACE_EVENT0("ServiceWorker", 710 TRACE_EVENT0("ServiceWorker",
702 "ServiceWorkerDispatcherHost::OnDeprecatedPostMessageToWorker"); 711 "ServiceWorkerDispatcherHost::OnDeprecatedPostMessageToWorker");
703 if (!GetContext()) 712 if (!GetContext())
(...skipping 624 matching lines...) Expand 10 before | Expand all | Expand 10 after
1328 if (!handle) { 1337 if (!handle) {
1329 bad_message::ReceivedBadMessage(this, 1338 bad_message::ReceivedBadMessage(this,
1330 bad_message::SWDH_TERMINATE_BAD_HANDLE); 1339 bad_message::SWDH_TERMINATE_BAD_HANDLE);
1331 return; 1340 return;
1332 } 1341 }
1333 handle->version()->StopWorker( 1342 handle->version()->StopWorker(
1334 base::Bind(&ServiceWorkerUtils::NoOpStatusCallback)); 1343 base::Bind(&ServiceWorkerUtils::NoOpStatusCallback));
1335 } 1344 }
1336 1345
1337 } // namespace content 1346 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698