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

Unified Diff: content/app/android/child_process_service_impl.cc

Issue 2684433003: Files required by a service now listed in manifest. (Closed)
Patch Set: Fix build. 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
« no previous file with comments | « content/app/DEPS ('k') | content/app/content_main_runner.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..ee268ad2adb4e172a71c151612375b9f8a686017 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"
@@ -18,10 +20,12 @@
#include "base/unguessable_token.h"
#include "content/child/child_thread_impl.h"
#include "content/public/common/content_descriptors.h"
+#include "content/public/common/content_switches.h"
#include "gpu/ipc/common/android/scoped_surface_request_conduit.h"
#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,14 +125,49 @@ void InternalInitChildProcessImpl(JNIEnv* env,
} // namespace <anonymous>
-void RegisterGlobalFileDescriptor(JNIEnv* env,
- const JavaParamRef<jclass>& clazz,
- jint id,
- jint fd,
- jlong offset,
- jlong size) {
- base::MemoryMappedFile::Region region = {offset, size};
- base::GlobalDescriptors::GetInstance()->Set(id, fd, region);
+void RegisterFileDescriptors(JNIEnv* env,
+ const JavaParamRef<jclass>& clazz,
+ const JavaParamRef<jintArray>& j_ids,
+ const JavaParamRef<jintArray>& j_fds,
+ const JavaParamRef<jlongArray>& j_offsets,
+ const JavaParamRef<jlongArray>& j_sizes) {
+ std::vector<int> ids;
+ base::android::JavaIntArrayToIntVector(env, j_ids, &ids);
+ std::vector<int> fds;
+ base::android::JavaIntArrayToIntVector(env, j_fds, &fds);
+ std::vector<int64_t> offsets;
+ base::android::JavaLongArrayToInt64Vector(env, j_offsets, &offsets);
+ std::vector<int64_t> sizes;
+ base::android::JavaLongArrayToInt64Vector(env, j_sizes, &sizes);
+
+ DCHECK_EQ(ids.size(), fds.size());
+ DCHECK_EQ(fds.size(), offsets.size());
+ DCHECK_EQ(offsets.size(), sizes.size());
+
+ std::map<int, std::string> ids_to_keys;
+ std::string file_switch_value =
+ base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
+ switches::kSharedFiles);
+ if (!file_switch_value.empty()) {
+ base::Optional<std::map<int, std::string>> ids_to_keys_from_command_line =
+ service_manager::ParseSharedFileSwitchValue(file_switch_value);
+ if (ids_to_keys_from_command_line) {
+ ids_to_keys = std::move(*ids_to_keys_from_command_line);
+ }
+ }
+
+ for (size_t i = 0; i < ids.size(); i++) {
+ base::MemoryMappedFile::Region region = {offsets.at(i), sizes.at(i)};
+ int id = ids.at(i);
+ int fd = fds.at(i);
+ auto iter = ids_to_keys.find(id);
+ if (iter != ids_to_keys.end()) {
+ base::FileDescriptorStore::GetInstance().Set(iter->second,
+ base::ScopedFD(fd), region);
+ } else {
+ base::GlobalDescriptors::GetInstance()->Set(id, fd, region);
+ }
+ }
}
void InitChildProcessImpl(JNIEnv* env,
« no previous file with comments | « content/app/DEPS ('k') | content/app/content_main_runner.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698