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

Side by Side Diff: content/renderer/service_worker/embedded_worker_instance_client_impl.cc

Issue 2490623005: Remove InterfaceRegistry/Provider from service workers (Closed)
Patch Set: review Created 4 years, 1 month 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 (c) 2016 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2016 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/renderer/service_worker/embedded_worker_instance_client_impl.h " 5 #include "content/renderer/service_worker/embedded_worker_instance_client_impl.h "
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "content/child/scoped_child_process_reference.h" 10 #include "content/child/scoped_child_process_reference.h"
11 #include "content/common/service_worker/embedded_worker_messages.h" 11 #include "content/common/service_worker/embedded_worker_messages.h"
12 #include "content/public/common/content_client.h" 12 #include "content/public/common/content_client.h"
13 #include "content/renderer/service_worker/embedded_worker_devtools_agent.h" 13 #include "content/renderer/service_worker/embedded_worker_devtools_agent.h"
14 #include "content/renderer/service_worker/service_worker_context_client.h" 14 #include "content/renderer/service_worker/service_worker_context_client.h"
15 #include "services/service_manager/public/cpp/interface_registry.h"
16 #include "third_party/WebKit/public/web/WebEmbeddedWorker.h" 15 #include "third_party/WebKit/public/web/WebEmbeddedWorker.h"
17 #include "third_party/WebKit/public/web/WebEmbeddedWorkerStartData.h" 16 #include "third_party/WebKit/public/web/WebEmbeddedWorkerStartData.h"
18 17
19 namespace content { 18 namespace content {
20 19
21 // static 20 // static
22 void EmbeddedWorkerInstanceClientImpl::Create( 21 void EmbeddedWorkerInstanceClientImpl::Create(
23 EmbeddedWorkerDispatcher* dispatcher, 22 EmbeddedWorkerDispatcher* dispatcher,
24 mojo::InterfaceRequest<mojom::EmbeddedWorkerInstanceClient> request) { 23 mojo::InterfaceRequest<mojom::EmbeddedWorkerInstanceClient> request) {
25 // This won't be leaked because the lifetime will be managed internally. 24 // This won't be leaked because the lifetime will be managed internally.
26 new EmbeddedWorkerInstanceClientImpl(dispatcher, std::move(request)); 25 new EmbeddedWorkerInstanceClientImpl(dispatcher, std::move(request));
27 } 26 }
28 27
29 void EmbeddedWorkerInstanceClientImpl::ExposeInterfacesToBrowser(
30 service_manager::InterfaceRegistry* interface_registry) {
31 DCHECK(renderer_request_.is_pending());
32 interface_registry->Bind(
33 std::move(renderer_request_), service_manager::Identity(),
34 service_manager::InterfaceProviderSpec(), service_manager::Identity(),
35 service_manager::InterfaceProviderSpec());
36 }
37
38 void EmbeddedWorkerInstanceClientImpl::StopWorkerCompleted() { 28 void EmbeddedWorkerInstanceClientImpl::StopWorkerCompleted() {
39 DCHECK(embedded_worker_id_); 29 DCHECK(embedded_worker_id_);
40 DCHECK(stop_callback_); 30 DCHECK(stop_callback_);
41 dispatcher_->UnregisterWorker(embedded_worker_id_.value()); 31 dispatcher_->UnregisterWorker(embedded_worker_id_.value());
42 embedded_worker_id_.reset(); 32 embedded_worker_id_.reset();
43 stop_callback_.Run(); 33 stop_callback_.Run();
44 TRACE_EVENT0("ServiceWorker", 34 TRACE_EVENT0("ServiceWorker",
45 "EmbeddedWorkerInstanceClientImpl::StopWorkerCompleted"); 35 "EmbeddedWorkerInstanceClientImpl::StopWorkerCompleted");
46 stop_callback_.Reset(); 36 stop_callback_.Reset();
47 } 37 }
48 38
49 void EmbeddedWorkerInstanceClientImpl::StartWorker( 39 void EmbeddedWorkerInstanceClientImpl::StartWorker(
50 const EmbeddedWorkerStartParams& params, 40 const EmbeddedWorkerStartParams& params,
51 service_manager::mojom::InterfaceProviderPtr browser_interfaces, 41 mojom::ServiceWorkerEventDispatcherRequest dispatcher_request) {
52 service_manager::mojom::InterfaceProviderRequest renderer_request) {
53 DCHECK(ChildThreadImpl::current()); 42 DCHECK(ChildThreadImpl::current());
54 TRACE_EVENT0("ServiceWorker", 43 TRACE_EVENT0("ServiceWorker",
55 "EmbeddedWorkerInstanceClientImpl::StartWorker"); 44 "EmbeddedWorkerInstanceClientImpl::StartWorker");
56 embedded_worker_id_ = params.embedded_worker_id; 45 embedded_worker_id_ = params.embedded_worker_id;
57 remote_interfaces_.Bind(std::move(browser_interfaces));
58 renderer_request_ = std::move(renderer_request);
59 46
60 std::unique_ptr<EmbeddedWorkerDispatcher::WorkerWrapper> wrapper = 47 std::unique_ptr<EmbeddedWorkerDispatcher::WorkerWrapper> wrapper =
61 dispatcher_->StartWorkerContext( 48 dispatcher_->StartWorkerContext(
62 params, base::MakeUnique<ServiceWorkerContextClient>( 49 params,
63 params.embedded_worker_id, 50 base::MakeUnique<ServiceWorkerContextClient>(
64 params.service_worker_version_id, params.scope, 51 params.embedded_worker_id, params.service_worker_version_id,
65 params.script_url, params.worker_devtools_agent_route_id, 52 params.scope, params.script_url,
66 std::move(temporal_self_))); 53 params.worker_devtools_agent_route_id,
54 std::move(dispatcher_request), std::move(temporal_self_)));
67 wrapper_ = wrapper.get(); 55 wrapper_ = wrapper.get();
68 dispatcher_->RegisterWorker(params.embedded_worker_id, std::move(wrapper)); 56 dispatcher_->RegisterWorker(params.embedded_worker_id, std::move(wrapper));
69 } 57 }
70 58
71 void EmbeddedWorkerInstanceClientImpl::StopWorker( 59 void EmbeddedWorkerInstanceClientImpl::StopWorker(
72 const StopWorkerCallback& callback) { 60 const StopWorkerCallback& callback) {
73 DCHECK(ChildThreadImpl::current()); 61 DCHECK(ChildThreadImpl::current());
74 DCHECK(embedded_worker_id_); 62 DCHECK(embedded_worker_id_);
75 // StopWorker is possible to be called twice. 63 // StopWorker is possible to be called twice.
76 if (stop_callback_) { 64 if (stop_callback_) {
(...skipping 17 matching lines...) Expand all
94 } 82 }
95 83
96 EmbeddedWorkerInstanceClientImpl::~EmbeddedWorkerInstanceClientImpl() {} 84 EmbeddedWorkerInstanceClientImpl::~EmbeddedWorkerInstanceClientImpl() {}
97 85
98 void EmbeddedWorkerInstanceClientImpl::OnError() { 86 void EmbeddedWorkerInstanceClientImpl::OnError() {
99 // Removes myself if it's owned by myself. 87 // Removes myself if it's owned by myself.
100 temporal_self_.reset(); 88 temporal_self_.reset();
101 } 89 }
102 90
103 } // namespace content 91 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698