| 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_DATABASE_H_ | 5 #ifndef CONTENT_BROWSER_PAYMENTS_PAYMENT_APP_DATABASE_H_ |
| 6 #define CONTENT_BROWSER_PAYMENTS_PAYMENT_APP_DATABASE_H_ | 6 #define CONTENT_BROWSER_PAYMENTS_PAYMENT_APP_DATABASE_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 public: | 25 public: |
| 26 using WriteManifestCallback = | 26 using WriteManifestCallback = |
| 27 base::Callback<void(payments::mojom::PaymentAppManifestError)>; | 27 base::Callback<void(payments::mojom::PaymentAppManifestError)>; |
| 28 using ReadManifestCallback = | 28 using ReadManifestCallback = |
| 29 base::Callback<void(payments::mojom::PaymentAppManifestPtr, | 29 base::Callback<void(payments::mojom::PaymentAppManifestPtr, |
| 30 payments::mojom::PaymentAppManifestError)>; | 30 payments::mojom::PaymentAppManifestError)>; |
| 31 using ManifestWithID = | 31 using ManifestWithID = |
| 32 std::pair<int64_t, payments::mojom::PaymentAppManifestPtr>; | 32 std::pair<int64_t, payments::mojom::PaymentAppManifestPtr>; |
| 33 using Manifests = std::vector<ManifestWithID>; | 33 using Manifests = std::vector<ManifestWithID>; |
| 34 using ReadAllManifestsCallback = base::Callback<void(Manifests)>; | 34 using ReadAllManifestsCallback = base::Callback<void(Manifests)>; |
| 35 using ReadPaymentInstrumentCallback = |
| 36 base::OnceCallback<void(payments::mojom::PaymentInstrumentPtr, |
| 37 payments::mojom::PaymentHandlerStatus)>; |
| 38 using WritePaymentInstrumentCallback = |
| 39 base::OnceCallback<void(payments::mojom::PaymentHandlerStatus)>; |
| 35 | 40 |
| 36 explicit PaymentAppDatabase( | 41 explicit PaymentAppDatabase( |
| 37 scoped_refptr<ServiceWorkerContextWrapper> service_worker_context); | 42 scoped_refptr<ServiceWorkerContextWrapper> service_worker_context); |
| 38 ~PaymentAppDatabase(); | 43 ~PaymentAppDatabase(); |
| 39 | 44 |
| 40 void WriteManifest(const GURL& scope, | 45 void WriteManifest(const GURL& scope, |
| 41 payments::mojom::PaymentAppManifestPtr manifest, | 46 payments::mojom::PaymentAppManifestPtr manifest, |
| 42 const WriteManifestCallback& callback); | 47 const WriteManifestCallback& callback); |
| 43 void ReadManifest(const GURL& scope, const ReadManifestCallback& callback); | 48 void ReadManifest(const GURL& scope, const ReadManifestCallback& callback); |
| 44 void ReadAllManifests(const ReadAllManifestsCallback& callback); | 49 void ReadAllManifests(const ReadAllManifestsCallback& callback); |
| 50 void ReadPaymentInstrument(const GURL& scope, |
| 51 const std::string& instrumentKey, |
| 52 ReadPaymentInstrumentCallback callback); |
| 53 void WritePaymentInstrument(const GURL& scope, |
| 54 const std::string& instrumentKey, |
| 55 payments::mojom::PaymentInstrumentPtr instrument, |
| 56 WritePaymentInstrumentCallback callback); |
| 45 | 57 |
| 46 private: | 58 private: |
| 47 // WriteManifest callbacks | 59 // WriteManifest callbacks |
| 48 void DidFindRegistrationToWriteManifest( | 60 void DidFindRegistrationToWriteManifest( |
| 49 payments::mojom::PaymentAppManifestPtr manifest, | 61 payments::mojom::PaymentAppManifestPtr manifest, |
| 50 const WriteManifestCallback& callback, | 62 const WriteManifestCallback& callback, |
| 51 ServiceWorkerStatusCode status, | 63 ServiceWorkerStatusCode status, |
| 52 scoped_refptr<ServiceWorkerRegistration> registration); | 64 scoped_refptr<ServiceWorkerRegistration> registration); |
| 53 void DidWriteManifest(const WriteManifestCallback& callback, | 65 void DidWriteManifest(const WriteManifestCallback& callback, |
| 54 ServiceWorkerStatusCode status); | 66 ServiceWorkerStatusCode status); |
| 55 | 67 |
| 56 // ReadManifest callbacks | 68 // ReadManifest callbacks |
| 57 void DidFindRegistrationToReadManifest( | 69 void DidFindRegistrationToReadManifest( |
| 58 const ReadManifestCallback& callback, | 70 const ReadManifestCallback& callback, |
| 59 ServiceWorkerStatusCode status, | 71 ServiceWorkerStatusCode status, |
| 60 scoped_refptr<ServiceWorkerRegistration> registration); | 72 scoped_refptr<ServiceWorkerRegistration> registration); |
| 61 void DidReadManifest(const ReadManifestCallback& callback, | 73 void DidReadManifest(const ReadManifestCallback& callback, |
| 62 const std::vector<std::string>& data, | 74 const std::vector<std::string>& data, |
| 63 ServiceWorkerStatusCode status); | 75 ServiceWorkerStatusCode status); |
| 64 | 76 |
| 65 // ReadAllManifests callbacks | 77 // ReadAllManifests callbacks |
| 66 void DidReadAllManifests( | 78 void DidReadAllManifests( |
| 67 const ReadAllManifestsCallback& callback, | 79 const ReadAllManifestsCallback& callback, |
| 68 const std::vector<std::pair<int64_t, std::string>>& raw_data, | 80 const std::vector<std::pair<int64_t, std::string>>& raw_data, |
| 69 ServiceWorkerStatusCode status); | 81 ServiceWorkerStatusCode status); |
| 70 | 82 |
| 83 // ReadPaymentInstrument callbacks |
| 84 void DidFindRegistrationToReadPaymentInstrument( |
| 85 const std::string& instrumentKey, |
| 86 ReadPaymentInstrumentCallback callback, |
| 87 ServiceWorkerStatusCode status, |
| 88 scoped_refptr<ServiceWorkerRegistration> registration); |
| 89 void DidReadPaymentInstrument(ReadPaymentInstrumentCallback callback, |
| 90 const std::vector<std::string>& data, |
| 91 ServiceWorkerStatusCode status); |
| 92 |
| 93 // WritePaymentInstrument callbacks |
| 94 void DidFindRegistrationToWritePaymentInstrument( |
| 95 const std::string& instrumentKey, |
| 96 payments::mojom::PaymentInstrumentPtr instrument, |
| 97 WritePaymentInstrumentCallback callback, |
| 98 ServiceWorkerStatusCode status, |
| 99 scoped_refptr<ServiceWorkerRegistration> registration); |
| 100 void DidWritePaymentInstrument(WritePaymentInstrumentCallback callback, |
| 101 ServiceWorkerStatusCode status); |
| 102 |
| 71 scoped_refptr<ServiceWorkerContextWrapper> service_worker_context_; | 103 scoped_refptr<ServiceWorkerContextWrapper> service_worker_context_; |
| 72 base::WeakPtrFactory<PaymentAppDatabase> weak_ptr_factory_; | 104 base::WeakPtrFactory<PaymentAppDatabase> weak_ptr_factory_; |
| 73 | 105 |
| 74 DISALLOW_COPY_AND_ASSIGN(PaymentAppDatabase); | 106 DISALLOW_COPY_AND_ASSIGN(PaymentAppDatabase); |
| 75 }; | 107 }; |
| 76 | 108 |
| 77 } // namespace content | 109 } // namespace content |
| 78 | 110 |
| 79 #endif // CONTENT_BROWSER_PAYMENTS_PAYMENT_APP_DATABASE_H_ | 111 #endif // CONTENT_BROWSER_PAYMENTS_PAYMENT_APP_DATABASE_H_ |
| OLD | NEW |