| OLD | NEW |
| 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_ANDROID_PAYMENT_MANIFEST_PARSER_ANDROID_H_ | 5 #ifndef COMPONENTS_PAYMENTS_CONTENT_ANDROID_PAYMENT_MANIFEST_PARSER_ANDROID_H_ |
| 6 #define COMPONENTS_PAYMENTS_CONTENT_ANDROID_PAYMENT_MANIFEST_PARSER_ANDROID_H_ | 6 #define COMPONENTS_PAYMENTS_CONTENT_ANDROID_PAYMENT_MANIFEST_PARSER_ANDROID_H_ |
| 7 | 7 |
| 8 #include <jni.h> | 8 #include <jni.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "base/android/jni_android.h" | 13 #include "base/android/jni_android.h" |
| 14 #include "base/android/scoped_java_ref.h" | 14 #include "base/android/scoped_java_ref.h" |
| 15 #include "base/macros.h" | 15 #include "base/macros.h" |
| 16 #include "components/payments/content/android/payment_manifest_parser.mojom.h" | 16 #include "components/payments/content/payment_manifest_parser_host.h" |
| 17 | |
| 18 namespace content { | |
| 19 template <class MojoInterface> | |
| 20 class UtilityProcessMojoClient; | |
| 21 } | |
| 22 | 17 |
| 23 namespace payments { | 18 namespace payments { |
| 24 | 19 |
| 25 // Host of the utility process that parses manifest contents. | 20 // Android wrapper for the host of the utility process that parses manifest |
| 21 // contents. |
| 26 class PaymentManifestParserAndroid { | 22 class PaymentManifestParserAndroid { |
| 27 public: | 23 public: |
| 28 PaymentManifestParserAndroid(); | 24 PaymentManifestParserAndroid(); |
| 29 ~PaymentManifestParserAndroid(); | 25 ~PaymentManifestParserAndroid(); |
| 30 | 26 |
| 31 void StartUtilityProcess(JNIEnv* env, | 27 void StartUtilityProcess(JNIEnv* env, |
| 32 const base::android::JavaParamRef<jobject>& jcaller); | 28 const base::android::JavaParamRef<jobject>& jcaller); |
| 33 | 29 |
| 34 void ParsePaymentManifest( | 30 void ParsePaymentManifest( |
| 35 JNIEnv* env, | 31 JNIEnv* env, |
| 36 const base::android::JavaParamRef<jobject>& jcaller, | 32 const base::android::JavaParamRef<jobject>& jcaller, |
| 37 const base::android::JavaParamRef<jstring>& jcontent, | 33 const base::android::JavaParamRef<jstring>& jcontent, |
| 38 const base::android::JavaParamRef<jobject>& jcallback); | 34 const base::android::JavaParamRef<jobject>& jcallback); |
| 39 | 35 |
| 40 // Deletes this object. | 36 // Deletes this object. |
| 41 void StopUtilityProcess(JNIEnv* env, | 37 void StopUtilityProcess(JNIEnv* env, |
| 42 const base::android::JavaParamRef<jobject>& jcaller); | 38 const base::android::JavaParamRef<jobject>& jcaller); |
| 43 | 39 |
| 44 private: | 40 private: |
| 45 class ParseCallback; | 41 PaymentManifestParserHost host_; |
| 46 | |
| 47 // The |callback_identifier| parameter is a pointer to one of the owned | |
| 48 // elements in the |pending_callbacks_| list. | |
| 49 void OnParse(ParseCallback* callback_identifier, | |
| 50 std::vector<mojom::PaymentManifestSectionPtr> manifest); | |
| 51 | |
| 52 void OnUtilityProcessStopped(); | |
| 53 | |
| 54 std::unique_ptr< | |
| 55 content::UtilityProcessMojoClient<mojom::PaymentManifestParser>> | |
| 56 mojo_client_; | |
| 57 std::vector<std::unique_ptr<ParseCallback>> pending_callbacks_; | |
| 58 | 42 |
| 59 DISALLOW_COPY_AND_ASSIGN(PaymentManifestParserAndroid); | 43 DISALLOW_COPY_AND_ASSIGN(PaymentManifestParserAndroid); |
| 60 }; | 44 }; |
| 61 | 45 |
| 62 bool RegisterPaymentManifestParser(JNIEnv* env); | 46 bool RegisterPaymentManifestParser(JNIEnv* env); |
| 63 | 47 |
| 64 } // namespace payments | 48 } // namespace payments |
| 65 | 49 |
| 66 #endif // COMPONENTS_PAYMENTS_CONTENT_ANDROID_PAYMENT_MANIFEST_PARSER_ANDROID_H
_ | 50 #endif // COMPONENTS_PAYMENTS_CONTENT_ANDROID_PAYMENT_MANIFEST_PARSER_ANDROID_H
_ |
| OLD | NEW |