Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(454)

Side by Side Diff: components/payments/content/payment_manifest_parser_host.h

Issue 2802043002: Use web-app manifest format for Android payment apps. (Closed)
Patch Set: Address java comments. Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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 COMPONENTS_PAYMENTS_CONTENT_PAYMENT_MANIFEST_PARSER_HOST_H_ 5 #ifndef COMPONENTS_PAYMENTS_CONTENT_PAYMENT_MANIFEST_PARSER_HOST_H_
6 #define COMPONENTS_PAYMENTS_CONTENT_PAYMENT_MANIFEST_PARSER_HOST_H_ 6 #define COMPONENTS_PAYMENTS_CONTENT_PAYMENT_MANIFEST_PARSER_HOST_H_
7 7
8 #include <stdint.h>
9
8 #include <memory> 10 #include <memory>
11 #include <unordered_map>
9 #include <vector> 12 #include <vector>
10 13
11 #include "base/callback_forward.h" 14 #include "base/callback_forward.h"
12 #include "base/macros.h" 15 #include "base/macros.h"
13 #include "components/payments/content/payment_manifest_parser.mojom.h" 16 #include "components/payments/content/payment_manifest_parser.mojom.h"
17 #include "url/gurl.h"
14 18
15 namespace content { 19 namespace content {
16 template <class MojoInterface> 20 template <class MojoInterface>
17 class UtilityProcessMojoClient; 21 class UtilityProcessMojoClient;
18 } 22 }
19 23
20 namespace payments { 24 namespace payments {
21 25
22 // Host of the utility process that parses manifest contents. 26 // Host of the utility process that parses manifest contents.
23 class PaymentManifestParserHost { 27 class PaymentManifestParserHost {
24 public: 28 public:
25 // Called on successful parsing. The result is a move-only vector, which is 29 // Called on successful parsing of a payment method manifest. The result is a
26 // empty on parse failure. 30 // move-only vector, which is empty on parse failure.
27 using Callback = 31 using PaymentMethodCallback = base::OnceCallback<void(std::vector<GURL>)>;
28 base::OnceCallback<void(std::vector<mojom::PaymentManifestSectionPtr>)>; 32 // Called on successful parsing of a web app manifest. The result is a
33 // move-only vector, which is empty on parse failure.
34 using WebAppCallback =
35 base::OnceCallback<void(std::vector<mojom::WebAppManifestSectionPtr>)>;
29 36
30 PaymentManifestParserHost(); 37 PaymentManifestParserHost();
31 38
32 // Stops the utility process. 39 // Stops the utility process.
33 ~PaymentManifestParserHost(); 40 ~PaymentManifestParserHost();
34 41
35 // Starts the utility process. This can take up to 2 seconds and should be 42 // Starts the utility process. This can take up to 2 seconds and should be
36 // done as soon as it is known that the parser will be needed. 43 // done as soon as it is known that the parser will be needed.
37 void StartUtilityProcess(); 44 void StartUtilityProcess();
38 45
39 void ParsePaymentManifest(const std::string& content, Callback callback); 46 void ParsePaymentMethodManifest(const std::string& content,
47 PaymentMethodCallback callback);
48 void ParseWebAppManifest(const std::string& content, WebAppCallback callback);
40 49
41 private: 50 private:
42 // The |callback_identifier| parameter is a pointer to one of the items in the 51 void OnPaymentMethodParse(int64_t callback_identifier,
43 // |pending_callbacks_| list. 52 const std::vector<GURL>& web_app_manifest_urls);
44 void OnParse(const Callback* callback_identifier, 53 void OnWebAppParse(int64_t callback_identifier,
45 std::vector<mojom::PaymentManifestSectionPtr> manifest); 54 std::vector<mojom::WebAppManifestSectionPtr> manifest);
46 55
47 void OnUtilityProcessStopped(); 56 void OnUtilityProcessStopped();
48 57
49 std::unique_ptr< 58 std::unique_ptr<
50 content::UtilityProcessMojoClient<mojom::PaymentManifestParser>> 59 content::UtilityProcessMojoClient<mojom::PaymentManifestParser>>
51 mojo_client_; 60 mojo_client_;
52 61
53 std::vector<Callback> pending_callbacks_; 62 int64_t callback_counter_;
63 std::unordered_map<int64_t, PaymentMethodCallback>
64 pending_payment_method_callbacks_;
65 std::unordered_map<int64_t, WebAppCallback> pending_web_app_callbacks_;
54 66
55 DISALLOW_COPY_AND_ASSIGN(PaymentManifestParserHost); 67 DISALLOW_COPY_AND_ASSIGN(PaymentManifestParserHost);
56 }; 68 };
57 69
58 } // namespace payments 70 } // namespace payments
59 71
60 #endif // COMPONENTS_PAYMENTS_CONTENT_PAYMENT_MANIFEST_PARSER_HOST_H_ 72 #endif // COMPONENTS_PAYMENTS_CONTENT_PAYMENT_MANIFEST_PARSER_HOST_H_
OLDNEW
« no previous file with comments | « components/payments/content/payment_manifest_parser.mojom ('k') | components/payments/content/payment_manifest_parser_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698