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

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

Issue 17741010: Make ChildThread::current() and ChildProcess::current() only work on the main thread of the child... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: sync and also fix gpu single process case Created 7 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | content/browser/gpu/gpu_process_host.cc » ('j') | content/child/child_thread.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.h" 5 #include "content/app/android/child_process_service.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/logging.h" 11 #include "base/logging.h"
12 #include "base/posix/global_descriptors.h" 12 #include "base/posix/global_descriptors.h"
13 #include "content/child/child_process.h"
14 #include "content/child/child_thread.h" 13 #include "content/child/child_thread.h"
15 #include "content/common/android/surface_texture_peer.h" 14 #include "content/common/android/surface_texture_peer.h"
16 #include "content/common/gpu/gpu_surface_lookup.h" 15 #include "content/common/gpu/gpu_surface_lookup.h"
17 #include "content/public/app/android_library_loader_hooks.h" 16 #include "content/public/app/android_library_loader_hooks.h"
18 #include "content/public/common/content_descriptors.h" 17 #include "content/public/common/content_descriptors.h"
19 #include "ipc/ipc_descriptors.h" 18 #include "ipc/ipc_descriptors.h"
20 #include "jni/ChildProcessService_jni.h" 19 #include "jni/ChildProcessService_jni.h"
21 #include "ui/gl/android/scoped_java_surface.h" 20 #include "ui/gl/android/scoped_java_surface.h"
22 21
23 using base::android::AttachCurrentThread; 22 using base::android::AttachCurrentThread;
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 private: 73 private:
75 // The instance of org.chromium.content.app.ChildProcessService. 74 // The instance of org.chromium.content.app.ChildProcessService.
76 base::android::ScopedJavaGlobalRef<jobject> service_; 75 base::android::ScopedJavaGlobalRef<jobject> service_;
77 76
78 DISALLOW_COPY_AND_ASSIGN(SurfaceTexturePeerChildImpl); 77 DISALLOW_COPY_AND_ASSIGN(SurfaceTexturePeerChildImpl);
79 }; 78 };
80 79
81 // Chrome actually uses the renderer code path for all of its child 80 // Chrome actually uses the renderer code path for all of its child
82 // processes such as renderers, plugins, etc. 81 // processes such as renderers, plugins, etc.
83 void InternalInitChildProcess(const std::vector<int>& file_ids, 82 void InternalInitChildProcess(const std::vector<int>& file_ids,
84 const std::vector<int>& file_fds, 83 const std::vector<int>& file_fds,
85 JNIEnv* env, 84 JNIEnv* env,
86 jclass clazz, 85 jclass clazz,
87 jobject context, 86 jobject context,
88 jobject service_in, 87 jobject service_in,
89 jint cpu_count, 88 jint cpu_count,
90 jlong cpu_features) { 89 jlong cpu_features) {
91 base::android::ScopedJavaLocalRef<jobject> service(env, service_in); 90 base::android::ScopedJavaLocalRef<jobject> service(env, service_in);
92 91
93 // Set the CPU properties. 92 // Set the CPU properties.
94 android_setCpu(cpu_count, cpu_features); 93 android_setCpu(cpu_count, cpu_features);
95 // Register the file descriptors. 94 // Register the file descriptors.
96 // This includes the IPC channel, the crash dump signals and resource related 95 // This includes the IPC channel, the crash dump signals and resource related
97 // files. 96 // files.
98 DCHECK(file_fds.size() == file_ids.size()); 97 DCHECK(file_fds.size() == file_ids.size());
99 for (size_t i = 0; i < file_ids.size(); ++i) 98 for (size_t i = 0; i < file_ids.size(); ++i)
100 base::GlobalDescriptors::GetInstance()->Set(file_ids[i], file_fds[i]); 99 base::GlobalDescriptors::GetInstance()->Set(file_ids[i], file_fds[i]);
101 100
102 content::SurfaceTexturePeer::InitInstance( 101 content::SurfaceTexturePeer::InitInstance(
103 new SurfaceTexturePeerChildImpl(service)); 102 new SurfaceTexturePeerChildImpl(service));
104 103
105 } 104 }
106 105
107 void QuitMainThreadMessageLoop() {
108 base::MessageLoop::current()->Quit();
109 }
110
111 } // namespace <anonymous> 106 } // namespace <anonymous>
112 107
113 void InitChildProcess(JNIEnv* env, 108 void InitChildProcess(JNIEnv* env,
114 jclass clazz, 109 jclass clazz,
115 jobject context, 110 jobject context,
116 jobject service, 111 jobject service,
117 jintArray j_file_ids, 112 jintArray j_file_ids,
118 jintArray j_file_fds, 113 jintArray j_file_fds,
119 jint cpu_count, 114 jint cpu_count,
120 jlong cpu_features) { 115 jlong cpu_features) {
121 std::vector<int> file_ids; 116 std::vector<int> file_ids;
122 std::vector<int> file_fds; 117 std::vector<int> file_fds;
123 JavaIntArrayToIntVector(env, j_file_ids, &file_ids); 118 JavaIntArrayToIntVector(env, j_file_ids, &file_ids);
124 JavaIntArrayToIntVector(env, j_file_fds, &file_fds); 119 JavaIntArrayToIntVector(env, j_file_fds, &file_fds);
125 120
126 InternalInitChildProcess( 121 InternalInitChildProcess(
127 file_ids, file_fds, env, clazz, context, service, 122 file_ids, file_fds, env, clazz, context, service,
128 cpu_count, cpu_features); 123 cpu_count, cpu_features);
129 } 124 }
130 125
131 void ExitChildProcess(JNIEnv* env, jclass clazz) { 126 void ExitChildProcess(JNIEnv* env, jclass clazz) {
132 LOG(INFO) << "ChildProcessService: Exiting child process."; 127 LOG(INFO) << "ChildProcessService: Exiting child process.";
133 LibraryLoaderExitHook(); 128 LibraryLoaderExitHook();
134 _exit(0); 129 _exit(0);
135 } 130 }
136 131
137 bool RegisterChildProcessService(JNIEnv* env) { 132 bool RegisterChildProcessService(JNIEnv* env) {
138 return RegisterNativesImpl(env); 133 return RegisterNativesImpl(env);
139 } 134 }
140 135
141 void ShutdownMainThread(JNIEnv* env, jobject obj) { 136 void ShutdownMainThread(JNIEnv* env, jobject obj) {
142 ChildProcess* current_process = ChildProcess::current(); 137 ChildThread::ShutdownThread();
143 if (!current_process)
144 return;
145 ChildThread* main_child_thread = current_process->main_thread();
146 if (main_child_thread && main_child_thread->message_loop())
147 main_child_thread->message_loop()->PostTask(FROM_HERE,
148 base::Bind(&QuitMainThreadMessageLoop));
149 } 138 }
150 139
151 } // namespace content 140 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/browser/gpu/gpu_process_host.cc » ('j') | content/child/child_thread.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698