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

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

Issue 2497983002: PaymentApp: Implement PaymentAppManager.setManifest(). (Closed)
Patch Set: rebase Created 4 years, 1 month 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.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 PaymentAppContext::PaymentAppContext(
19 scoped_refptr<ServiceWorkerContextWrapper> service_worker_context)
20 : service_worker_context_(std::move(service_worker_context)) {
19 DCHECK_CURRENTLY_ON(BrowserThread::UI); 21 DCHECK_CURRENTLY_ON(BrowserThread::UI);
20 } 22 }
21 23
22 PaymentAppContext::~PaymentAppContext() { 24 PaymentAppContext::~PaymentAppContext() {
23 DCHECK(services_.empty()); 25 DCHECK(services_.empty());
24 } 26 }
25 27
26 void PaymentAppContext::Init(
27 scoped_refptr<ServiceWorkerContextWrapper> context) {
28 DCHECK_CURRENTLY_ON(BrowserThread::UI);
29 }
30
31 void PaymentAppContext::Shutdown() { 28 void PaymentAppContext::Shutdown() {
32 DCHECK_CURRENTLY_ON(BrowserThread::UI); 29 DCHECK_CURRENTLY_ON(BrowserThread::UI);
33 30
34 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, 31 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE,
35 base::Bind(&PaymentAppContext::ShutdownOnIO, this)); 32 base::Bind(&PaymentAppContext::ShutdownOnIO, this));
36 } 33 }
37 34
38 void PaymentAppContext::CreateService( 35 void PaymentAppContext::CreateService(
39 mojo::InterfaceRequest<payments::mojom::PaymentAppManager> request) { 36 mojo::InterfaceRequest<payments::mojom::PaymentAppManager> request) {
40 DCHECK_CURRENTLY_ON(BrowserThread::UI); 37 DCHECK_CURRENTLY_ON(BrowserThread::UI);
41 38
42 BrowserThread::PostTask( 39 BrowserThread::PostTask(
43 BrowserThread::IO, FROM_HERE, 40 BrowserThread::IO, FROM_HERE,
44 base::Bind(&PaymentAppContext::CreateServiceOnIOThread, this, 41 base::Bind(&PaymentAppContext::CreateServiceOnIOThread, this,
45 base::Passed(&request))); 42 base::Passed(&request)));
46 } 43 }
47 44
48 void PaymentAppContext::ServiceHadConnectionError(PaymentAppManager* service) { 45 void PaymentAppContext::ServiceHadConnectionError(PaymentAppManager* service) {
49 DCHECK_CURRENTLY_ON(BrowserThread::IO); 46 DCHECK_CURRENTLY_ON(BrowserThread::IO);
50 DCHECK(base::ContainsKey(services_, service)); 47 DCHECK(base::ContainsKey(services_, service));
51 48
52 services_.erase(service); 49 services_.erase(service);
53 } 50 }
54 51
52 ServiceWorkerContextWrapper* PaymentAppContext::service_worker_context() const {
53 return service_worker_context_.get();
54 }
55
55 void PaymentAppContext::CreateServiceOnIOThread( 56 void PaymentAppContext::CreateServiceOnIOThread(
56 mojo::InterfaceRequest<payments::mojom::PaymentAppManager> request) { 57 mojo::InterfaceRequest<payments::mojom::PaymentAppManager> request) {
57 DCHECK_CURRENTLY_ON(BrowserThread::IO); 58 DCHECK_CURRENTLY_ON(BrowserThread::IO);
58 PaymentAppManager* service = new PaymentAppManager(this, std::move(request)); 59 PaymentAppManager* service = new PaymentAppManager(this, std::move(request));
59 services_[service] = base::WrapUnique(service); 60 services_[service] = base::WrapUnique(service);
60 } 61 }
61 62
62 void PaymentAppContext::ShutdownOnIO() { 63 void PaymentAppContext::ShutdownOnIO() {
63 DCHECK_CURRENTLY_ON(BrowserThread::IO); 64 DCHECK_CURRENTLY_ON(BrowserThread::IO);
64 65
65 services_.clear(); 66 services_.clear();
66 } 67 }
67 68
68 } // namespace content 69 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/payments/payment_app_context.h ('k') | content/browser/payments/payment_app_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698