| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "content/browser/service_worker/service_worker_service_impl.h" |
| 6 |
| 7 #include "content/browser/service_worker/service_worker_context_core.h" |
| 8 #include "content/public/browser/browser_thread.h" |
| 9 |
| 10 namespace content { |
| 11 |
| 12 ServiceWorkerServiceImpl::ServiceWorkerServiceImpl( |
| 13 base::WeakPtr<ServiceWorkerContextCore> context, |
| 14 blink::mojom::ServiceWorkerServiceRequest request) |
| 15 : context_(context), binding_(this, std::move(request)) { |
| 16 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 17 binding_.set_connection_error_handler( |
| 18 base::Bind(&ServiceWorkerServiceImpl::OnConnectionError, |
| 19 base::Unretained(this) /* the channel is owned by this */)); |
| 20 } |
| 21 |
| 22 ServiceWorkerServiceImpl::~ServiceWorkerServiceImpl() { |
| 23 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 24 } |
| 25 |
| 26 void ServiceWorkerServiceImpl::ReplaceContext( |
| 27 base::WeakPtr<ServiceWorkerContextCore> context) { |
| 28 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 29 context_ = context; |
| 30 } |
| 31 |
| 32 void ServiceWorkerServiceImpl::WorkerStarted(int32_t embedded_worker_id) { |
| 33 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 34 LOG(ERROR) << "ServiceWorkerServiceImpl::WorkerStarted " |
| 35 << embedded_worker_id; |
| 36 } |
| 37 |
| 38 void ServiceWorkerServiceImpl::OnConnectionError() { |
| 39 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 40 if (!context_) |
| 41 return; |
| 42 context_->ServiceHadConnectionError(this); |
| 43 // |this| is now deleted. |
| 44 } |
| 45 |
| 46 } // namespace content |
| OLD | NEW |