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

Unified Diff: content/browser/payments/payment_app_context_impl.h

Issue 2572183002: PaymentApp: Introduce PaymentAppDatabase class. (Closed)
Patch Set: rebase 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/browser/BUILD.gn ('k') | content/browser/payments/payment_app_context_impl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/payments/payment_app_context_impl.h
diff --git a/content/browser/payments/payment_app_context_impl.h b/content/browser/payments/payment_app_context_impl.h
index e3fd583411246f14e923d58e5ef95e23f0cd6b8e..824b5c27a7a5cd7f0e8216cfc961e720f49feaa6 100644
--- a/content/browser/payments/payment_app_context_impl.h
+++ b/content/browser/payments/payment_app_context_impl.h
@@ -16,29 +16,54 @@
namespace content {
+class PaymentAppDatabase;
class PaymentAppManager;
class ServiceWorkerContextWrapper;
+// One instance of this exists per StoragePartition, and services multiple child
+// processes/origins. Most logic is delegated to the owned PaymentAppDatabase
+// instance, which is only accessed on the IO thread.
+//
+// This class is created/destructed by StoragePartitionImpl on UI thread.
+// However, the PaymentAppDatabase that this class has internally should work on
+// IO thread. So, this class has Init() and Shutdown() methods in addition to
+// constructor and destructor. They should be called explicitly when creating
+// and destroying StoragePartitionImpl.
+//
+// Expected order of lifetime calls:
+// 1) Constructor
+// 2) Init()
+// 3) Can now call other public methods in this class in any order.
+// - Can call CreatePaymentAppManager() on UI thread.
+// - Can call GetAllManifests() on UI thread.
+// - Can call PaymentAppManagerHadConnectionError() on IO thread.
+// - Can call payment_app_database() on IO thread.
+// 4) Shutdown()
+// 5) Destructor
class CONTENT_EXPORT PaymentAppContextImpl
: public base::RefCountedThreadSafe<PaymentAppContextImpl>,
NON_EXPORTED_BASE(public PaymentAppContext) {
public:
- explicit PaymentAppContextImpl(
- scoped_refptr<ServiceWorkerContextWrapper> service_worker_context);
+ PaymentAppContextImpl();
+
+ // Init and Shutdown are for use on the UI thread when the
+ // StoragePartition is being setup and torn down.
+ void Init(scoped_refptr<ServiceWorkerContextWrapper> service_worker_context);
// Shutdown must be called before deleting this. Call on the UI thread.
void Shutdown();
// Create a PaymentAppManager that is owned by this. Call on the UI
// thread.
- void CreateService(
+ void CreatePaymentAppManager(
mojo::InterfaceRequest<payments::mojom::PaymentAppManager> request);
// Called by PaymentAppManager objects so that they can
// be deleted. Call on the IO thread.
- void ServiceHadConnectionError(PaymentAppManager* service);
+ void PaymentAppManagerHadConnectionError(PaymentAppManager* service);
- ServiceWorkerContextWrapper* service_worker_context() const;
+ // Should be accessed only on the IO thread.
+ PaymentAppDatabase* payment_app_database() const;
// PaymentAppContext implementation:
void GetAllManifests(const GetAllManifestsCallback& callback) override;
@@ -50,17 +75,26 @@ class CONTENT_EXPORT PaymentAppContextImpl
friend class base::RefCountedThreadSafe<PaymentAppContextImpl>;
~PaymentAppContextImpl() override;
- void CreateServiceOnIOThread(
+ void CreatePaymentAppDatabaseOnIO(
+ scoped_refptr<ServiceWorkerContextWrapper> service_worker_context);
+
+ void CreatePaymentAppManagerOnIO(
mojo::InterfaceRequest<payments::mojom::PaymentAppManager> request);
void ShutdownOnIO();
+ void DidShutdown();
+
+ // Only accessed on the IO thread.
+ std::unique_ptr<PaymentAppDatabase> payment_app_database_;
- scoped_refptr<ServiceWorkerContextWrapper> service_worker_context_;
+ // The PaymentAppManagers are owned by this. They're either deleted during
+ // ShutdownOnIO or when the channel is closed via
+ // PaymentAppManagerHadConnectionError. Only accessed on the IO thread.
+ std::map<PaymentAppManager*, std::unique_ptr<PaymentAppManager>>
+ payment_app_managers_;
- // The services are owned by this. They're either deleted
- // during ShutdownOnIO or when the channel is closed via
- // ServiceHadConnectionError. Only accessed on the IO thread.
- std::map<PaymentAppManager*, std::unique_ptr<PaymentAppManager>> services_;
+ // Only accessed on the UI thread.
+ bool is_shutdown_;
DISALLOW_COPY_AND_ASSIGN(PaymentAppContextImpl);
};
« no previous file with comments | « content/browser/BUILD.gn ('k') | content/browser/payments/payment_app_context_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698