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

Side by Side Diff: content/child/service_worker/web_service_worker_impl.cc

Issue 1877283002: ServiceWorker: Remove unused MessageEvent implementation from ServiceWorkerGlobalScope (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 8 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/child/service_worker/web_service_worker_impl.h" 5 #include "content/child/service_worker/web_service_worker_impl.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
11 #include "content/child/service_worker/service_worker_dispatcher.h" 11 #include "content/child/service_worker/service_worker_dispatcher.h"
12 #include "content/child/service_worker/service_worker_handle_reference.h" 12 #include "content/child/service_worker/service_worker_handle_reference.h"
13 #include "content/child/service_worker/web_service_worker_provider_impl.h" 13 #include "content/child/service_worker/web_service_worker_provider_impl.h"
14 #include "content/child/thread_safe_sender.h" 14 #include "content/child/thread_safe_sender.h"
15 #include "content/child/webmessageportchannel_impl.h" 15 #include "content/child/webmessageportchannel_impl.h"
16 #include "content/common/service_worker/service_worker_messages.h" 16 #include "content/common/service_worker/service_worker_messages.h"
17 #include "third_party/WebKit/public/platform/WebSecurityOrigin.h" 17 #include "third_party/WebKit/public/platform/WebSecurityOrigin.h"
18 #include "third_party/WebKit/public/platform/WebString.h" 18 #include "third_party/WebKit/public/platform/WebString.h"
19 #include "third_party/WebKit/public/platform/modules/serviceworker/WebServiceWor kerProxy.h" 19 #include "third_party/WebKit/public/platform/modules/serviceworker/WebServiceWor kerProxy.h"
20 #include "third_party/WebKit/public/web/WebRuntimeFeatures.h" 20 #include "third_party/WebKit/public/web/WebRuntimeFeatures.h"
21 21
22 using blink::WebMessagePortChannel; 22 using blink::WebMessagePortChannel;
23 using blink::WebMessagePortChannelArray; 23 using blink::WebMessagePortChannelArray;
24 using blink::WebMessagePortChannelClient; 24 using blink::WebMessagePortChannelClient;
25 using blink::WebRuntimeFeatures;
26 using blink::WebSecurityOrigin; 25 using blink::WebSecurityOrigin;
27 using blink::WebString; 26 using blink::WebString;
28 27
29 namespace content { 28 namespace content {
30 29
31 namespace { 30 namespace {
32 31
33 class HandleImpl : public blink::WebServiceWorker::Handle { 32 class HandleImpl : public blink::WebServiceWorker::Handle {
34 public: 33 public:
35 explicit HandleImpl(const scoped_refptr<WebServiceWorkerImpl>& worker) 34 explicit HandleImpl(const scoped_refptr<WebServiceWorkerImpl>& worker)
36 : worker_(worker) {} 35 : worker_(worker) {}
37 ~HandleImpl() override {} 36 ~HandleImpl() override {}
38 37
39 blink::WebServiceWorker* serviceWorker() override { return worker_.get(); } 38 blink::WebServiceWorker* serviceWorker() override { return worker_.get(); }
40 39
41 private: 40 private:
42 scoped_refptr<WebServiceWorkerImpl> worker_; 41 scoped_refptr<WebServiceWorkerImpl> worker_;
43 42
44 DISALLOW_COPY_AND_ASSIGN(HandleImpl); 43 DISALLOW_COPY_AND_ASSIGN(HandleImpl);
45 }; 44 };
46 45
47 void SendPostMessageToWorkerOnMainThread( 46 void SendPostMessageToWorkerOnMainThread(
48 ThreadSafeSender* thread_safe_sender, 47 ThreadSafeSender* thread_safe_sender,
49 int handle_id, 48 int handle_id,
50 int provider_id, 49 int provider_id,
51 const base::string16& message, 50 const base::string16& message,
52 const url::Origin& source_origin, 51 const url::Origin& source_origin,
53 std::unique_ptr<WebMessagePortChannelArray> channels) { 52 std::unique_ptr<WebMessagePortChannelArray> channels) {
54 if (WebRuntimeFeatures::isServiceWorkerExtendableMessageEventEnabled()) { 53 thread_safe_sender->Send(new ServiceWorkerHostMsg_PostMessageToWorker(
55 thread_safe_sender->Send(new ServiceWorkerHostMsg_PostMessageToWorker( 54 handle_id, provider_id, message, source_origin,
56 handle_id, provider_id, message, source_origin, 55 WebMessagePortChannelImpl::ExtractMessagePortIDs(std::move(channels))));
57 WebMessagePortChannelImpl::ExtractMessagePortIDs(std::move(channels))));
58 } else {
59 thread_safe_sender->Send(
60 new ServiceWorkerHostMsg_DeprecatedPostMessageToWorker(
61 handle_id, message,
62 WebMessagePortChannelImpl::ExtractMessagePortIDs(
63 std::move(channels))));
64 }
65 } 56 }
66 57
67 } // namespace 58 } // namespace
68 59
69 WebServiceWorkerImpl::WebServiceWorkerImpl( 60 WebServiceWorkerImpl::WebServiceWorkerImpl(
70 std::unique_ptr<ServiceWorkerHandleReference> handle_ref, 61 std::unique_ptr<ServiceWorkerHandleReference> handle_ref,
71 ThreadSafeSender* thread_safe_sender) 62 ThreadSafeSender* thread_safe_sender)
72 : handle_ref_(std::move(handle_ref)), 63 : handle_ref_(std::move(handle_ref)),
73 state_(handle_ref_->state()), 64 state_(handle_ref_->state()),
74 thread_safe_sender_(thread_safe_sender), 65 thread_safe_sender_(thread_safe_sender),
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 } 139 }
149 140
150 WebServiceWorkerImpl::~WebServiceWorkerImpl() { 141 WebServiceWorkerImpl::~WebServiceWorkerImpl() {
151 ServiceWorkerDispatcher* dispatcher = 142 ServiceWorkerDispatcher* dispatcher =
152 ServiceWorkerDispatcher::GetThreadSpecificInstance(); 143 ServiceWorkerDispatcher::GetThreadSpecificInstance();
153 if (dispatcher) 144 if (dispatcher)
154 dispatcher->RemoveServiceWorker(handle_ref_->handle_id()); 145 dispatcher->RemoveServiceWorker(handle_ref_->handle_id());
155 } 146 }
156 147
157 } // namespace content 148 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698