Chromium Code Reviews| Index: android_webview/native/aw_assets.cc |
| diff --git a/android_webview/native/aw_assets.cc b/android_webview/native/aw_assets.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..d592f0946b641bd48651a4bba7f74d94955c5d1d |
| --- /dev/null |
| +++ b/android_webview/native/aw_assets.cc |
| @@ -0,0 +1,39 @@ |
| +// Copyright 2014 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include <jni.h> |
| + |
| +#include "android_webview/native/aw_assets.h" |
| + |
| +#include "base/android/jni_string.h" |
| +#include "base/android/scoped_java_ref.h" |
| +#include "jni/AwAssets_jni.h" |
| + |
| +namespace android_webview { |
| +namespace AwAssets { |
| + |
| +bool OpenAsset(const std::string& filename, |
| + int* fd, |
| + int64* offset, |
| + int64* size) { |
| + JNIEnv* env = base::android::AttachCurrentThread(); |
| + ScopedJavaLocalRef<jlongArray> jarr = Java_AwAssets_OpenAsset( |
| + env, |
| + base::android::GetApplicationContext(), |
| + base::android::ConvertUTF8ToJavaString(env, filename).Release()); |
| + jlong* arr = env->GetLongArrayElements(jarr.obj(), NULL); |
|
mkosiba (inactive)
2014/07/18 05:49:05
maybe add a JavaLongArrayToLongVector helper funct
Primiano Tucci (use gerrit)
2014/07/18 17:03:30
Done
|
| + *fd = static_cast<int>(arr[0]); |
| + *offset = arr[1]; |
| + *size = arr[2]; |
| + env->ReleaseLongArrayElements(jarr.obj(), arr, JNI_ABORT); |
| + return *fd != -1; |
| +} |
| + |
| +} // namespace AwAssets |
| + |
| +bool RegisterAwAssets(JNIEnv* env) { |
| + return RegisterNativesImpl(env); |
| +} |
| + |
| +} // namespace android_webview |