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 DeletePaymentInstrumentCallback = |
| 36 base::OnceCallback<void(payments::mojom::PaymentHandlerStatus)>; |
35 using ReadPaymentInstrumentCallback = | 37 using ReadPaymentInstrumentCallback = |
36 base::OnceCallback<void(payments::mojom::PaymentInstrumentPtr, | 38 base::OnceCallback<void(payments::mojom::PaymentInstrumentPtr, |
37 payments::mojom::PaymentHandlerStatus)>; | 39 payments::mojom::PaymentHandlerStatus)>; |
38 using WritePaymentInstrumentCallback = | 40 using WritePaymentInstrumentCallback = |
39 base::OnceCallback<void(payments::mojom::PaymentHandlerStatus)>; | 41 base::OnceCallback<void(payments::mojom::PaymentHandlerStatus)>; |
40 | 42 |
41 explicit PaymentAppDatabase( | 43 explicit PaymentAppDatabase( |
42 scoped_refptr<ServiceWorkerContextWrapper> service_worker_context); | 44 scoped_refptr<ServiceWorkerContextWrapper> service_worker_context); |
43 ~PaymentAppDatabase(); | 45 ~PaymentAppDatabase(); |
44 | 46 |
45 void WriteManifest(const GURL& scope, | 47 void WriteManifest(const GURL& scope, |
46 payments::mojom::PaymentAppManifestPtr manifest, | 48 payments::mojom::PaymentAppManifestPtr manifest, |
47 const WriteManifestCallback& callback); | 49 const WriteManifestCallback& callback); |
48 void ReadManifest(const GURL& scope, const ReadManifestCallback& callback); | 50 void ReadManifest(const GURL& scope, const ReadManifestCallback& callback); |
49 void ReadAllManifests(const ReadAllManifestsCallback& callback); | 51 void ReadAllManifests(const ReadAllManifestsCallback& callback); |
| 52 void DeletePaymentInstrument(const GURL& scope, |
| 53 const std::string& instrument_key, |
| 54 DeletePaymentInstrumentCallback callback); |
50 void ReadPaymentInstrument(const GURL& scope, | 55 void ReadPaymentInstrument(const GURL& scope, |
51 const std::string& instrumentKey, | 56 const std::string& instrument_key, |
52 ReadPaymentInstrumentCallback callback); | 57 ReadPaymentInstrumentCallback callback); |
53 void WritePaymentInstrument(const GURL& scope, | 58 void WritePaymentInstrument(const GURL& scope, |
54 const std::string& instrumentKey, | 59 const std::string& instrument_key, |
55 payments::mojom::PaymentInstrumentPtr instrument, | 60 payments::mojom::PaymentInstrumentPtr instrument, |
56 WritePaymentInstrumentCallback callback); | 61 WritePaymentInstrumentCallback callback); |
57 | 62 |
58 private: | 63 private: |
59 // WriteManifest callbacks | 64 // WriteManifest callbacks |
60 void DidFindRegistrationToWriteManifest( | 65 void DidFindRegistrationToWriteManifest( |
61 payments::mojom::PaymentAppManifestPtr manifest, | 66 payments::mojom::PaymentAppManifestPtr manifest, |
62 const WriteManifestCallback& callback, | 67 const WriteManifestCallback& callback, |
63 ServiceWorkerStatusCode status, | 68 ServiceWorkerStatusCode status, |
64 scoped_refptr<ServiceWorkerRegistration> registration); | 69 scoped_refptr<ServiceWorkerRegistration> registration); |
65 void DidWriteManifest(const WriteManifestCallback& callback, | 70 void DidWriteManifest(const WriteManifestCallback& callback, |
66 ServiceWorkerStatusCode status); | 71 ServiceWorkerStatusCode status); |
67 | 72 |
68 // ReadManifest callbacks | 73 // ReadManifest callbacks |
69 void DidFindRegistrationToReadManifest( | 74 void DidFindRegistrationToReadManifest( |
70 const ReadManifestCallback& callback, | 75 const ReadManifestCallback& callback, |
71 ServiceWorkerStatusCode status, | 76 ServiceWorkerStatusCode status, |
72 scoped_refptr<ServiceWorkerRegistration> registration); | 77 scoped_refptr<ServiceWorkerRegistration> registration); |
73 void DidReadManifest(const ReadManifestCallback& callback, | 78 void DidReadManifest(const ReadManifestCallback& callback, |
74 const std::vector<std::string>& data, | 79 const std::vector<std::string>& data, |
75 ServiceWorkerStatusCode status); | 80 ServiceWorkerStatusCode status); |
76 | 81 |
77 // ReadAllManifests callbacks | 82 // ReadAllManifests callbacks |
78 void DidReadAllManifests( | 83 void DidReadAllManifests( |
79 const ReadAllManifestsCallback& callback, | 84 const ReadAllManifestsCallback& callback, |
80 const std::vector<std::pair<int64_t, std::string>>& raw_data, | 85 const std::vector<std::pair<int64_t, std::string>>& raw_data, |
81 ServiceWorkerStatusCode status); | 86 ServiceWorkerStatusCode status); |
82 | 87 |
| 88 // DeletePaymentInstrument callbacks |
| 89 void DidFindRegistrationToDeletePaymentInstrument( |
| 90 const std::string& instrument_key, |
| 91 DeletePaymentInstrumentCallback callback, |
| 92 ServiceWorkerStatusCode status, |
| 93 scoped_refptr<ServiceWorkerRegistration> registration); |
| 94 void DidFindPaymentInstrument(int64_t registration_id, |
| 95 const std::string& instrument_key, |
| 96 DeletePaymentInstrumentCallback callback, |
| 97 const std::vector<std::string>& data, |
| 98 ServiceWorkerStatusCode status); |
| 99 void DidDeletePaymentInstrument(DeletePaymentInstrumentCallback callback, |
| 100 ServiceWorkerStatusCode status); |
| 101 |
83 // ReadPaymentInstrument callbacks | 102 // ReadPaymentInstrument callbacks |
84 void DidFindRegistrationToReadPaymentInstrument( | 103 void DidFindRegistrationToReadPaymentInstrument( |
85 const std::string& instrumentKey, | 104 const std::string& instrument_key, |
86 ReadPaymentInstrumentCallback callback, | 105 ReadPaymentInstrumentCallback callback, |
87 ServiceWorkerStatusCode status, | 106 ServiceWorkerStatusCode status, |
88 scoped_refptr<ServiceWorkerRegistration> registration); | 107 scoped_refptr<ServiceWorkerRegistration> registration); |
89 void DidReadPaymentInstrument(ReadPaymentInstrumentCallback callback, | 108 void DidReadPaymentInstrument(ReadPaymentInstrumentCallback callback, |
90 const std::vector<std::string>& data, | 109 const std::vector<std::string>& data, |
91 ServiceWorkerStatusCode status); | 110 ServiceWorkerStatusCode status); |
92 | 111 |
93 // WritePaymentInstrument callbacks | 112 // WritePaymentInstrument callbacks |
94 void DidFindRegistrationToWritePaymentInstrument( | 113 void DidFindRegistrationToWritePaymentInstrument( |
95 const std::string& instrumentKey, | 114 const std::string& instrument_key, |
96 payments::mojom::PaymentInstrumentPtr instrument, | 115 payments::mojom::PaymentInstrumentPtr instrument, |
97 WritePaymentInstrumentCallback callback, | 116 WritePaymentInstrumentCallback callback, |
98 ServiceWorkerStatusCode status, | 117 ServiceWorkerStatusCode status, |
99 scoped_refptr<ServiceWorkerRegistration> registration); | 118 scoped_refptr<ServiceWorkerRegistration> registration); |
100 void DidWritePaymentInstrument(WritePaymentInstrumentCallback callback, | 119 void DidWritePaymentInstrument(WritePaymentInstrumentCallback callback, |
101 ServiceWorkerStatusCode status); | 120 ServiceWorkerStatusCode status); |
102 | 121 |
103 scoped_refptr<ServiceWorkerContextWrapper> service_worker_context_; | 122 scoped_refptr<ServiceWorkerContextWrapper> service_worker_context_; |
104 base::WeakPtrFactory<PaymentAppDatabase> weak_ptr_factory_; | 123 base::WeakPtrFactory<PaymentAppDatabase> weak_ptr_factory_; |
105 | 124 |
106 DISALLOW_COPY_AND_ASSIGN(PaymentAppDatabase); | 125 DISALLOW_COPY_AND_ASSIGN(PaymentAppDatabase); |
107 }; | 126 }; |
108 | 127 |
109 } // namespace content | 128 } // namespace content |
110 | 129 |
111 #endif // CONTENT_BROWSER_PAYMENTS_PAYMENT_APP_DATABASE_H_ | 130 #endif // CONTENT_BROWSER_PAYMENTS_PAYMENT_APP_DATABASE_H_ |
OLD | NEW |