OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 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/payments/payment_app_provider_impl.h" |
| 6 |
| 7 #include "content/browser/payments/payment_app_context_impl.h" |
| 8 #include "content/browser/storage_partition_impl.h" |
| 9 #include "content/public/browser/browser_context.h" |
| 10 #include "content/public/browser/browser_thread.h" |
| 11 |
| 12 namespace content { |
| 13 namespace { |
| 14 |
| 15 void DidGetAllManifestsOnIO( |
| 16 const PaymentAppProvider::GetAllManifestsCallback& callback, |
| 17 PaymentAppProvider::Manifests manifests) { |
| 18 BrowserThread::PostTask( |
| 19 BrowserThread::UI, FROM_HERE, |
| 20 base::Bind(callback, base::Passed(std::move(manifests)))); |
| 21 } |
| 22 |
| 23 void GetAllManifestsOnIO( |
| 24 const scoped_refptr<PaymentAppContextImpl>& payment_app_context, |
| 25 const PaymentAppProvider::GetAllManifestsCallback& callback) { |
| 26 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 27 |
| 28 payment_app_context->payment_app_database()->ReadAllManifests( |
| 29 base::Bind(&DidGetAllManifestsOnIO, callback)); |
| 30 } |
| 31 |
| 32 } // namespace |
| 33 |
| 34 // static |
| 35 PaymentAppProvider* PaymentAppProvider::GetInstance() { |
| 36 return PaymentAppProviderImpl::GetInstance(); |
| 37 } |
| 38 |
| 39 // static |
| 40 PaymentAppProviderImpl* PaymentAppProviderImpl::GetInstance() { |
| 41 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 42 return base::Singleton<PaymentAppProviderImpl>::get(); |
| 43 } |
| 44 |
| 45 void PaymentAppProviderImpl::GetAllManifests( |
| 46 BrowserContext* browser_context, |
| 47 const GetAllManifestsCallback& callback) { |
| 48 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 49 |
| 50 StoragePartitionImpl* partition = static_cast<StoragePartitionImpl*>( |
| 51 BrowserContext::GetDefaultStoragePartition(browser_context)); |
| 52 scoped_refptr<PaymentAppContextImpl> payment_app_context = |
| 53 partition->GetPaymentAppContext(); |
| 54 |
| 55 BrowserThread::PostTask( |
| 56 BrowserThread::IO, FROM_HERE, |
| 57 base::Bind(&GetAllManifestsOnIO, payment_app_context, callback)); |
| 58 } |
| 59 |
| 60 PaymentAppProviderImpl::PaymentAppProviderImpl() {} |
| 61 |
| 62 PaymentAppProviderImpl::~PaymentAppProviderImpl() {} |
| 63 |
| 64 } // namespace content |
OLD | NEW |