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

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

Issue 2575583003: PaymentApp: Add a interface to query all payment app manifests. (Closed)
Patch Set: PaymentApp: Add a interface to query all payment app manifests. 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
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.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"
11 #include "base/stl_util.h" 11 #include "base/stl_util.h"
12 #include "content/browser/payments/payment_app_manager.h" 12 #include "content/browser/payments/payment_app_manager.h"
13 #include "content/browser/service_worker/service_worker_context_wrapper.h" 13 #include "content/browser/service_worker/service_worker_context_wrapper.h"
14 #include "content/public/browser/browser_thread.h" 14 #include "content/public/browser/browser_thread.h"
15 15
16 namespace content { 16 namespace content {
17 17
18 PaymentAppContext::PaymentAppContext( 18 PaymentAppContextImpl::PaymentAppContextImpl(
19 scoped_refptr<ServiceWorkerContextWrapper> service_worker_context) 19 scoped_refptr<ServiceWorkerContextWrapper> service_worker_context)
20 : service_worker_context_(std::move(service_worker_context)) { 20 : service_worker_context_(std::move(service_worker_context)) {
21 DCHECK_CURRENTLY_ON(BrowserThread::UI); 21 DCHECK_CURRENTLY_ON(BrowserThread::UI);
22 } 22 }
23 23
24 PaymentAppContext::~PaymentAppContext() { 24 void PaymentAppContextImpl::Shutdown() {
25 DCHECK(services_.empty()); 25 DCHECK_CURRENTLY_ON(BrowserThread::UI);
26
27 BrowserThread::PostTask(
28 BrowserThread::IO, FROM_HERE,
29 base::Bind(&PaymentAppContextImpl::ShutdownOnIO, this));
26 } 30 }
27 31
28 void PaymentAppContext::Shutdown() { 32 void PaymentAppContextImpl::CreateService(
29 DCHECK_CURRENTLY_ON(BrowserThread::UI);
30
31 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE,
32 base::Bind(&PaymentAppContext::ShutdownOnIO, this));
33 }
34
35 void PaymentAppContext::CreateService(
36 mojo::InterfaceRequest<payments::mojom::PaymentAppManager> request) { 33 mojo::InterfaceRequest<payments::mojom::PaymentAppManager> request) {
37 DCHECK_CURRENTLY_ON(BrowserThread::UI); 34 DCHECK_CURRENTLY_ON(BrowserThread::UI);
38 35
39 BrowserThread::PostTask( 36 BrowserThread::PostTask(
40 BrowserThread::IO, FROM_HERE, 37 BrowserThread::IO, FROM_HERE,
41 base::Bind(&PaymentAppContext::CreateServiceOnIOThread, this, 38 base::Bind(&PaymentAppContextImpl::CreateServiceOnIOThread, this,
42 base::Passed(&request))); 39 base::Passed(&request)));
43 } 40 }
44 41
45 void PaymentAppContext::ServiceHadConnectionError(PaymentAppManager* service) { 42 void PaymentAppContextImpl::ServiceHadConnectionError(
43 PaymentAppManager* service) {
46 DCHECK_CURRENTLY_ON(BrowserThread::IO); 44 DCHECK_CURRENTLY_ON(BrowserThread::IO);
47 DCHECK(base::ContainsKey(services_, service)); 45 DCHECK(base::ContainsKey(services_, service));
48 46
49 services_.erase(service); 47 services_.erase(service);
50 } 48 }
51 49
52 ServiceWorkerContextWrapper* PaymentAppContext::service_worker_context() const { 50 ServiceWorkerContextWrapper* PaymentAppContextImpl::service_worker_context()
51 const {
53 return service_worker_context_.get(); 52 return service_worker_context_.get();
54 } 53 }
55 54
56 void PaymentAppContext::CreateServiceOnIOThread( 55 void PaymentAppContextImpl::GetAllManifests(
56 const GetAllManifestsCallback& callback) {
57 NOTIMPLEMENTED();
58 }
59
60 PaymentAppContextImpl::~PaymentAppContextImpl() {
61 DCHECK(services_.empty());
62 }
63
64 void PaymentAppContextImpl::CreateServiceOnIOThread(
57 mojo::InterfaceRequest<payments::mojom::PaymentAppManager> request) { 65 mojo::InterfaceRequest<payments::mojom::PaymentAppManager> request) {
58 DCHECK_CURRENTLY_ON(BrowserThread::IO); 66 DCHECK_CURRENTLY_ON(BrowserThread::IO);
59 PaymentAppManager* service = new PaymentAppManager(this, std::move(request)); 67 PaymentAppManager* service = new PaymentAppManager(this, std::move(request));
60 services_[service] = base::WrapUnique(service); 68 services_[service] = base::WrapUnique(service);
61 } 69 }
62 70
63 void PaymentAppContext::ShutdownOnIO() { 71 void PaymentAppContextImpl::ShutdownOnIO() {
64 DCHECK_CURRENTLY_ON(BrowserThread::IO); 72 DCHECK_CURRENTLY_ON(BrowserThread::IO);
65 73
66 services_.clear(); 74 services_.clear();
67 } 75 }
68 76
69 } // namespace content 77 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/payments/payment_app_context_impl.h ('k') | content/browser/payments/payment_app_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698