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

Side by Side Diff: components/payments/android/payments_jni_registrar.cc

Issue 2607063002: Remove mojo::Array. (Closed)
Patch Set: rebase Created 3 years, 11 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 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 #include "components/payments/android/payments_jni_registrar.h" 5 #include "components/payments/android/payments_jni_registrar.h"
6 6
7 #include <string> 7 #include <string>
8 #include <utility> 8 #include <utility>
9 9
10 #include "components/payments/payment_details_validation.h" 10 #include "components/payments/payment_details_validation.h"
11 #include "components/payments/payment_request.mojom.h" 11 #include "components/payments/payment_request.mojom.h"
12 #include "jni/PaymentValidator_jni.h" 12 #include "jni/PaymentValidator_jni.h"
13 13
14 namespace payments { 14 namespace payments {
15 15
16 jboolean ValidatePaymentDetails( 16 jboolean ValidatePaymentDetails(
17 JNIEnv* env, 17 JNIEnv* env,
18 const base::android::JavaParamRef<jclass>& jcaller, 18 const base::android::JavaParamRef<jclass>& jcaller,
19 const base::android::JavaParamRef<jobject>& buffer) { 19 const base::android::JavaParamRef<jobject>& buffer) {
20 jbyte* buf_in = static_cast<jbyte*>(env->GetDirectBufferAddress(buffer)); 20 jbyte* buf_in = static_cast<jbyte*>(env->GetDirectBufferAddress(buffer));
21 jlong buf_size = env->GetDirectBufferCapacity(buffer); 21 jlong buf_size = env->GetDirectBufferCapacity(buffer);
22 mojo::Array<uint8_t> mojo_buffer = mojo::Array<uint8_t>::New(buf_size); 22 std::vector<uint8_t> mojo_buffer(buf_size);
23 memcpy(&mojo_buffer[0], buf_in, buf_size); 23 memcpy(&mojo_buffer[0], buf_in, buf_size);
24 mojom::PaymentDetailsPtr details; 24 mojom::PaymentDetailsPtr details;
25 if (!mojom::PaymentDetails::Deserialize(std::move(mojo_buffer), &details)) 25 if (!mojom::PaymentDetails::Deserialize(std::move(mojo_buffer), &details))
26 return false; 26 return false;
27 std::string unused_error_message; 27 std::string unused_error_message;
28 return payments::validatePaymentDetails(details, &unused_error_message); 28 return payments::validatePaymentDetails(details, &unused_error_message);
29 } 29 }
30 30
31 } // namespace payments 31 } // namespace payments
32 32
33 bool RegisterPaymentValidator(JNIEnv* env) { 33 bool RegisterPaymentValidator(JNIEnv* env) {
34 return payments::RegisterNativesImpl(env); 34 return payments::RegisterNativesImpl(env);
35 } 35 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698