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

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

Issue 2785523003: PaymentHandler: Rename PaymentAppManager to PaymentManager. (Closed)
Patch Set: PaymentHandler: Rename PaymentAppManager to PaymentManager. Created 3 years, 8 months 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_IMPL_H_ 5 #ifndef CONTENT_BROWSER_PAYMENTS_PAYMENT_APP_CONTEXT_IMPL_H_
6 #define CONTENT_BROWSER_PAYMENTS_PAYMENT_APP_CONTEXT_IMPL_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/content/payment_app.mojom.h" 13 #include "components/payments/content/payment_app.mojom.h"
14 #include "content/browser/payments/payment_app_database.h" 14 #include "content/browser/payments/payment_app_database.h"
15 #include "content/common/content_export.h" 15 #include "content/common/content_export.h"
16 16
17 namespace content { 17 namespace content {
18 18
19 class PaymentAppDatabase; 19 class PaymentAppDatabase;
20 class PaymentAppManager; 20 class PaymentManager;
21 class ServiceWorkerContextWrapper; 21 class ServiceWorkerContextWrapper;
22 22
23 // One instance of this exists per StoragePartition, and services multiple child 23 // One instance of this exists per StoragePartition, and services multiple child
24 // processes/origins. Most logic is delegated to the owned PaymentAppDatabase 24 // processes/origins. Most logic is delegated to the owned PaymentAppDatabase
25 // instance, which is only accessed on the IO thread. 25 // instance, which is only accessed on the IO thread.
26 // 26 //
27 // This class is created/destructed by StoragePartitionImpl on UI thread. 27 // This class is created/destructed by StoragePartitionImpl on UI thread.
28 // However, the PaymentAppDatabase that this class has internally should work on 28 // However, the PaymentAppDatabase that this class has internally should work on
29 // IO thread. So, this class has Init() and Shutdown() methods in addition to 29 // IO thread. So, this class has Init() and Shutdown() methods in addition to
30 // constructor and destructor. They should be called explicitly when creating 30 // constructor and destructor. They should be called explicitly when creating
31 // and destroying StoragePartitionImpl. 31 // and destroying StoragePartitionImpl.
32 // 32 //
33 // Expected order of lifetime calls: 33 // Expected order of lifetime calls:
34 // 1) Constructor 34 // 1) Constructor
35 // 2) Init() 35 // 2) Init()
36 // 3) Can now call other public methods in this class in any order. 36 // 3) Can now call other public methods in this class in any order.
37 // - Can call CreatePaymentAppManager() on UI thread. 37 // - Can call CreatePaymentManager() on UI thread.
38 // - Can call GetAllManifests() on UI thread. 38 // - Can call GetAllManifests() on UI thread.
39 // - Can call PaymentAppManagerHadConnectionError() on IO thread. 39 // - Can call PaymentManagerHadConnectionError() on IO thread.
40 // - Can call payment_app_database() on IO thread. 40 // - Can call payment_app_database() on IO thread.
41 // 4) Shutdown() 41 // 4) Shutdown()
42 // 5) Destructor 42 // 5) Destructor
43 class CONTENT_EXPORT PaymentAppContextImpl 43 class CONTENT_EXPORT PaymentAppContextImpl
44 : public base::RefCountedThreadSafe<PaymentAppContextImpl> { 44 : public base::RefCountedThreadSafe<PaymentAppContextImpl> {
45 public: 45 public:
46 PaymentAppContextImpl(); 46 PaymentAppContextImpl();
47 47
48 // Init and Shutdown are for use on the UI thread when the 48 // Init and Shutdown are for use on the UI thread when the
49 // StoragePartition is being setup and torn down. 49 // StoragePartition is being setup and torn down.
50 void Init(scoped_refptr<ServiceWorkerContextWrapper> service_worker_context); 50 void Init(scoped_refptr<ServiceWorkerContextWrapper> service_worker_context);
51 51
52 // Shutdown must be called before deleting this. Call on the UI thread. 52 // Shutdown must be called before deleting this. Call on the UI thread.
53 void Shutdown(); 53 void Shutdown();
54 54
55 // Create a PaymentAppManager that is owned by this. Call on the UI 55 // Create a PaymentManager that is owned by this. Call on the UI
56 // thread. 56 // thread.
57 void CreatePaymentAppManager( 57 void CreatePaymentManager(
58 mojo::InterfaceRequest<payments::mojom::PaymentAppManager> request); 58 mojo::InterfaceRequest<payments::mojom::PaymentManager> request);
59 59
60 // Called by PaymentAppManager objects so that they can 60 // Called by PaymentManager objects so that they can
61 // be deleted. Call on the IO thread. 61 // be deleted. Call on the IO thread.
62 void PaymentAppManagerHadConnectionError(PaymentAppManager* service); 62 void PaymentManagerHadConnectionError(PaymentManager* service);
63 63
64 // Should be accessed only on the IO thread. 64 // Should be accessed only on the IO thread.
65 PaymentAppDatabase* payment_app_database() const; 65 PaymentAppDatabase* payment_app_database() const;
66 66
67 private: 67 private:
68 friend class PaymentAppContentUnitTestBase; 68 friend class PaymentAppContentUnitTestBase;
69 friend class base::RefCountedThreadSafe<PaymentAppContextImpl>; 69 friend class base::RefCountedThreadSafe<PaymentAppContextImpl>;
70 ~PaymentAppContextImpl(); 70 ~PaymentAppContextImpl();
71 71
72 void CreatePaymentAppDatabaseOnIO( 72 void CreatePaymentAppDatabaseOnIO(
73 scoped_refptr<ServiceWorkerContextWrapper> service_worker_context); 73 scoped_refptr<ServiceWorkerContextWrapper> service_worker_context);
74 74
75 void CreatePaymentAppManagerOnIO( 75 void CreatePaymentManagerOnIO(
76 mojo::InterfaceRequest<payments::mojom::PaymentAppManager> request); 76 mojo::InterfaceRequest<payments::mojom::PaymentManager> request);
77 77
78 void ShutdownOnIO(); 78 void ShutdownOnIO();
79 void DidShutdown(); 79 void DidShutdown();
80 80
81 // Only accessed on the IO thread. 81 // Only accessed on the IO thread.
82 std::unique_ptr<PaymentAppDatabase> payment_app_database_; 82 std::unique_ptr<PaymentAppDatabase> payment_app_database_;
83 83
84 // The PaymentAppManagers are owned by this. They're either deleted during 84 // The PaymentManagers are owned by this. They're either deleted during
85 // ShutdownOnIO or when the channel is closed via 85 // ShutdownOnIO or when the channel is closed via
86 // PaymentAppManagerHadConnectionError. Only accessed on the IO thread. 86 // PaymentManagerHadConnectionError. Only accessed on the IO thread.
87 std::map<PaymentAppManager*, std::unique_ptr<PaymentAppManager>> 87 std::map<PaymentManager*, std::unique_ptr<PaymentManager>> payment_managers_;
88 payment_app_managers_;
89 88
90 // Only accessed on the UI thread. 89 // Only accessed on the UI thread.
91 bool is_shutdown_; 90 bool is_shutdown_;
92 91
93 DISALLOW_COPY_AND_ASSIGN(PaymentAppContextImpl); 92 DISALLOW_COPY_AND_ASSIGN(PaymentAppContextImpl);
94 }; 93 };
95 94
96 } // namespace content 95 } // namespace content
97 96
98 #endif // CONTENT_BROWSER_PAYMENTS_PAYMENT_APP_CONTEXT_IMPL_H_ 97 #endif // CONTENT_BROWSER_PAYMENTS_PAYMENT_APP_CONTEXT_IMPL_H_
OLDNEW
« no previous file with comments | « content/browser/payments/payment_app_content_unittest_base.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