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

Side by Side Diff: content/app/android/child_process_service_impl.cc

Issue 2684433003: Files required by a service now listed in manifest. (Closed)
Patch Set: Synced + addressed comment from @rockot 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/app/android/child_process_service_impl.h" 5 #include "content/app/android/child_process_service_impl.h"
6 6
7 #include <android/native_window_jni.h> 7 #include <android/native_window_jni.h>
8 #include <cpu-features.h> 8 #include <cpu-features.h>
9 9
10 #include "base/android/jni_array.h" 10 #include "base/android/jni_array.h"
11 #include "base/android/jni_string.h"
11 #include "base/android/library_loader/library_loader_hooks.h" 12 #include "base/android/library_loader/library_loader_hooks.h"
12 #include "base/android/memory_pressure_listener_android.h" 13 #include "base/android/memory_pressure_listener_android.h"
13 #include "base/android/unguessable_token_android.h" 14 #include "base/android/unguessable_token_android.h"
15 #include "base/file_descriptor_store.h"
14 #include "base/lazy_instance.h" 16 #include "base/lazy_instance.h"
15 #include "base/logging.h" 17 #include "base/logging.h"
16 #include "base/macros.h" 18 #include "base/macros.h"
17 #include "base/posix/global_descriptors.h" 19 #include "base/posix/global_descriptors.h"
18 #include "base/unguessable_token.h" 20 #include "base/unguessable_token.h"
19 #include "content/child/child_thread_impl.h" 21 #include "content/child/child_thread_impl.h"
20 #include "content/public/common/content_descriptors.h" 22 #include "content/public/common/content_descriptors.h"
21 #include "gpu/ipc/common/android/scoped_surface_request_conduit.h" 23 #include "gpu/ipc/common/android/scoped_surface_request_conduit.h"
22 #include "gpu/ipc/common/gpu_surface_lookup.h" 24 #include "gpu/ipc/common/gpu_surface_lookup.h"
23 #include "ipc/ipc_descriptors.h" 25 #include "ipc/ipc_descriptors.h"
24 #include "jni/ChildProcessServiceImpl_jni.h" 26 #include "jni/ChildProcessServiceImpl_jni.h"
27 #include "services/service_manager/public/cpp/shared_file_util.h"
25 #include "ui/gl/android/scoped_java_surface.h" 28 #include "ui/gl/android/scoped_java_surface.h"
26 #include "ui/gl/android/surface_texture.h" 29 #include "ui/gl/android/surface_texture.h"
27 30
28 using base::android::AttachCurrentThread; 31 using base::android::AttachCurrentThread;
29 using base::android::CheckException; 32 using base::android::CheckException;
30 using base::android::JavaIntArrayToIntVector; 33 using base::android::JavaIntArrayToIntVector;
31 using base::android::JavaParamRef; 34 using base::android::JavaParamRef;
32 35
33 namespace content { 36 namespace content {
34 37
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 gpu::GpuSurfaceLookup::InitInstance( 117 gpu::GpuSurfaceLookup::InitInstance(
115 g_child_process_surface_manager.Pointer()); 118 g_child_process_surface_manager.Pointer());
116 gpu::ScopedSurfaceRequestConduit::SetInstance( 119 gpu::ScopedSurfaceRequestConduit::SetInstance(
117 g_child_process_surface_manager.Pointer()); 120 g_child_process_surface_manager.Pointer());
118 121
119 base::android::MemoryPressureListenerAndroid::RegisterSystemCallback(env); 122 base::android::MemoryPressureListenerAndroid::RegisterSystemCallback(env);
120 } 123 }
121 124
122 } // namespace <anonymous> 125 } // namespace <anonymous>
123 126
127 jlong CreateFileDescriptorStoreRegistrationContext(
128 JNIEnv* env,
129 const JavaParamRef<jclass>& clazz,
130 const JavaParamRef<jstring>& shared_param) {
131 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.
132 return 0L;
133
134 std::string param = base::android::ConvertJavaStringToUTF8(env, shared_param);
135 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.
136 base::MakeUnique<std::map<int, std::string>>();
137 if (!service_manager::ParseSharedFileSwitchValue(param, values.get()))
138 return 0L;
139 return reinterpret_cast<jlong>(values.release());
140 }
141
142 void ReleaseFileDescriptorStoreRegistrationContext(
143 JNIEnv* env,
144 const JavaParamRef<jclass>& clazz,
145 jlong context) {
146 delete reinterpret_cast<std::map<int, std::string>*>(context);
147 }
148
149 jboolean RegisterInFileDescriptorStore(JNIEnv* env,
150 const JavaParamRef<jclass>& clazz,
151 jlong store_context,
152 jint id,
153 jint fd,
154 jlong offset,
155 jlong size) {
156 if (!store_context)
157 return false;
158
159 std::map<int, std::string>* id_to_keys =
160 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
161 const auto& iter = id_to_keys->find(id);
162 if (iter == id_to_keys->end())
163 return false;
164
165 base::MemoryMappedFile::Region region = {offset, size};
166 base::FileDescriptorStore::GetInstance().Set(iter->second, base::ScopedFD(fd),
167 region);
168 return true;
169 }
170
124 void RegisterGlobalFileDescriptor(JNIEnv* env, 171 void RegisterGlobalFileDescriptor(JNIEnv* env,
125 const JavaParamRef<jclass>& clazz, 172 const JavaParamRef<jclass>& clazz,
126 jint id, 173 jint id,
127 jint fd, 174 jint fd,
128 jlong offset, 175 jlong offset,
129 jlong size) { 176 jlong size) {
130 base::MemoryMappedFile::Region region = {offset, size}; 177 base::MemoryMappedFile::Region region = {offset, size};
131 base::GlobalDescriptors::GetInstance()->Set(id, fd, region); 178 base::GlobalDescriptors::GetInstance()->Set(id, fd, region);
132 } 179 }
133 180
(...skipping 13 matching lines...) Expand all
147 194
148 bool RegisterChildProcessServiceImpl(JNIEnv* env) { 195 bool RegisterChildProcessServiceImpl(JNIEnv* env) {
149 return RegisterNativesImpl(env); 196 return RegisterNativesImpl(env);
150 } 197 }
151 198
152 void ShutdownMainThread(JNIEnv* env, const JavaParamRef<jobject>& obj) { 199 void ShutdownMainThread(JNIEnv* env, const JavaParamRef<jobject>& obj) {
153 ChildThreadImpl::ShutdownThread(); 200 ChildThreadImpl::ShutdownThread();
154 } 201 }
155 202
156 } // namespace content 203 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698