1 // Copyright 2015 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 #ifndef BASE_ANDROID_APK_ASSETS_H_ 6 #define BASE_ANDROID_APK_ASSETS_H_ 7 8 #include <string> 9 10 #include "base/android/jni_android.h" 11 #include "base/files/file_path.h" 12 #include "base/files/memory_mapped_file.h" 13 14 namespace base { 15 namespace android { 16 17 // Opens an asset (e.g. a .pak file) from the apk. 18 // Can be used from renderer process. 19 // Fails if the asset is not stored uncompressed within the .apk. 20 // Returns: The File Descriptor of the asset, or -1 upon failure. 21 // Input arguments: 22 // - |file_path|: Path to file within .apk. e.g.: assets/foo.pak 23 // Output arguments: 24 // - |region|: size & offset (in bytes) within the .apk of the asset. 25 BASE_EXPORT int OpenApkAsset( 26 const std::string& file_path, 27 base::MemoryMappedFile::Region* region); 28 29 // Registers an uncompressed asset from within the apk in the 30 // FileDescriptorStore. 31 // Returns: true in case of success, false otherwise. 32 BASE_EXPORT bool RegisterApkAssetWithFileDescriptorStore( 33 const std::string& key, 34 const base::FilePath& file_path); 35 36 } // namespace android 37 } // namespace base 38 39 #endif // BASE_ANDROID_APK_ASSETS_H_ 40