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

Unified Diff: android_webview/native/aw_assets.cc

Issue 401743003: [android_webview] Introduce AwAssets to reference assets inside the apk. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@pakfiles
Patch Set: Created 6 years, 5 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 side-by-side diff with in-line comments
Download patch
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

Powered by Google App Engine
This is Rietveld 408576698