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

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

Issue 2476343002: PaymentApp: Initial implementation for PaymentAppManager.setManifest(). (Closed)
Patch Set: fix lint error 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
(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.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_manager.h"
13 #include "content/browser/service_worker/service_worker_context_wrapper.h"
14 #include "content/public/browser/browser_thread.h"
15
16 namespace content {
17
18 PaymentAppContext::PaymentAppContext() {
19 DCHECK_CURRENTLY_ON(BrowserThread::UI);
20 }
21
22 PaymentAppContext::~PaymentAppContext() {
23 DCHECK(services_.empty());
24 }
25
26 void PaymentAppContext::Init(
27 scoped_refptr<ServiceWorkerContextWrapper> context) {
28 DCHECK_CURRENTLY_ON(BrowserThread::UI);
29 }
30
31 void PaymentAppContext::Shutdown() {
32 DCHECK_CURRENTLY_ON(BrowserThread::UI);
33
34 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE,
35 base::Bind(&PaymentAppContext::ShutdownOnIO, this));
36 }
37
38 void PaymentAppContext::CreateService(
39 mojo::InterfaceRequest<payments::mojom::PaymentAppManager> request) {
40 DCHECK_CURRENTLY_ON(BrowserThread::UI);
41
42 BrowserThread::PostTask(
43 BrowserThread::IO, FROM_HERE,
44 base::Bind(&PaymentAppContext::CreateServiceOnIOThread, this,
45 base::Passed(&request)));
46 }
47
48 void PaymentAppContext::ServiceHadConnectionError(PaymentAppManager* service) {
49 DCHECK_CURRENTLY_ON(BrowserThread::IO);
50 DCHECK(base::ContainsKey(services_, service));
51
52 services_.erase(service);
53 }
54
55 void PaymentAppContext::CreateServiceOnIOThread(
56 mojo::InterfaceRequest<payments::mojom::PaymentAppManager> request) {
57 DCHECK_CURRENTLY_ON(BrowserThread::IO);
58 PaymentAppManager* service = new PaymentAppManager(this, std::move(request));
59 services_[service] = base::WrapUnique(service);
60 }
61
62 void PaymentAppContext::ShutdownOnIO() {
63 DCHECK_CURRENTLY_ON(BrowserThread::IO);
64
65 services_.clear();
66 }
67
68 } // 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