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

Side by Side Diff: content/browser/child_process_launcher_helper_android.cc

Issue 2839353002: Revert of Remove post_launch_on_client_thread_called (Closed)
Patch Set: Created 3 years, 7 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
« no previous file with comments | « content/browser/child_process_launcher_helper.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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/browser/child_process_launcher_helper_android.h" 5 #include "content/browser/child_process_launcher_helper_android.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/android/apk_assets.h" 9 #include "base/android/apk_assets.h"
10 #include "base/android/jni_array.h" 10 #include "base/android/jni_array.h"
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 void ChildProcessLauncherHelper::ResetRegisteredFilesForTesting() { 192 void ChildProcessLauncherHelper::ResetRegisteredFilesForTesting() {
193 ResetFilesToShareForTestingPosix(); 193 ResetFilesToShareForTestingPosix();
194 } 194 }
195 195
196 // static 196 // static
197 base::File OpenFileToShare(const base::FilePath& path, 197 base::File OpenFileToShare(const base::FilePath& path,
198 base::MemoryMappedFile::Region* region) { 198 base::MemoryMappedFile::Region* region) {
199 return base::File(base::android::OpenApkAsset(path.value(), region)); 199 return base::File(base::android::OpenApkAsset(path.value(), region));
200 } 200 }
201 201
202 // Called from ChildProcessLauncher.java when the ChildProcess was started. 202 // Called from ChildProcessLauncher.java when the ChildProcess was
203 // started.
203 // |handle| is the processID of the child process as originated in Java, 0 if 204 // |handle| is the processID of the child process as originated in Java, 0 if
204 // the ChildProcess could not be created. 205 // the ChildProcess could not be created.
205 void ChildProcessLauncherHelper::OnChildProcessStarted( 206 void ChildProcessLauncherHelper::OnChildProcessStarted(
206 JNIEnv*, 207 JNIEnv*,
207 const base::android::JavaParamRef<jobject>& obj, 208 const base::android::JavaParamRef<jobject>& obj,
208 jint handle) { 209 jint handle) {
209 DCHECK_CURRENTLY_ON(BrowserThread::PROCESS_LAUNCHER);
210 scoped_refptr<ChildProcessLauncherHelper> ref(this); 210 scoped_refptr<ChildProcessLauncherHelper> ref(this);
211 Release(); // Balances with LaunchProcessOnLauncherThread. 211 Release(); // Balances with LaunchProcessOnLauncherThread.
212 212
213 int launch_result = (handle == base::kNullProcessHandle) 213 int launch_result = (handle == base::kNullProcessHandle)
214 ? LAUNCH_RESULT_FAILURE 214 ? LAUNCH_RESULT_FAILURE
215 : LAUNCH_RESULT_SUCCESS; 215 : LAUNCH_RESULT_SUCCESS;
216 216
217 // TODO(jcivelli): Remove this by defining better what happens on what thread
218 // in the corresponding Java code.
217 ChildProcessLauncherHelper::Process process; 219 ChildProcessLauncherHelper::Process process;
218 process.process = base::Process(handle); 220 process.process = base::Process(handle);
219 PostLaunchOnLauncherThread(std::move(process), launch_result); 221 if (BrowserThread::CurrentlyOn(BrowserThread::PROCESS_LAUNCHER)) {
222 PostLaunchOnLauncherThread(std::move(process), launch_result,
223 false); // post_launch_on_client_thread_called
224 return;
225 }
226
227 bool on_client_thread = BrowserThread::CurrentlyOn(
228 static_cast<BrowserThread::ID>(client_thread_id()));
229 BrowserThread::PostTask(
230 BrowserThread::PROCESS_LAUNCHER, FROM_HERE,
231 base::Bind(&ChildProcessLauncherHelper::PostLaunchOnLauncherThread, this,
232 base::Passed(std::move(process)), launch_result,
233 on_client_thread));
234 if (on_client_thread) {
235 ChildProcessLauncherHelper::Process process;
236 process.process = base::Process(handle);
237 PostLaunchOnClientThread(std::move(process), launch_result);
238 }
220 } 239 }
221 240
222 // static 241 // static
223 size_t ChildProcessLauncherHelper::GetNumberOfRendererSlots() { 242 size_t ChildProcessLauncherHelper::GetNumberOfRendererSlots() {
224 return static_cast<size_t>( 243 return static_cast<size_t>(
225 Java_ChildProcessLauncherHelper_getNumberOfRendererSlots( 244 Java_ChildProcessLauncherHelper_getNumberOfRendererSlots(
226 AttachCurrentThread())); 245 AttachCurrentThread()));
227 } 246 }
228 247
229 } // namespace internal 248 } // namespace internal
230 249
231 bool RegisterChildProcessLauncher(JNIEnv* env) { 250 bool RegisterChildProcessLauncher(JNIEnv* env) {
232 return internal::RegisterNativesImpl(env); 251 return internal::RegisterNativesImpl(env);
233 } 252 }
234 253
235 } // namespace content 254 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/child_process_launcher_helper.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698