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

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

Issue 2313653002: ServiceWorker: Exchange InterfaceProviders when starting worker thread (Closed)
Patch Set: Indent Created 4 years, 3 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 (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"
(...skipping 17 matching lines...) Expand all
28 DCHECK(embedded_worker_id_); 28 DCHECK(embedded_worker_id_);
29 dispatcher_->UnregisterWorker(embedded_worker_id_.value()); 29 dispatcher_->UnregisterWorker(embedded_worker_id_.value());
30 embedded_worker_id_.reset(); 30 embedded_worker_id_.reset();
31 stop_callback_.Run(); 31 stop_callback_.Run();
32 TRACE_EVENT0("ServiceWorker", 32 TRACE_EVENT0("ServiceWorker",
33 "EmbeddedWorkerInstanceClientImpl::StopWorkerCompleted"); 33 "EmbeddedWorkerInstanceClientImpl::StopWorkerCompleted");
34 stop_callback_.Reset(); 34 stop_callback_.Reset();
35 } 35 }
36 36
37 void EmbeddedWorkerInstanceClientImpl::StartWorker( 37 void EmbeddedWorkerInstanceClientImpl::StartWorker(
38 mojom::EmbeddedWorkerStartWorkerParamsPtr params) { 38 mojom::EmbeddedWorkerStartWorkerParamsPtr params,
39 shell::mojom::InterfaceProviderPtr remote_interfaces) {
39 TRACE_EVENT0("ServiceWorker", 40 TRACE_EVENT0("ServiceWorker",
40 "EmbeddedWorkerInstanceClientImpl::StartWorker"); 41 "EmbeddedWorkerInstanceClientImpl::StartWorker");
41 42
42 embedded_worker_id_ = params->embedded_worker_id; 43 embedded_worker_id_ = params->embedded_worker_id;
44 remote_interfaces_.Bind(std::move(remote_interfaces));
43 45
44 std::unique_ptr<EmbeddedWorkerDispatcher::WorkerWrapper> wrapper( 46 std::unique_ptr<EmbeddedWorkerDispatcher::WorkerWrapper> wrapper(
45 new EmbeddedWorkerDispatcher::WorkerWrapper( 47 new EmbeddedWorkerDispatcher::WorkerWrapper(
46 blink::WebEmbeddedWorker::create( 48 blink::WebEmbeddedWorker::create(
47 new ServiceWorkerContextClient( 49 new ServiceWorkerContextClient(
48 params->embedded_worker_id, params->service_worker_version_id, 50 params->embedded_worker_id, params->service_worker_version_id,
49 params->scope, params->script_url, 51 params->scope, params->script_url,
50 params->worker_devtools_agent_route_id, 52 params->worker_devtools_agent_route_id,
51 std::move(temporal_self_)), 53 std::move(temporal_self_)),
52 NULL), 54 NULL),
(...skipping 28 matching lines...) Expand all
81 stop_callback_ = std::move(callback); 83 stop_callback_ = std::move(callback);
82 dispatcher_->SetStopWorkerTimer(embedded_worker_id_.value()); 84 dispatcher_->SetStopWorkerTimer(embedded_worker_id_.value());
83 wrapper_->worker()->terminateWorkerContext(); 85 wrapper_->worker()->terminateWorkerContext();
84 } 86 }
85 87
86 EmbeddedWorkerInstanceClientImpl::EmbeddedWorkerInstanceClientImpl( 88 EmbeddedWorkerInstanceClientImpl::EmbeddedWorkerInstanceClientImpl(
87 EmbeddedWorkerDispatcher* dispatcher, 89 EmbeddedWorkerDispatcher* dispatcher,
88 mojo::InterfaceRequest<mojom::EmbeddedWorkerInstanceClient> request) 90 mojo::InterfaceRequest<mojom::EmbeddedWorkerInstanceClient> request)
89 : dispatcher_(dispatcher), 91 : dispatcher_(dispatcher),
90 binding_(this, std::move(request)), 92 binding_(this, std::move(request)),
91 temporal_self_(std::unique_ptr<EmbeddedWorkerInstanceClientImpl>(this)) { 93 temporal_self_(std::unique_ptr<EmbeddedWorkerInstanceClientImpl>(this)),
92 binding_.set_connection_error_handler(base::Bind( 94 main_thread_task_runner_(base::ThreadTaskRunnerHandle::Get()),
93 &EmbeddedWorkerInstanceClientImpl::OnError, base::Unretained(this))); 95 weak_factory(this) {
96 binding_.set_connection_error_handler(
97 base::Bind(&EmbeddedWorkerInstanceClientImpl::OnError, AsWeakPtr()));
94 } 98 }
95 99
96 EmbeddedWorkerInstanceClientImpl::~EmbeddedWorkerInstanceClientImpl() {} 100 EmbeddedWorkerInstanceClientImpl::~EmbeddedWorkerInstanceClientImpl() {}
97 101
98 void EmbeddedWorkerInstanceClientImpl::OnError() { 102 void EmbeddedWorkerInstanceClientImpl::OnError() {
99 // Removes myself if it's owned by myself 103 // Removes myself if it's owned by myself
100 temporal_self_.reset(); 104 temporal_self_.reset();
101 } 105 }
102 106
107 base::WeakPtr<EmbeddedWorkerInstanceClientImpl>
108 EmbeddedWorkerInstanceClientImpl::AsWeakPtr() {
109 return weak_factory.GetWeakPtr();
110 }
111
103 } // namespace content 112 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698