Chromium Code Reviews| 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 ef6f171beee881cd9fc576659735e426230ad00b..be2ae9d1a28ae86938beb78628859dae4863be0c 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" |
| @@ -22,6 +24,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" |
| #include "ui/gl/android/surface_texture.h" |
| @@ -121,6 +124,50 @@ void InternalInitChildProcessImpl(JNIEnv* env, |
| } // namespace <anonymous> |
| +jlong CreateFileDescriptorStoreRegistrationContext( |
| + JNIEnv* env, |
| + const JavaParamRef<jclass>& clazz, |
| + const JavaParamRef<jstring>& shared_param) { |
| + if (shared_param.obj() == nullptr) |
|
boliu
2017/02/09 23:59:54
nit: shared_param.is_null()
Jay Civelli
2017/02/10 06:32:33
Done.
|
| + return 0L; |
| + |
| + std::string param = base::android::ConvertJavaStringToUTF8(env, shared_param); |
| + std::unique_ptr<std::map<int, std::string>> values = |
|
boliu
2017/02/09 23:59:54
nit: auto
Jay Civelli
2017/02/10 06:32:34
Done.
|
| + 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); |
|
boliu
2017/02/09 23:59:54
really should alias this
Jay Civelli
2017/02/10 06:32:34
The method has changed and the map comes up just o
|
| + 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, base::ScopedFD(fd), |
| + region); |
| + return true; |
| +} |
| + |
| void RegisterGlobalFileDescriptor(JNIEnv* env, |
| const JavaParamRef<jclass>& clazz, |
| jint id, |