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_impl.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" |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 48 } | 48 } |
| 49 | 49 |
| 50 void PaymentAppContextImpl::ServiceHadConnectionError( | 50 void PaymentAppContextImpl::ServiceHadConnectionError( |
| 51 PaymentAppManager* service) { | 51 PaymentAppManager* service) { |
| 52 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 52 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 53 DCHECK(base::ContainsKey(services_, service)); | 53 DCHECK(base::ContainsKey(services_, service)); |
| 54 | 54 |
| 55 services_.erase(service); | 55 services_.erase(service); |
| 56 } | 56 } |
| 57 | 57 |
| 58 PaymentAppDatabase* PaymentAppContextImpl::payment_app_database() const { | 58 PaymentAppDatabase* PaymentAppContextImpl::payment_app_database() const { |
|
please use gerrit instead
2016/12/12 20:17:39
DCHECK_CURRENTLY_ON(BrowserThread::IO);
zino
2016/12/16 19:45:40
Done.
| |
| 59 return payment_app_database_.get(); | 59 return payment_app_database_.get(); |
| 60 } | 60 } |
| 61 | 61 |
| 62 void PaymentAppContextImpl::GetAllManifests( | 62 void PaymentAppContextImpl::GetAllManifests( |
| 63 const GetAllManifestsCallback& callback) { | 63 const GetAllManifestsCallback& callback) { |
| 64 NOTIMPLEMENTED(); | 64 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 65 BrowserThread::PostTask( | |
| 66 BrowserThread::IO, FROM_HERE, | |
| 67 base::Bind(&PaymentAppContextImpl::GetAllManifestsOnIO, this, callback)); | |
| 65 } | 68 } |
| 66 | 69 |
| 67 PaymentAppContextImpl::~PaymentAppContextImpl() { | 70 PaymentAppContextImpl::~PaymentAppContextImpl() { |
| 68 DCHECK(services_.empty()); | 71 DCHECK(services_.empty()); |
| 69 DCHECK(!payment_app_database_); | 72 DCHECK(!payment_app_database_); |
| 70 } | 73 } |
| 71 | 74 |
| 72 void PaymentAppContextImpl::CreatePaymentAppDatabaseOnIO( | 75 void PaymentAppContextImpl::CreatePaymentAppDatabaseOnIO( |
| 73 scoped_refptr<ServiceWorkerContextWrapper> service_worker_context) { | 76 scoped_refptr<ServiceWorkerContextWrapper> service_worker_context) { |
| 74 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 77 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 75 payment_app_database_ = | 78 payment_app_database_ = |
| 76 base::WrapUnique(new PaymentAppDatabase(service_worker_context)); | 79 base::WrapUnique(new PaymentAppDatabase(service_worker_context)); |
| 77 } | 80 } |
| 78 | 81 |
| 79 void PaymentAppContextImpl::CreateServiceOnIOThread( | 82 void PaymentAppContextImpl::CreateServiceOnIOThread( |
| 80 mojo::InterfaceRequest<payments::mojom::PaymentAppManager> request) { | 83 mojo::InterfaceRequest<payments::mojom::PaymentAppManager> request) { |
| 81 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 84 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 82 PaymentAppManager* service = new PaymentAppManager(this, std::move(request)); | 85 PaymentAppManager* service = new PaymentAppManager(this, std::move(request)); |
| 83 services_[service] = base::WrapUnique(service); | 86 services_[service] = base::WrapUnique(service); |
| 84 } | 87 } |
| 85 | 88 |
| 86 void PaymentAppContextImpl::ShutdownOnIO() { | 89 void PaymentAppContextImpl::ShutdownOnIO() { |
| 87 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 90 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 88 | 91 |
| 89 services_.clear(); | 92 services_.clear(); |
| 90 payment_app_database_.reset(); | 93 payment_app_database_.reset(); |
| 91 } | 94 } |
| 92 | 95 |
| 96 void PaymentAppContextImpl::GetAllManifestsOnIO( | |
| 97 const GetAllManifestsCallback& callback) { | |
| 98 DCHECK_CURRENTLY_ON(BrowserThread::IO); | |
| 99 payment_app_database()->ReadAllManifests(base::Bind( | |
| 100 &PaymentAppContextImpl::DidGetAllManifestsOnIO, this, callback)); | |
| 101 } | |
| 102 | |
| 103 void PaymentAppContextImpl::DidGetAllManifestsOnIO( | |
| 104 const GetAllManifestsCallback& callback, | |
| 105 Manifests manifests) { | |
| 106 DCHECK_CURRENTLY_ON(BrowserThread::IO); | |
| 107 | |
| 108 BrowserThread::PostTask( | |
| 109 BrowserThread::UI, FROM_HERE, | |
| 110 base::Bind(callback, base::Passed(std::move(manifests)))); | |
| 111 } | |
| 112 | |
| 93 } // namespace content | 113 } // namespace content |
| OLD | NEW |