| 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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 DCHECK(base::ContainsKey(payment_app_managers_, payment_app_manager)); | 54 DCHECK(base::ContainsKey(payment_app_managers_, payment_app_manager)); |
| 55 | 55 |
| 56 payment_app_managers_.erase(payment_app_manager); | 56 payment_app_managers_.erase(payment_app_manager); |
| 57 } | 57 } |
| 58 | 58 |
| 59 PaymentAppDatabase* PaymentAppContextImpl::payment_app_database() const { | 59 PaymentAppDatabase* PaymentAppContextImpl::payment_app_database() const { |
| 60 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 60 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 61 return payment_app_database_.get(); | 61 return payment_app_database_.get(); |
| 62 } | 62 } |
| 63 | 63 |
| 64 void PaymentAppContextImpl::GetAllManifests( | |
| 65 const GetAllManifestsCallback& callback) { | |
| 66 DCHECK_CURRENTLY_ON(BrowserThread::UI); | |
| 67 BrowserThread::PostTask( | |
| 68 BrowserThread::IO, FROM_HERE, | |
| 69 base::Bind(&PaymentAppContextImpl::GetAllManifestsOnIO, this, callback)); | |
| 70 } | |
| 71 | |
| 72 PaymentAppContextImpl::~PaymentAppContextImpl() { | 64 PaymentAppContextImpl::~PaymentAppContextImpl() { |
| 73 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 65 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 74 DCHECK(is_shutdown_); | 66 DCHECK(is_shutdown_); |
| 75 } | 67 } |
| 76 | 68 |
| 77 void PaymentAppContextImpl::CreatePaymentAppDatabaseOnIO( | 69 void PaymentAppContextImpl::CreatePaymentAppDatabaseOnIO( |
| 78 scoped_refptr<ServiceWorkerContextWrapper> service_worker_context) { | 70 scoped_refptr<ServiceWorkerContextWrapper> service_worker_context) { |
| 79 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 71 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 80 payment_app_database_ = | 72 payment_app_database_ = |
| 81 base::MakeUnique<PaymentAppDatabase>(service_worker_context); | 73 base::MakeUnique<PaymentAppDatabase>(service_worker_context); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 96 payment_app_managers_.clear(); | 88 payment_app_managers_.clear(); |
| 97 payment_app_database_.reset(); | 89 payment_app_database_.reset(); |
| 98 } | 90 } |
| 99 | 91 |
| 100 void PaymentAppContextImpl::DidShutdown() { | 92 void PaymentAppContextImpl::DidShutdown() { |
| 101 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 93 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 102 | 94 |
| 103 is_shutdown_ = true; | 95 is_shutdown_ = true; |
| 104 } | 96 } |
| 105 | 97 |
| 106 void PaymentAppContextImpl::GetAllManifestsOnIO( | |
| 107 const GetAllManifestsCallback& callback) { | |
| 108 DCHECK_CURRENTLY_ON(BrowserThread::IO); | |
| 109 payment_app_database()->ReadAllManifests(base::Bind( | |
| 110 &PaymentAppContextImpl::DidGetAllManifestsOnIO, this, callback)); | |
| 111 } | |
| 112 | |
| 113 void PaymentAppContextImpl::DidGetAllManifestsOnIO( | |
| 114 const GetAllManifestsCallback& callback, | |
| 115 Manifests manifests) { | |
| 116 DCHECK_CURRENTLY_ON(BrowserThread::IO); | |
| 117 | |
| 118 BrowserThread::PostTask( | |
| 119 BrowserThread::UI, FROM_HERE, | |
| 120 base::Bind(callback, base::Passed(std::move(manifests)))); | |
| 121 } | |
| 122 | |
| 123 } // namespace content | 98 } // namespace content |
| OLD | NEW |