| 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 10 matching lines...) Expand all Loading... |
| 21 | 21 |
| 22 class ServiceWorkerRegistration; | 22 class ServiceWorkerRegistration; |
| 23 | 23 |
| 24 class CONTENT_EXPORT PaymentAppDatabase { | 24 class CONTENT_EXPORT PaymentAppDatabase { |
| 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 = |
| 32 std::pair<int64_t, payments::mojom::PaymentAppManifestPtr>; |
| 33 using Manifests = std::vector<ManifestWithID>; |
| 34 using ReadAllManifestsCallback = base::Callback<void(Manifests)>; |
| 31 | 35 |
| 32 explicit PaymentAppDatabase( | 36 explicit PaymentAppDatabase( |
| 33 scoped_refptr<ServiceWorkerContextWrapper> service_worker_context); | 37 scoped_refptr<ServiceWorkerContextWrapper> service_worker_context); |
| 34 ~PaymentAppDatabase(); | 38 ~PaymentAppDatabase(); |
| 35 | 39 |
| 36 void WriteManifest(const GURL& scope, | 40 void WriteManifest(const GURL& scope, |
| 37 payments::mojom::PaymentAppManifestPtr manifest, | 41 payments::mojom::PaymentAppManifestPtr manifest, |
| 38 const WriteManifestCallback& callback); | 42 const WriteManifestCallback& callback); |
| 39 void ReadManifest(const GURL& scope, const ReadManifestCallback& callback); | 43 void ReadManifest(const GURL& scope, const ReadManifestCallback& callback); |
| 44 void ReadAllManifests(const ReadAllManifestsCallback& callback); |
| 40 | 45 |
| 41 private: | 46 private: |
| 42 // WriteManifest callbacks | 47 // WriteManifest callbacks |
| 43 void DidFindRegistrationToWriteManifest( | 48 void DidFindRegistrationToWriteManifest( |
| 44 payments::mojom::PaymentAppManifestPtr manifest, | 49 payments::mojom::PaymentAppManifestPtr manifest, |
| 45 const WriteManifestCallback& callback, | 50 const WriteManifestCallback& callback, |
| 46 ServiceWorkerStatusCode status, | 51 ServiceWorkerStatusCode status, |
| 47 scoped_refptr<ServiceWorkerRegistration> registration); | 52 scoped_refptr<ServiceWorkerRegistration> registration); |
| 48 void DidWriteManifest(const WriteManifestCallback& callback, | 53 void DidWriteManifest(const WriteManifestCallback& callback, |
| 49 ServiceWorkerStatusCode status); | 54 ServiceWorkerStatusCode status); |
| 50 | 55 |
| 51 // ReadManifest callbacks | 56 // ReadManifest callbacks |
| 52 void DidFindRegistrationToReadManifest( | 57 void DidFindRegistrationToReadManifest( |
| 53 const ReadManifestCallback& callback, | 58 const ReadManifestCallback& callback, |
| 54 ServiceWorkerStatusCode status, | 59 ServiceWorkerStatusCode status, |
| 55 scoped_refptr<ServiceWorkerRegistration> registration); | 60 scoped_refptr<ServiceWorkerRegistration> registration); |
| 56 void DidReadManifest(const ReadManifestCallback& callback, | 61 void DidReadManifest(const ReadManifestCallback& callback, |
| 57 const std::vector<std::string>& data, | 62 const std::vector<std::string>& data, |
| 58 ServiceWorkerStatusCode status); | 63 ServiceWorkerStatusCode status); |
| 59 | 64 |
| 65 // ReadAllManifests callbacks |
| 66 void DidReadAllManifests( |
| 67 const ReadAllManifestsCallback& callback, |
| 68 const std::vector<std::pair<int64_t, std::string>>& raw_data, |
| 69 ServiceWorkerStatusCode status); |
| 70 |
| 60 scoped_refptr<ServiceWorkerContextWrapper> service_worker_context_; | 71 scoped_refptr<ServiceWorkerContextWrapper> service_worker_context_; |
| 61 base::WeakPtrFactory<PaymentAppDatabase> weak_ptr_factory_; | 72 base::WeakPtrFactory<PaymentAppDatabase> weak_ptr_factory_; |
| 62 | 73 |
| 63 DISALLOW_COPY_AND_ASSIGN(PaymentAppDatabase); | 74 DISALLOW_COPY_AND_ASSIGN(PaymentAppDatabase); |
| 64 }; | 75 }; |
| 65 | 76 |
| 66 } // namespace content | 77 } // namespace content |
| 67 | 78 |
| 68 #endif // CONTENT_BROWSER_PAYMENTS_PAYMENT_APP_DATABASE_H_ | 79 #endif // CONTENT_BROWSER_PAYMENTS_PAYMENT_APP_DATABASE_H_ |
| OLD | NEW |