Chromium Code Reviews| Index: components/payments/content/payment_manifest_parser_host.h |
| diff --git a/components/payments/content/android/payment_manifest_parser_android.h b/components/payments/content/payment_manifest_parser_host.h |
| similarity index 35% |
| copy from components/payments/content/android/payment_manifest_parser_android.h |
| copy to components/payments/content/payment_manifest_parser_host.h |
| index 0b6250af74a27a514a2c4e4463280f749b5d4e8a..0e10cf947150a183d710519a683f811d7b346b12 100644 |
| --- a/components/payments/content/android/payment_manifest_parser_android.h |
| +++ b/components/payments/content/payment_manifest_parser_host.h |
| @@ -2,18 +2,15 @@ |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| -#ifndef COMPONENTS_PAYMENTS_CONTENT_ANDROID_PAYMENT_MANIFEST_PARSER_ANDROID_H_ |
| -#define COMPONENTS_PAYMENTS_CONTENT_ANDROID_PAYMENT_MANIFEST_PARSER_ANDROID_H_ |
| - |
| -#include <jni.h> |
| +#ifndef COMPONENTS_PAYMENTS_CONTENT_PAYMENT_MANIFEST_PARSER_HOST_H_ |
| +#define COMPONENTS_PAYMENTS_CONTENT_PAYMENT_MANIFEST_PARSER_HOST_H_ |
| #include <memory> |
| #include <vector> |
| -#include "base/android/jni_android.h" |
| -#include "base/android/scoped_java_ref.h" |
| +#include "base/callback_forward.h" |
| #include "base/macros.h" |
| -#include "components/payments/content/android/payment_manifest_parser.mojom.h" |
| +#include "components/payments/content/payment_manifest_parser.mojom.h" |
| namespace content { |
| template <class MojoInterface> |
| @@ -23,30 +20,27 @@ class UtilityProcessMojoClient; |
| namespace payments { |
| // Host of the utility process that parses manifest contents. |
| -class PaymentManifestParserAndroid { |
| +class PaymentManifestParserHost { |
| public: |
| - PaymentManifestParserAndroid(); |
| - ~PaymentManifestParserAndroid(); |
| + // Called on successful parsing. The result is a move-only vector, which is |
| + // empty on parse failure. |
| + using Callback = |
| + base::OnceCallback<void(std::vector<mojom::PaymentManifestSectionPtr>)>; |
| - void StartUtilityProcess(JNIEnv* env, |
| - const base::android::JavaParamRef<jobject>& jcaller); |
| + PaymentManifestParserHost(); |
|
Mathieu
2017/03/21 20:18:12
Does this need to be here?
please use gerrit instead
2017/03/21 20:34:51
Where do you propose to put it? This place seems s
|
| - void ParsePaymentManifest( |
| - JNIEnv* env, |
| - const base::android::JavaParamRef<jobject>& jcaller, |
| - const base::android::JavaParamRef<jstring>& jcontent, |
| - const base::android::JavaParamRef<jobject>& jcallback); |
| + // Stops the utility process. |
| + ~PaymentManifestParserHost(); |
| - // Deletes this object. |
| - void StopUtilityProcess(JNIEnv* env, |
| - const base::android::JavaParamRef<jobject>& jcaller); |
| + // Starts the utility process. |
|
Mathieu
2017/03/21 20:18:12
Mention that it may have long startup time and sho
please use gerrit instead
2017/03/21 20:34:51
Done.
|
| + void StartUtilityProcess(); |
| - private: |
| - class ParseCallback; |
| + void ParsePaymentManifest(const std::string& content, Callback callback); |
| - // The |callback_identifier| parameter is a pointer to one of the owned |
| - // elements in the |pending_callbacks_| list. |
| - void OnParse(ParseCallback* callback_identifier, |
| + private: |
| + // The |callback_identifier| parameter is a pointer to one of the items in the |
| + // |pending_callbacks_| list. |
| + void OnParse(const Callback* callback_identifier, |
| std::vector<mojom::PaymentManifestSectionPtr> manifest); |
| void OnUtilityProcessStopped(); |
| @@ -54,13 +48,12 @@ class PaymentManifestParserAndroid { |
| std::unique_ptr< |
| content::UtilityProcessMojoClient<mojom::PaymentManifestParser>> |
| mojo_client_; |
| - std::vector<std::unique_ptr<ParseCallback>> pending_callbacks_; |
| - DISALLOW_COPY_AND_ASSIGN(PaymentManifestParserAndroid); |
| -}; |
| + std::vector<Callback> pending_callbacks_; |
|
Mathieu
2017/03/21 20:18:12
Have you looked into base/callback_list.h?
https:
please use gerrit instead
2017/03/21 20:34:52
CallbackList works with base::Callback, which is c
|
| -bool RegisterPaymentManifestParser(JNIEnv* env); |
| + DISALLOW_COPY_AND_ASSIGN(PaymentManifestParserHost); |
| +}; |
| } // namespace payments |
| -#endif // COMPONENTS_PAYMENTS_CONTENT_ANDROID_PAYMENT_MANIFEST_PARSER_ANDROID_H_ |
| +#endif // COMPONENTS_PAYMENTS_CONTENT_PAYMENT_MANIFEST_PARSER_HOST_H_ |