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

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

Issue 2560293002: PaymentApp: Introduce PaymentAppDatabase class. (Closed)
Patch Set: PaymentApp: Introduce PaymentAppDatabase class. 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 DCHECK(!payment_app_database_);
70 }
71
72 void PaymentAppContextImpl::CreatePaymentAppDatabaseOnIO(
73 scoped_refptr<ServiceWorkerContextWrapper> service_worker_context) {
74 DCHECK_CURRENTLY_ON(BrowserThread::IO);
75 payment_app_database_ =
76 base::WrapUnique(new PaymentAppDatabase(service_worker_context));
77 }
78
79 void PaymentAppContextImpl::CreateServiceOnIOThread(
80 mojo::InterfaceRequest<payments::mojom::PaymentAppManager> request) {
81 DCHECK_CURRENTLY_ON(BrowserThread::IO);
82 PaymentAppManager* service = new PaymentAppManager(this, std::move(request));
83 services_[service] = base::WrapUnique(service);
84 }
85
86 void PaymentAppContextImpl::ShutdownOnIO() {
87 DCHECK_CURRENTLY_ON(BrowserThread::IO);
88
89 services_.clear();
90 payment_app_database_.reset();
91 }
92
93 } // namespace content
OLDNEW
« 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