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

Unified Diff: base/android/apk_assets.cc

Issue 2684433003: Files required by a service now listed in manifest. (Closed)
Patch Set: Addressed @boliu and @jam's comments. Created 3 years, 10 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: base/android/apk_assets.cc
diff --git a/base/android/apk_assets.cc b/base/android/apk_assets.cc
index 2a433cc4eaef1309150fcdae276d33a302829c49..186ba8980bb5f40b384f96a6393d995a1dea3c2a 100644
--- a/base/android/apk_assets.cc
+++ b/base/android/apk_assets.cc
@@ -10,6 +10,7 @@
#include "base/android/jni_array.h"
#include "base/android/jni_string.h"
#include "base/android/scoped_java_ref.h"
+#include "base/file_descriptor_store.h"
#include "jni/ApkAssets_jni.h"
namespace base {
@@ -17,8 +18,8 @@ namespace android {
int OpenApkAsset(const std::string& file_path,
base::MemoryMappedFile::Region* region) {
- // The AAssetManager API of the NDK is does not expose a method for accessing
- // raw resources :(.
+ // The AssetManager API of the NDK does not expose a method for accessing raw
+ // resources :(
JNIEnv* env = base::android::AttachCurrentThread();
ScopedJavaLocalRef<jlongArray> jarr = Java_ApkAssets_open(
env, base::android::GetApplicationContext(),
@@ -32,6 +33,18 @@ int OpenApkAsset(const std::string& file_path,
return fd;
}
+bool RegisterApkAssetWithFileDescriptorStore(const std::string& key,
+ const std::string& file_path) {
+ base::MemoryMappedFile::Region region =
+ base::MemoryMappedFile::Region::kWholeFile;
+ int asset_fd = OpenApkAsset(file_path, &region);
+ if (asset_fd == -1)
+ return false;
nyquist 2017/02/10 23:37:50 Should the function for global descriptors follow
Jay Civelli 2017/02/13 18:48:25 Anything to make you happy, Tommy :-)
+ base::FileDescriptorStore::GetInstance().Set(key, base::ScopedFD(asset_fd),
+ region);
+ return true;
+}
+
bool RegisterApkAssetWithGlobalDescriptors(base::GlobalDescriptors::Key key,
const std::string& file_path) {
base::MemoryMappedFile::Region region =

Powered by Google App Engine
This is Rietveld 408576698