Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/payment_app.mojom.h" | 13 #include "components/payments/payment_app.mojom.h" |
| 14 #include "content/browser/payments/payment_app_database.h" | |
|
please use gerrit instead
2016/12/14 19:44:00
Forward-declare instead?
zino
2016/12/15 17:56:52
Done.
| |
| 14 #include "content/common/content_export.h" | 15 #include "content/common/content_export.h" |
| 15 #include "content/public/browser/payment_app_context.h" | 16 #include "content/public/browser/payment_app_context.h" |
| 16 | 17 |
| 17 namespace content { | 18 namespace content { |
| 18 | 19 |
| 19 class PaymentAppManager; | 20 class PaymentAppManager; |
| 20 class ServiceWorkerContextWrapper; | 21 class ServiceWorkerContextWrapper; |
| 21 | 22 |
|
please use gerrit instead
2016/12/14 19:44:00
Add a class comment about the expected order of li
zino
2016/12/15 17:56:52
Done.
| |
| 22 class CONTENT_EXPORT PaymentAppContextImpl | 23 class CONTENT_EXPORT PaymentAppContextImpl |
| 23 : public base::RefCountedThreadSafe<PaymentAppContextImpl>, | 24 : public base::RefCountedThreadSafe<PaymentAppContextImpl>, |
| 24 NON_EXPORTED_BASE(public PaymentAppContext) { | 25 NON_EXPORTED_BASE(public PaymentAppContext) { |
| 25 public: | 26 public: |
| 26 explicit PaymentAppContextImpl( | 27 PaymentAppContextImpl(); |
| 27 scoped_refptr<ServiceWorkerContextWrapper> service_worker_context); | 28 |
| 29 // Init and Shutdown are for use on the UI thread when the | |
| 30 // StoragePartition is being setup and torn down. | |
| 31 void Init(scoped_refptr<ServiceWorkerContextWrapper> service_worker_context); | |
| 28 | 32 |
| 29 // Shutdown must be called before deleting this. Call on the UI thread. | 33 // Shutdown must be called before deleting this. Call on the UI thread. |
| 30 void Shutdown(); | 34 void Shutdown(); |
| 31 | 35 |
| 32 // Create a PaymentAppManager that is owned by this. Call on the UI | 36 // Create a PaymentAppManager that is owned by this. Call on the UI |
| 33 // thread. | 37 // thread. |
| 34 void CreateService( | 38 void CreateService( |
| 35 mojo::InterfaceRequest<payments::mojom::PaymentAppManager> request); | 39 mojo::InterfaceRequest<payments::mojom::PaymentAppManager> request); |
| 36 | 40 |
| 37 // Called by PaymentAppManager objects so that they can | 41 // Called by PaymentAppManager objects so that they can |
| 38 // be deleted. Call on the IO thread. | 42 // be deleted. Call on the IO thread. |
| 39 void ServiceHadConnectionError(PaymentAppManager* service); | 43 void ServiceHadConnectionError(PaymentAppManager* service); |
| 40 | 44 |
| 41 ServiceWorkerContextWrapper* service_worker_context() const; | 45 // Should be accessed only on the IO thread. |
| 46 PaymentAppDatabase* payment_app_database() const; | |
| 42 | 47 |
| 43 // PaymentAppContext implementation: | 48 // PaymentAppContext implementation: |
| 44 void GetAllManifests(const GetAllManifestsCallback& callback) override; | 49 void GetAllManifests(const GetAllManifestsCallback& callback) override; |
| 45 | 50 |
| 46 protected: | 51 protected: |
| 47 friend class PaymentAppManagerTest; | 52 friend class PaymentAppManagerTest; |
| 48 | 53 |
| 49 private: | 54 private: |
| 50 friend class base::RefCountedThreadSafe<PaymentAppContextImpl>; | 55 friend class base::RefCountedThreadSafe<PaymentAppContextImpl>; |
| 51 ~PaymentAppContextImpl() override; | 56 ~PaymentAppContextImpl() override; |
| 52 | 57 |
| 53 void CreateServiceOnIOThread( | 58 void CreatePaymentAppDatabaseOnIO( |
| 59 scoped_refptr<ServiceWorkerContextWrapper> service_worker_context); | |
| 60 | |
| 61 void CreateServiceOnIO( | |
| 54 mojo::InterfaceRequest<payments::mojom::PaymentAppManager> request); | 62 mojo::InterfaceRequest<payments::mojom::PaymentAppManager> request); |
| 55 | 63 |
| 56 void ShutdownOnIO(); | 64 void ShutdownOnIO(); |
| 57 | 65 |
| 58 scoped_refptr<ServiceWorkerContextWrapper> service_worker_context_; | 66 // Only accessed on the IO thread. |
| 67 std::unique_ptr<PaymentAppDatabase> payment_app_database_; | |
| 59 | 68 |
| 60 // The services are owned by this. They're either deleted | 69 // The services are owned by this. They're either deleted |
| 61 // during ShutdownOnIO or when the channel is closed via | 70 // during ShutdownOnIO or when the channel is closed via |
| 62 // ServiceHadConnectionError. Only accessed on the IO thread. | 71 // ServiceHadConnectionError. Only accessed on the IO thread. |
| 63 std::map<PaymentAppManager*, std::unique_ptr<PaymentAppManager>> services_; | 72 std::map<PaymentAppManager*, std::unique_ptr<PaymentAppManager>> services_; |
|
please use gerrit instead
2016/12/14 19:44:00
It's strange that "services_" is a collection of *
zino
2016/12/15 17:56:52
Done.
| |
| 64 | 73 |
| 65 DISALLOW_COPY_AND_ASSIGN(PaymentAppContextImpl); | 74 DISALLOW_COPY_AND_ASSIGN(PaymentAppContextImpl); |
| 66 }; | 75 }; |
| 67 | 76 |
| 68 } // namespace content | 77 } // namespace content |
| 69 | 78 |
| 70 #endif // CONTENT_BROWSER_PAYMENTS_PAYMENT_APP_CONTEXT_IMPL_H_ | 79 #endif // CONTENT_BROWSER_PAYMENTS_PAYMENT_APP_CONTEXT_IMPL_H_ |
| OLD | NEW |