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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include <jni.h>
6
7 #include "android_webview/native/aw_assets.h"
8
9 #include "base/android/jni_string.h"
10 #include "base/android/scoped_java_ref.h"
11 #include "jni/AwAssets_jni.h"
12
13 namespace android_webview {
14 namespace AwAssets {
15
16 bool OpenAsset(const std::string& filename,
17 int* fd,
18 int64* offset,
19 int64* size) {
20 JNIEnv* env = base::android::AttachCurrentThread();
21 ScopedJavaLocalRef<jlongArray> jarr = Java_AwAssets_OpenAsset(
22 env,
23 base::android::GetApplicationContext(),
24 base::android::ConvertUTF8ToJavaString(env, filename).Release());
25 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
26 *fd = static_cast<int>(arr[0]);
27 *offset = arr[1];
28 *size = arr[2];
29 env->ReleaseLongArrayElements(jarr.obj(), arr, JNI_ABORT);
30 return *fd != -1;
31 }
32
33 } // namespace AwAssets
34
35 bool RegisterAwAssets(JNIEnv* env) {
36 return RegisterNativesImpl(env);
37 }
38
39 } // namespace android_webview
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698