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

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

Issue 2560293002: PaymentApp: Introduce PaymentAppDatabase class. (Closed)
Patch Set: PaymentApp: Introduce PaymentAppDatabase class. 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 #ifndef CONTENT_BROWSER_PAYMENTS_PAYMENT_APP_CONTEXT_H_ 5 #ifndef CONTENT_BROWSER_PAYMENTS_PAYMENT_APP_CONTEXT_IMPL_H_
6 #define CONTENT_BROWSER_PAYMENTS_PAYMENT_APP_CONTEXT_H_ 6 #define CONTENT_BROWSER_PAYMENTS_PAYMENT_APP_CONTEXT_IMPL_H_
7 7
8 #include <map> 8 #include <map>
9 #include <memory> 9 #include <memory>
10 10
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/memory/ref_counted.h" 12 #include "base/memory/ref_counted.h"
13 #include "components/payments/payment_app.mojom.h" 13 #include "components/payments/payment_app.mojom.h"
14 #include "content/browser/payments/payment_app_database.h"
14 #include "content/common/content_export.h" 15 #include "content/common/content_export.h"
16 #include "content/public/browser/payment_app_context.h"
15 17
16 namespace content { 18 namespace content {
17 19
18 class PaymentAppManager; 20 class PaymentAppManager;
19 class ServiceWorkerContextWrapper;
20 21
21 class CONTENT_EXPORT PaymentAppContext 22 class CONTENT_EXPORT PaymentAppContextImpl
22 : public base::RefCountedThreadSafe<PaymentAppContext> { 23 : NON_EXPORTED_BASE(public PaymentAppContext),
24 public base::RefCountedThreadSafe<PaymentAppContextImpl> {
23 public: 25 public:
24 explicit PaymentAppContext( 26 PaymentAppContextImpl();
25 scoped_refptr<ServiceWorkerContextWrapper> service_worker_context); 27
28 // Init and Shutdown are for use on the UI thread when the
29 // StoragePartition is being setup and torn down.
30 void Init(scoped_refptr<ServiceWorkerContextWrapper> service_worker_context);
26 31
27 // Shutdown must be called before deleting this. Call on the UI thread. 32 // Shutdown must be called before deleting this. Call on the UI thread.
28 void Shutdown(); 33 void Shutdown();
29 34
30 // Create a PaymentAppManager that is owned by this. Call on the UI 35 // Create a PaymentAppManager that is owned by this. Call on the UI
31 // thread. 36 // thread.
32 void CreateService( 37 void CreateService(
33 mojo::InterfaceRequest<payments::mojom::PaymentAppManager> request); 38 mojo::InterfaceRequest<payments::mojom::PaymentAppManager> request);
34 39
35 // Called by PaymentAppManager objects so that they can 40 // Called by PaymentAppManager objects so that they can
36 // be deleted. Call on the IO thread. 41 // be deleted. Call on the IO thread.
37 void ServiceHadConnectionError(PaymentAppManager* service); 42 void ServiceHadConnectionError(PaymentAppManager* service);
38 43
39 ServiceWorkerContextWrapper* service_worker_context() const; 44 PaymentAppDatabase* payment_app_database() const;
45
46 void GetAllManifests(const GetAllManifestsCallback& callback) override;
40 47
41 protected: 48 protected:
42 friend class base::RefCountedThreadSafe<PaymentAppContext>; 49 friend class base::RefCountedThreadSafe<PaymentAppContextImpl>;
43 friend class PaymentAppManagerTest; 50 friend class PaymentAppManagerTest;
44 virtual ~PaymentAppContext(); 51 virtual ~PaymentAppContextImpl();
45 52
46 private: 53 private:
54 void CreatePaymentAppDatabaseOnIO(
55 scoped_refptr<ServiceWorkerContextWrapper> service_worker_context);
56
47 void CreateServiceOnIOThread( 57 void CreateServiceOnIOThread(
48 mojo::InterfaceRequest<payments::mojom::PaymentAppManager> request); 58 mojo::InterfaceRequest<payments::mojom::PaymentAppManager> request);
49 59
50 void ShutdownOnIO(); 60 void ShutdownOnIO();
51 61
52 scoped_refptr<ServiceWorkerContextWrapper> service_worker_context_; 62 // Only accessed on the IO thread.
63 std::unique_ptr<PaymentAppDatabase> payment_app_database_;
53 64
54 // The services are owned by this. They're either deleted 65 // The services are owned by this. They're either deleted
55 // during ShutdownOnIO or when the channel is closed via 66 // during ShutdownOnIO or when the channel is closed via
56 // ServiceHadConnectionError. Only accessed on the IO thread. 67 // ServiceHadConnectionError. Only accessed on the IO thread.
57 std::map<PaymentAppManager*, std::unique_ptr<PaymentAppManager>> services_; 68 std::map<PaymentAppManager*, std::unique_ptr<PaymentAppManager>> services_;
58 69
59 DISALLOW_COPY_AND_ASSIGN(PaymentAppContext); 70 DISALLOW_COPY_AND_ASSIGN(PaymentAppContextImpl);
60 }; 71 };
61 72
62 } // namespace content 73 } // namespace content
63 74
64 #endif // CONTENT_BROWSER_PAYMENTS_PAYMENT_APP_CONTEXT_H_ 75 #endif // CONTENT_BROWSER_PAYMENTS_PAYMENT_APP_CONTEXT_IMPL_H_
OLDNEW
« no previous file with comments | « content/browser/payments/payment_app_context.cc ('k') | content/browser/payments/payment_app_context_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698