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

Unified Diff: content/child/service_worker/web_service_worker_impl.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 side-by-side diff with in-line comments
Download patch
Index: content/child/service_worker/web_service_worker_impl.cc
diff --git a/content/child/service_worker/web_service_worker_impl.cc b/content/child/service_worker/web_service_worker_impl.cc
index f926872c062ae5ec708f077868b7cf3300144c15..7c5a510194031e62068d105b5f03facf9c449b00 100644
--- a/content/child/service_worker/web_service_worker_impl.cc
+++ b/content/child/service_worker/web_service_worker_impl.cc
@@ -9,9 +9,11 @@
#include "base/macros.h"
#include "content/child/service_worker/service_worker_dispatcher.h"
#include "content/child/service_worker/service_worker_handle_reference.h"
+#include "content/child/service_worker/web_service_worker_provider_impl.h"
#include "content/child/thread_safe_sender.h"
#include "content/child/webmessageportchannel_impl.h"
#include "content/common/service_worker/service_worker_messages.h"
+#include "third_party/WebKit/public/platform/WebSecurityOrigin.h"
#include "third_party/WebKit/public/platform/WebString.h"
#include "third_party/WebKit/public/platform/modules/serviceworker/WebServiceWorkerProxy.h"
#include "third_party/WebKit/public/web/WebRuntimeFeatures.h"
@@ -20,6 +22,7 @@ using blink::WebMessagePortChannel;
using blink::WebMessagePortChannelArray;
using blink::WebMessagePortChannelClient;
using blink::WebRuntimeFeatures;
+using blink::WebSecurityOrigin;
using blink::WebString;
namespace content {
@@ -43,11 +46,13 @@ class HandleImpl : public blink::WebServiceWorker::Handle {
void SendPostMessageToWorkerOnMainThread(
ThreadSafeSender* thread_safe_sender,
int handle_id,
+ int provider_id,
const base::string16& message,
+ const url::Origin& source_origin,
scoped_ptr<WebMessagePortChannelArray> channels) {
if (WebRuntimeFeatures::isServiceWorkerExtendableMessageEventEnabled()) {
thread_safe_sender->Send(new ServiceWorkerHostMsg_PostMessageToWorker(
- handle_id, message,
+ handle_id, provider_id, message, source_origin,
WebMessagePortChannelImpl::ExtractMessagePortIDs(std::move(channels))));
} else {
thread_safe_sender->Send(
@@ -100,8 +105,13 @@ blink::WebServiceWorkerState WebServiceWorkerImpl::state() const {
return state_;
}
-void WebServiceWorkerImpl::postMessage(const WebString& message,
- WebMessagePortChannelArray* channels) {
+void WebServiceWorkerImpl::postMessage(
+ blink::WebServiceWorkerProvider* provider,
+ const WebString& message,
+ const WebSecurityOrigin& source_origin,
+ WebMessagePortChannelArray* channels) {
+ WebServiceWorkerProviderImpl* provider_impl =
+ static_cast<WebServiceWorkerProviderImpl*>(provider);
ServiceWorkerDispatcher* dispatcher =
ServiceWorkerDispatcher::GetThreadSpecificInstance();
DCHECK(dispatcher);
@@ -111,12 +121,14 @@ void WebServiceWorkerImpl::postMessage(const WebString& message,
// (with thread hopping), so we need to do the same thread hopping here not
// to overtake those messages.
dispatcher->main_thread_task_runner()->PostTask(
- FROM_HERE, base::Bind(&SendPostMessageToWorkerOnMainThread,
- thread_safe_sender_, handle_ref_->handle_id(),
- // We cast WebString to string16 before crossing
- // threads for thread-safety.
- static_cast<base::string16>(message),
- base::Passed(make_scoped_ptr(channels))));
+ FROM_HERE,
+ base::Bind(&SendPostMessageToWorkerOnMainThread, thread_safe_sender_,
+ handle_ref_->handle_id(), provider_impl->provider_id(),
+ // We cast WebString to string16 before crossing
+ // threads for thread-safety.
+ static_cast<base::string16>(message),
+ url::Origin(source_origin),
+ base::Passed(make_scoped_ptr(channels))));
}
void WebServiceWorkerImpl::terminate() {
« no previous file with comments | « content/child/service_worker/web_service_worker_impl.h ('k') | content/common/service_worker/service_worker_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698