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 |
11 #include "base/macros.h" | 11 #include "base/macros.h" |
12 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
13 #include "components/payments/content/payment_app.mojom.h" | 13 #include "components/payments/content/payment_app.mojom.h" |
14 #include "content/browser/service_worker/service_worker_context_wrapper.h" | 14 #include "content/browser/service_worker/service_worker_context_wrapper.h" |
15 #include "content/browser/service_worker/service_worker_registration.h" | 15 #include "content/browser/service_worker/service_worker_registration.h" |
16 #include "content/common/content_export.h" | 16 #include "content/common/content_export.h" |
17 #include "content/common/service_worker/service_worker_status_code.h" | 17 #include "content/common/service_worker/service_worker_status_code.h" |
18 #include "mojo/public/cpp/bindings/binding.h" | 18 #include "mojo/public/cpp/bindings/binding.h" |
19 | 19 |
20 using payments::mojom::PaymentHandlerStatus; | |
please use gerrit instead
2017/04/12 19:11:31
Please don't put such "using" statements in header
zino
2017/04/15 05:18:09
Done.
| |
21 using payments::mojom::PaymentInstrument; | |
22 using payments::mojom::PaymentInstrumentPtr; | |
23 | |
20 namespace content { | 24 namespace content { |
21 | 25 |
22 class ServiceWorkerRegistration; | 26 class ServiceWorkerRegistration; |
23 | 27 |
24 class CONTENT_EXPORT PaymentAppDatabase { | 28 class CONTENT_EXPORT PaymentAppDatabase { |
25 public: | 29 public: |
26 using WriteManifestCallback = | 30 using WriteManifestCallback = |
27 base::Callback<void(payments::mojom::PaymentAppManifestError)>; | 31 base::Callback<void(payments::mojom::PaymentAppManifestError)>; |
28 using ReadManifestCallback = | 32 using ReadManifestCallback = |
29 base::Callback<void(payments::mojom::PaymentAppManifestPtr, | 33 base::Callback<void(payments::mojom::PaymentAppManifestPtr, |
30 payments::mojom::PaymentAppManifestError)>; | 34 payments::mojom::PaymentAppManifestError)>; |
31 using ManifestWithID = | 35 using ManifestWithID = |
32 std::pair<int64_t, payments::mojom::PaymentAppManifestPtr>; | 36 std::pair<int64_t, payments::mojom::PaymentAppManifestPtr>; |
33 using Manifests = std::vector<ManifestWithID>; | 37 using Manifests = std::vector<ManifestWithID>; |
34 using ReadAllManifestsCallback = base::Callback<void(Manifests)>; | 38 using ReadAllManifestsCallback = base::Callback<void(Manifests)>; |
39 using ReadPaymentInstrumentCallback = | |
40 base::OnceCallback<void(PaymentInstrumentPtr, PaymentHandlerStatus)>; | |
41 using WritePaymentInstrumentCallback = | |
42 base::OnceCallback<void(PaymentHandlerStatus)>; | |
please use gerrit instead
2017/04/12 19:11:31
These "using" statements are OK, by the way.
| |
35 | 43 |
36 explicit PaymentAppDatabase( | 44 explicit PaymentAppDatabase( |
37 scoped_refptr<ServiceWorkerContextWrapper> service_worker_context); | 45 scoped_refptr<ServiceWorkerContextWrapper> service_worker_context); |
38 ~PaymentAppDatabase(); | 46 ~PaymentAppDatabase(); |
39 | 47 |
40 void WriteManifest(const GURL& scope, | 48 void WriteManifest(const GURL& scope, |
41 payments::mojom::PaymentAppManifestPtr manifest, | 49 payments::mojom::PaymentAppManifestPtr manifest, |
42 const WriteManifestCallback& callback); | 50 const WriteManifestCallback& callback); |
43 void ReadManifest(const GURL& scope, const ReadManifestCallback& callback); | 51 void ReadManifest(const GURL& scope, const ReadManifestCallback& callback); |
44 void ReadAllManifests(const ReadAllManifestsCallback& callback); | 52 void ReadAllManifests(const ReadAllManifestsCallback& callback); |
53 void ReadPaymentInstrument(const GURL& scope, | |
54 const std::string& instrumentKey, | |
55 ReadPaymentInstrumentCallback callback); | |
56 void WritePaymentInstrument(const GURL& scope, | |
57 const std::string& instrumentKey, | |
58 PaymentInstrumentPtr instrument, | |
59 WritePaymentInstrumentCallback callback); | |
45 | 60 |
46 private: | 61 private: |
47 // WriteManifest callbacks | 62 // WriteManifest callbacks |
48 void DidFindRegistrationToWriteManifest( | 63 void DidFindRegistrationToWriteManifest( |
49 payments::mojom::PaymentAppManifestPtr manifest, | 64 payments::mojom::PaymentAppManifestPtr manifest, |
50 const WriteManifestCallback& callback, | 65 const WriteManifestCallback& callback, |
51 ServiceWorkerStatusCode status, | 66 ServiceWorkerStatusCode status, |
52 scoped_refptr<ServiceWorkerRegistration> registration); | 67 scoped_refptr<ServiceWorkerRegistration> registration); |
53 void DidWriteManifest(const WriteManifestCallback& callback, | 68 void DidWriteManifest(const WriteManifestCallback& callback, |
54 ServiceWorkerStatusCode status); | 69 ServiceWorkerStatusCode status); |
55 | 70 |
56 // ReadManifest callbacks | 71 // ReadManifest callbacks |
57 void DidFindRegistrationToReadManifest( | 72 void DidFindRegistrationToReadManifest( |
58 const ReadManifestCallback& callback, | 73 const ReadManifestCallback& callback, |
59 ServiceWorkerStatusCode status, | 74 ServiceWorkerStatusCode status, |
60 scoped_refptr<ServiceWorkerRegistration> registration); | 75 scoped_refptr<ServiceWorkerRegistration> registration); |
61 void DidReadManifest(const ReadManifestCallback& callback, | 76 void DidReadManifest(const ReadManifestCallback& callback, |
62 const std::vector<std::string>& data, | 77 const std::vector<std::string>& data, |
63 ServiceWorkerStatusCode status); | 78 ServiceWorkerStatusCode status); |
64 | 79 |
65 // ReadAllManifests callbacks | 80 // ReadAllManifests callbacks |
66 void DidReadAllManifests( | 81 void DidReadAllManifests( |
67 const ReadAllManifestsCallback& callback, | 82 const ReadAllManifestsCallback& callback, |
68 const std::vector<std::pair<int64_t, std::string>>& raw_data, | 83 const std::vector<std::pair<int64_t, std::string>>& raw_data, |
69 ServiceWorkerStatusCode status); | 84 ServiceWorkerStatusCode status); |
70 | 85 |
86 // ReadPaymentInstrument callbacks | |
87 void DidFindRegistrationToReadPaymentInstrument( | |
88 const std::string& instrumentKey, | |
89 ReadPaymentInstrumentCallback callback, | |
90 ServiceWorkerStatusCode status, | |
91 scoped_refptr<ServiceWorkerRegistration> registration); | |
92 void DidReadPaymentInstrument(ReadPaymentInstrumentCallback callback, | |
93 const std::vector<std::string>& data, | |
94 ServiceWorkerStatusCode status); | |
95 | |
96 // WritePaymentInstrument callbacks | |
97 void DidFindRegistrationToWritePaymentInstrument( | |
98 const std::string& instrumentKey, | |
99 PaymentInstrumentPtr instrument, | |
100 WritePaymentInstrumentCallback callback, | |
101 ServiceWorkerStatusCode status, | |
102 scoped_refptr<ServiceWorkerRegistration> registration); | |
103 void DidWritePaymentInstrument(WritePaymentInstrumentCallback callback, | |
104 ServiceWorkerStatusCode status); | |
105 | |
71 scoped_refptr<ServiceWorkerContextWrapper> service_worker_context_; | 106 scoped_refptr<ServiceWorkerContextWrapper> service_worker_context_; |
72 base::WeakPtrFactory<PaymentAppDatabase> weak_ptr_factory_; | 107 base::WeakPtrFactory<PaymentAppDatabase> weak_ptr_factory_; |
73 | 108 |
74 DISALLOW_COPY_AND_ASSIGN(PaymentAppDatabase); | 109 DISALLOW_COPY_AND_ASSIGN(PaymentAppDatabase); |
75 }; | 110 }; |
76 | 111 |
77 } // namespace content | 112 } // namespace content |
78 | 113 |
79 #endif // CONTENT_BROWSER_PAYMENTS_PAYMENT_APP_DATABASE_H_ | 114 #endif // CONTENT_BROWSER_PAYMENTS_PAYMENT_APP_DATABASE_H_ |
OLD | NEW |