| Index: content/app/android/child_process_service_impl.cc
|
| diff --git a/content/app/android/child_process_service_impl.cc b/content/app/android/child_process_service_impl.cc
|
| index 66513172f0fd9a69a273362afbbf387e3767f3ff..22e7bea8b4a752ad682cf71853e8f46fde5398fd 100644
|
| --- a/content/app/android/child_process_service_impl.cc
|
| +++ b/content/app/android/child_process_service_impl.cc
|
| @@ -8,9 +8,11 @@
|
| #include <cpu-features.h>
|
|
|
| #include "base/android/jni_array.h"
|
| +#include "base/android/jni_string.h"
|
| #include "base/android/library_loader/library_loader_hooks.h"
|
| #include "base/android/memory_pressure_listener_android.h"
|
| #include "base/android/unguessable_token_android.h"
|
| +#include "base/file_descriptor_store.h"
|
| #include "base/lazy_instance.h"
|
| #include "base/logging.h"
|
| #include "base/macros.h"
|
| @@ -23,6 +25,7 @@
|
| #include "gpu/ipc/common/gpu_surface_lookup.h"
|
| #include "ipc/ipc_descriptors.h"
|
| #include "jni/ChildProcessServiceImpl_jni.h"
|
| +#include "services/service_manager/public/cpp/shared_file_util.h"
|
| #include "ui/gl/android/scoped_java_surface.h"
|
|
|
| using base::android::AttachCurrentThread;
|
| @@ -136,6 +139,49 @@ void InternalInitChildProcessImpl(JNIEnv* env,
|
|
|
| } // namespace <anonymous>
|
|
|
| +jlong CreateFileDescriptorStoreRegistrationContext(
|
| + JNIEnv* env,
|
| + const JavaParamRef<jclass>& clazz,
|
| + const JavaParamRef<jstring>& shared_param) {
|
| + if (shared_param.obj() == nullptr)
|
| + return 0L;
|
| +
|
| + std::string param = base::android::ConvertJavaStringToUTF8(env, shared_param);
|
| + std::unique_ptr<std::map<int, std::string>> values =
|
| + base::MakeUnique<std::map<int, std::string>>();
|
| + if (!service_manager::ParseSharedFileSwitchValue(param, values.get()))
|
| + return 0L;
|
| + return reinterpret_cast<jlong>(values.release());
|
| +}
|
| +
|
| +void ReleaseFileDescriptorStoreRegistrationContext(
|
| + JNIEnv* env,
|
| + const JavaParamRef<jclass>& clazz,
|
| + jlong context) {
|
| + delete reinterpret_cast<std::map<int, std::string>*>(context);
|
| +}
|
| +
|
| +jboolean RegisterInFileDescriptorStore(JNIEnv* env,
|
| + const JavaParamRef<jclass>& clazz,
|
| + jlong store_context,
|
| + jint id,
|
| + jint fd,
|
| + jlong offset,
|
| + jlong size) {
|
| + if (!store_context)
|
| + return false;
|
| +
|
| + std::map<int, std::string>* id_to_keys =
|
| + reinterpret_cast<std::map<int, std::string>*>(store_context);
|
| + const auto& iter = id_to_keys->find(id);
|
| + if (iter == id_to_keys->end())
|
| + return false;
|
| +
|
| + base::MemoryMappedFile::Region region = {offset, size};
|
| + base::FileDescriptorStore::GetInstance()->Set(iter->second, fd, region);
|
| + return true;
|
| +}
|
| +
|
| void RegisterGlobalFileDescriptor(JNIEnv* env,
|
| const JavaParamRef<jclass>& clazz,
|
| jint id,
|
|
|