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

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

Issue 2606593002: [ServiceWorker] Associate interfaces.
Patch Set: Fix unit tests Created 3 years, 11 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"
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 "third_party/WebKit/public/web/WebEmbeddedWorker.h" 15 #include "third_party/WebKit/public/web/WebEmbeddedWorker.h"
16 #include "third_party/WebKit/public/web/WebEmbeddedWorkerStartData.h" 16 #include "third_party/WebKit/public/web/WebEmbeddedWorkerStartData.h"
17 17
18 namespace content { 18 namespace content {
19 19
20 // static 20 // static
21 void EmbeddedWorkerInstanceClientImpl::Create( 21 void EmbeddedWorkerInstanceClientImpl::Create(
22 EmbeddedWorkerDispatcher* dispatcher, 22 EmbeddedWorkerDispatcher* dispatcher,
23 mojo::InterfaceRequest<mojom::EmbeddedWorkerInstanceClient> request) { 23 mojom::EmbeddedWorkerInstanceClientAssociatedRequest request) {
24 // 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.
25 new EmbeddedWorkerInstanceClientImpl(dispatcher, std::move(request)); 25 new EmbeddedWorkerInstanceClientImpl(dispatcher, std::move(request));
26 } 26 }
27 27
28 void EmbeddedWorkerInstanceClientImpl::StopWorkerCompleted() { 28 void EmbeddedWorkerInstanceClientImpl::StopWorkerCompleted() {
29 DCHECK(embedded_worker_id_); 29 DCHECK(embedded_worker_id_);
30 DCHECK(stop_callback_); 30 DCHECK(stop_callback_);
31 TRACE_EVENT0("ServiceWorker", 31 TRACE_EVENT0("ServiceWorker",
32 "EmbeddedWorkerInstanceClientImpl::StopWorkerCompleted"); 32 "EmbeddedWorkerInstanceClientImpl::StopWorkerCompleted");
33 // TODO(falken): The signals to the browser should be in the order: 33 // TODO(falken): The signals to the browser should be in the order:
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 if (stop_callback_ || !wrapper_) 72 if (stop_callback_ || !wrapper_)
73 return; 73 return;
74 TRACE_EVENT0("ServiceWorker", "EmbeddedWorkerInstanceClientImpl::StopWorker"); 74 TRACE_EVENT0("ServiceWorker", "EmbeddedWorkerInstanceClientImpl::StopWorker");
75 stop_callback_ = std::move(callback); 75 stop_callback_ = std::move(callback);
76 dispatcher_->RecordStopWorkerTimer(embedded_worker_id_.value()); 76 dispatcher_->RecordStopWorkerTimer(embedded_worker_id_.value());
77 wrapper_->worker()->terminateWorkerContext(); 77 wrapper_->worker()->terminateWorkerContext();
78 } 78 }
79 79
80 EmbeddedWorkerInstanceClientImpl::EmbeddedWorkerInstanceClientImpl( 80 EmbeddedWorkerInstanceClientImpl::EmbeddedWorkerInstanceClientImpl(
81 EmbeddedWorkerDispatcher* dispatcher, 81 EmbeddedWorkerDispatcher* dispatcher,
82 mojo::InterfaceRequest<mojom::EmbeddedWorkerInstanceClient> request) 82 mojom::EmbeddedWorkerInstanceClientAssociatedRequest request)
83 : dispatcher_(dispatcher), 83 : dispatcher_(dispatcher),
84 binding_(this, std::move(request)), 84 binding_(this, std::move(request)),
85 temporal_self_(std::unique_ptr<EmbeddedWorkerInstanceClientImpl>(this)), 85 temporal_self_(std::unique_ptr<EmbeddedWorkerInstanceClientImpl>(this)),
86 wrapper_(nullptr) { 86 wrapper_(nullptr) {
87 binding_.set_connection_error_handler(base::Bind( 87 binding_.set_connection_error_handler(base::Bind(
88 &EmbeddedWorkerInstanceClientImpl::OnError, base::Unretained(this))); 88 &EmbeddedWorkerInstanceClientImpl::OnError, base::Unretained(this)));
89 } 89 }
90 90
91 EmbeddedWorkerInstanceClientImpl::~EmbeddedWorkerInstanceClientImpl() {} 91 EmbeddedWorkerInstanceClientImpl::~EmbeddedWorkerInstanceClientImpl() {}
92 92
93 void EmbeddedWorkerInstanceClientImpl::OnError() { 93 void EmbeddedWorkerInstanceClientImpl::OnError() {
94 // Removes myself if it's owned by myself. 94 // Removes myself if it's owned by myself.
95 temporal_self_.reset(); 95 temporal_self_.reset();
96 } 96 }
97 97
98 } // namespace content 98 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/service_worker/embedded_worker_instance_client_impl.h ('k') | content/test/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698