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

Side by Side Diff: content/browser/payments/payment_app_context_impl.cc

Issue 2560293002: 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 unified diff | Download patch
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "content/browser/payments/payment_app_context_impl.h"
6
7 #include <utility>
8
9 #include "base/bind.h"
10 #include "base/memory/ptr_util.h"
11 #include "base/stl_util.h"
12 #include "content/browser/payments/payment_app_database.h"
13 #include "content/browser/payments/payment_app_manager.h"
14 #include "content/public/browser/browser_thread.h"
15
16 namespace content {
17
18 PaymentAppContextImpl::PaymentAppContextImpl() {
19 DCHECK_CURRENTLY_ON(BrowserThread::UI);
20 }
21
22 void PaymentAppContextImpl::Init(
23 scoped_refptr<ServiceWorkerContextWrapper> service_worker_context) {
24 DCHECK_CURRENTLY_ON(BrowserThread::UI);
25
26 BrowserThread::PostTask(
27 BrowserThread::IO, FROM_HERE,
28 base::Bind(&PaymentAppContextImpl::CreatePaymentAppDatabaseOnIO, this,
29 service_worker_context));
30 }
31
32 void PaymentAppContextImpl::Shutdown() {
33 DCHECK_CURRENTLY_ON(BrowserThread::UI);
34
35 BrowserThread::PostTask(
36 BrowserThread::IO, FROM_HERE,
37 base::Bind(&PaymentAppContextImpl::ShutdownOnIO, this));
38 }
39
40 void PaymentAppContextImpl::CreateService(
41 mojo::InterfaceRequest<payments::mojom::PaymentAppManager> request) {
42 DCHECK_CURRENTLY_ON(BrowserThread::UI);
43
44 BrowserThread::PostTask(
45 BrowserThread::IO, FROM_HERE,
46 base::Bind(&PaymentAppContextImpl::CreateServiceOnIOThread, this,
47 base::Passed(&request)));
48 }
49
50 void PaymentAppContextImpl::ServiceHadConnectionError(
51 PaymentAppManager* service) {
52 DCHECK_CURRENTLY_ON(BrowserThread::IO);
53 DCHECK(base::ContainsKey(services_, service));
54
55 services_.erase(service);
56 }
57
58 PaymentAppDatabase* PaymentAppContextImpl::payment_app_database() const {
59 return payment_app_database_.get();
60 }
61
62 void PaymentAppContextImpl::GetAllManifests(
63 const GetAllManifestsCallback& callback) {
64 NOTIMPLEMENTED();
65 }
66
67 PaymentAppContextImpl::~PaymentAppContextImpl() {
68 DCHECK(services_.empty());
69 }
70
71 void PaymentAppContextImpl::CreatePaymentAppDatabaseOnIO(
72 scoped_refptr<ServiceWorkerContextWrapper> service_worker_context) {
73 DCHECK_CURRENTLY_ON(BrowserThread::IO);
74 payment_app_database_ =
75 base::WrapUnique(new PaymentAppDatabase(service_worker_context));
76 }
77
78 void PaymentAppContextImpl::CreateServiceOnIOThread(
79 mojo::InterfaceRequest<payments::mojom::PaymentAppManager> request) {
80 DCHECK_CURRENTLY_ON(BrowserThread::IO);
81 PaymentAppManager* service = new PaymentAppManager(this, std::move(request));
82 services_[service] = base::WrapUnique(service);
83 }
84
85 void PaymentAppContextImpl::ShutdownOnIO() {
86 DCHECK_CURRENTLY_ON(BrowserThread::IO);
87
88 services_.clear();
89 }
90
91 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698