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

Unified Diff: content/browser/payments/payment_app_context.cc

Issue 2476343002: PaymentApp: Initial implementation for PaymentAppManager.setManifest(). (Closed)
Patch Set: PaymentApp: Initial implementation for PaymentAppManager.setManifest(). 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/payments/payment_app_context.cc
diff --git a/content/browser/payments/payment_app_context.cc b/content/browser/payments/payment_app_context.cc
new file mode 100644
index 0000000000000000000000000000000000000000..3c34cdf3a9a6cf837e712c5d7704b4435d3977fc
--- /dev/null
+++ b/content/browser/payments/payment_app_context.cc
@@ -0,0 +1,66 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "content/browser/payments/payment_app_context.h"
+
+#include "base/bind.h"
+#include "base/memory/ptr_util.h"
+#include "base/stl_util.h"
+#include "content/browser/payments/payment_app_manager.h"
+#include "content/browser/service_worker/service_worker_context_wrapper.h"
+#include "content/public/browser/browser_thread.h"
+
+namespace content {
+
+PaymentAppContext::PaymentAppContext() {
+ DCHECK_CURRENTLY_ON(BrowserThread::UI);
+}
+
+PaymentAppContext::~PaymentAppContext() {
+ DCHECK(services_.empty());
+}
+
+void PaymentAppContext::Init(
+ const scoped_refptr<ServiceWorkerContextWrapper>& context) {
+ DCHECK_CURRENTLY_ON(BrowserThread::UI);
+}
+
+void PaymentAppContext::Shutdown() {
+ DCHECK_CURRENTLY_ON(BrowserThread::UI);
+
+ BrowserThread::PostTask(BrowserThread::IO, FROM_HERE,
+ base::Bind(&PaymentAppContext::ShutdownOnIO, this));
+}
+
+void PaymentAppContext::CreateService(
+ mojo::InterfaceRequest<payments::mojom::PaymentAppManager> request) {
+ DCHECK_CURRENTLY_ON(BrowserThread::UI);
+
+ BrowserThread::PostTask(
+ BrowserThread::IO, FROM_HERE,
+ base::Bind(&PaymentAppContext::CreateServiceOnIOThread, this,
+ base::Passed(&request)));
+}
+
+void PaymentAppContext::ServiceHadConnectionError(PaymentAppManager* service) {
+ DCHECK_CURRENTLY_ON(BrowserThread::IO);
+ DCHECK(base::ContainsKey(services_, service));
+
+ services_.erase(service);
+}
+
+void PaymentAppContext::CreateServiceOnIOThread(
+ mojo::InterfaceRequest<payments::mojom::PaymentAppManager> request) {
+ DCHECK_CURRENTLY_ON(BrowserThread::IO);
+ PaymentAppManager* service = new PaymentAppManager(this, std::move(request));
+ services_[service] = base::WrapUnique(service);
jkarlin 2016/11/08 13:48:53 Prefer to use base::MakeUnique. Suggest: services
zino 2016/11/08 14:34:21 Sorry, I don't understand your comment exactly. D
jkarlin 2016/11/08 14:45:03 Ah, sorry, didn't notice that service was the key
+}
+
+void PaymentAppContext::ShutdownOnIO() {
+ DCHECK_CURRENTLY_ON(BrowserThread::IO);
+
+ services_.clear();
+}
+
+} // namespace content

Powered by Google App Engine
This is Rietveld 408576698