Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1171)

Unified Diff: content/browser/payments/payment_app_context_impl.cc

Issue 2572183002: PaymentApp: Introduce PaymentAppDatabase class. (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/browser/payments/payment_app_context_impl.cc
diff --git a/content/browser/payments/payment_app_context_impl.cc b/content/browser/payments/payment_app_context_impl.cc
index 7672a947c3f0b68341be0a899920c02280e51c43..e2a84e62b0b3c82fbefe36b17c76c714184fdf2e 100644
--- a/content/browser/payments/payment_app_context_impl.cc
+++ b/content/browser/payments/payment_app_context_impl.cc
@@ -9,20 +9,24 @@
#include "base/bind.h"
#include "base/memory/ptr_util.h"
#include "base/stl_util.h"
+#include "content/browser/payments/payment_app_database.h"
#include "content/browser/payments/payment_app_manager.h"
-#include "content/browser/service_worker/service_worker_context_wrapper.h"
#include "content/public/browser/browser_thread.h"
namespace content {
-PaymentAppContextImpl::PaymentAppContextImpl(
- scoped_refptr<ServiceWorkerContextWrapper> service_worker_context)
- : service_worker_context_(std::move(service_worker_context)) {
+PaymentAppContextImpl::PaymentAppContextImpl() {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
}
-PaymentAppContextImpl::~PaymentAppContextImpl() {
- DCHECK(services_.empty());
+void PaymentAppContextImpl::Init(
+ scoped_refptr<ServiceWorkerContextWrapper> service_worker_context) {
+ DCHECK_CURRENTLY_ON(BrowserThread::UI);
+
+ BrowserThread::PostTask(
+ BrowserThread::IO, FROM_HERE,
+ base::Bind(&PaymentAppContextImpl::CreatePaymentAppDatabaseOnIO, this,
+ service_worker_context));
}
void PaymentAppContextImpl::Shutdown() {
@@ -51,9 +55,8 @@ void PaymentAppContextImpl::ServiceHadConnectionError(
services_.erase(service);
}
-ServiceWorkerContextWrapper* PaymentAppContextImpl::service_worker_context()
- const {
- return service_worker_context_.get();
+PaymentAppDatabase* PaymentAppContextImpl::payment_app_database() const {
+ return payment_app_database_.get();
}
void PaymentAppContextImpl::GetAllManifests(
@@ -61,6 +64,18 @@ void PaymentAppContextImpl::GetAllManifests(
NOTIMPLEMENTED();
}
+PaymentAppContextImpl::~PaymentAppContextImpl() {
+ DCHECK(services_.empty());
+ DCHECK(!payment_app_database_);
+}
+
+void PaymentAppContextImpl::CreatePaymentAppDatabaseOnIO(
+ scoped_refptr<ServiceWorkerContextWrapper> service_worker_context) {
+ DCHECK_CURRENTLY_ON(BrowserThread::IO);
+ payment_app_database_ =
+ base::WrapUnique(new PaymentAppDatabase(service_worker_context));
Avi (use Gerrit) 2016/12/14 17:10:11 MakeUnique unless there is some reason you can't u
zino 2016/12/14 17:27:41 Done.
+}
+
void PaymentAppContextImpl::CreateServiceOnIOThread(
mojo::InterfaceRequest<payments::mojom::PaymentAppManager> request) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
@@ -72,6 +87,7 @@ void PaymentAppContextImpl::ShutdownOnIO() {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
services_.clear();
+ payment_app_database_.reset();
}
} // namespace content
« no previous file with comments | « content/browser/payments/payment_app_context_impl.h ('k') | content/browser/payments/payment_app_database.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698