Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 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/browser/payments/payment_app_context.h" | 5 #include "content/browser/payments/payment_app_context_impl.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| 11 #include "base/stl_util.h" | 11 #include "base/stl_util.h" |
| 12 #include "content/browser/payments/payment_app_manager.h" | 12 #include "content/browser/payments/payment_app_manager.h" |
| 13 #include "content/browser/service_worker/service_worker_context_wrapper.h" | 13 #include "content/browser/service_worker/service_worker_context_wrapper.h" |
| 14 #include "content/public/browser/browser_thread.h" | 14 #include "content/public/browser/browser_thread.h" |
| 15 | 15 |
| 16 namespace content { | 16 namespace content { |
| 17 | 17 |
| 18 PaymentAppContext::PaymentAppContext( | 18 PaymentAppContextImpl::PaymentAppContextImpl( |
| 19 scoped_refptr<ServiceWorkerContextWrapper> service_worker_context) | 19 scoped_refptr<ServiceWorkerContextWrapper> service_worker_context) |
| 20 : service_worker_context_(std::move(service_worker_context)) { | 20 : service_worker_context_(std::move(service_worker_context)) { |
| 21 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 21 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 22 } | 22 } |
| 23 | 23 |
| 24 PaymentAppContext::~PaymentAppContext() { | 24 PaymentAppContextImpl::~PaymentAppContextImpl() { |
| 25 DCHECK(services_.empty()); | 25 DCHECK(services_.empty()); |
|
please use gerrit instead
2016/12/14 17:39:40
Put the destructor right after GetAllManifests().
zino
2016/12/14 17:48:01
Done.
| |
| 26 } | 26 } |
| 27 | 27 |
| 28 void PaymentAppContext::Shutdown() { | 28 void PaymentAppContextImpl::Shutdown() { |
| 29 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 29 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 30 | 30 |
| 31 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, | 31 BrowserThread::PostTask( |
| 32 base::Bind(&PaymentAppContext::ShutdownOnIO, this)); | 32 BrowserThread::IO, FROM_HERE, |
| 33 base::Bind(&PaymentAppContextImpl::ShutdownOnIO, this)); | |
| 33 } | 34 } |
| 34 | 35 |
| 35 void PaymentAppContext::CreateService( | 36 void PaymentAppContextImpl::CreateService( |
| 36 mojo::InterfaceRequest<payments::mojom::PaymentAppManager> request) { | 37 mojo::InterfaceRequest<payments::mojom::PaymentAppManager> request) { |
| 37 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 38 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 38 | 39 |
| 39 BrowserThread::PostTask( | 40 BrowserThread::PostTask( |
| 40 BrowserThread::IO, FROM_HERE, | 41 BrowserThread::IO, FROM_HERE, |
| 41 base::Bind(&PaymentAppContext::CreateServiceOnIOThread, this, | 42 base::Bind(&PaymentAppContextImpl::CreateServiceOnIOThread, this, |
| 42 base::Passed(&request))); | 43 base::Passed(&request))); |
| 43 } | 44 } |
| 44 | 45 |
| 45 void PaymentAppContext::ServiceHadConnectionError(PaymentAppManager* service) { | 46 void PaymentAppContextImpl::ServiceHadConnectionError( |
| 47 PaymentAppManager* service) { | |
| 46 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 48 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 47 DCHECK(base::ContainsKey(services_, service)); | 49 DCHECK(base::ContainsKey(services_, service)); |
| 48 | 50 |
| 49 services_.erase(service); | 51 services_.erase(service); |
| 50 } | 52 } |
| 51 | 53 |
| 52 ServiceWorkerContextWrapper* PaymentAppContext::service_worker_context() const { | 54 ServiceWorkerContextWrapper* PaymentAppContextImpl::service_worker_context() |
| 55 const { | |
| 53 return service_worker_context_.get(); | 56 return service_worker_context_.get(); |
| 54 } | 57 } |
| 55 | 58 |
| 56 void PaymentAppContext::CreateServiceOnIOThread( | 59 void PaymentAppContextImpl::GetAllManifests( |
| 60 const GetAllManifestsCallback& callback) { | |
| 61 NOTIMPLEMENTED(); | |
| 62 } | |
| 63 | |
| 64 void PaymentAppContextImpl::CreateServiceOnIOThread( | |
| 57 mojo::InterfaceRequest<payments::mojom::PaymentAppManager> request) { | 65 mojo::InterfaceRequest<payments::mojom::PaymentAppManager> request) { |
| 58 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 66 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 59 PaymentAppManager* service = new PaymentAppManager(this, std::move(request)); | 67 PaymentAppManager* service = new PaymentAppManager(this, std::move(request)); |
| 60 services_[service] = base::WrapUnique(service); | 68 services_[service] = base::WrapUnique(service); |
| 61 } | 69 } |
| 62 | 70 |
| 63 void PaymentAppContext::ShutdownOnIO() { | 71 void PaymentAppContextImpl::ShutdownOnIO() { |
| 64 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 72 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 65 | 73 |
| 66 services_.clear(); | 74 services_.clear(); |
| 67 } | 75 } |
| 68 | 76 |
| 69 } // namespace content | 77 } // namespace content |
| OLD | NEW |