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

Side by Side Diff: content/browser/android/sandboxed_process_launcher.cc

Issue 10913085: Ensure we don't leak a callback object when starting a sandboxed process. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 3 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/public/android/java/src/org/chromium/content/browser/SandboxedProcessLauncher.java » ('j') | no next file with comments »
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/browser/android/sandboxed_process_launcher.h" 5 #include "content/browser/android/sandboxed_process_launcher.h"
6 6
7 #include "base/android/jni_android.h" 7 #include "base/android/jni_android.h"
8 #include "base/android/jni_array.h" 8 #include "base/android/jni_array.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
11 #include "jni/SandboxedProcessLauncher_jni.h" 11 #include "jni/SandboxedProcessLauncher_jni.h"
12 12
13 using base::android::AttachCurrentThread; 13 using base::android::AttachCurrentThread;
14 using base::android::ToJavaArrayOfStrings; 14 using base::android::ToJavaArrayOfStrings;
15 using base::android::ScopedJavaLocalRef; 15 using base::android::ScopedJavaLocalRef;
16 using base::GlobalDescriptors; 16 using base::GlobalDescriptors;
17 using content::StartSandboxedProcessCallback; 17 using content::StartSandboxedProcessCallback;
18 18
19 namespace content { 19 namespace content {
20 20
21 // Called from SandboxedProcessLauncher.java when the SandboxedProcess was 21 // Called from SandboxedProcessLauncher.java when the SandboxedProcess was
22 // started. 22 // started.
23 // |client_context| is the pointer to StartSandboxedProcessCallback which was 23 // |client_context| is the pointer to StartSandboxedProcessCallback which was
24 // passed in from StartSandboxedProcess. 24 // passed in from StartSandboxedProcess.
25 // |handle| is the processID of the child process as originated in Java. 25 // |handle| is the processID of the child process as originated in Java, 0 if
26 // the SandboxedProcess could not be created.
26 static void OnSandboxedProcessStarted(JNIEnv*, 27 static void OnSandboxedProcessStarted(JNIEnv*,
27 jclass, 28 jclass,
28 jint client_context, 29 jint client_context,
29 jint handle) { 30 jint handle) {
30 StartSandboxedProcessCallback* callback = 31 StartSandboxedProcessCallback* callback =
31 reinterpret_cast<StartSandboxedProcessCallback*>(client_context); 32 reinterpret_cast<StartSandboxedProcessCallback*>(client_context);
32 callback->Run(static_cast<base::ProcessHandle>(handle)); 33 if (handle)
34 callback->Run(static_cast<base::ProcessHandle>(handle));
33 delete callback; 35 delete callback;
34 } 36 }
35 37
36 void StartSandboxedProcess( 38 void StartSandboxedProcess(
37 const CommandLine::StringVector& argv, 39 const CommandLine::StringVector& argv,
38 int ipc_fd, 40 int ipc_fd,
39 const GlobalDescriptors::Mapping& files_to_register, 41 const GlobalDescriptors::Mapping& files_to_register,
40 const StartSandboxedProcessCallback& callback) { 42 const StartSandboxedProcessCallback& callback) {
41 JNIEnv* env = AttachCurrentThread(); 43 JNIEnv* env = AttachCurrentThread();
42 DCHECK(env); 44 DCHECK(env);
(...skipping 25 matching lines...) Expand all
68 JNIEnv* env = AttachCurrentThread(); 70 JNIEnv* env = AttachCurrentThread();
69 DCHECK(env); 71 DCHECK(env);
70 Java_SandboxedProcessLauncher_stop(env, static_cast<jint>(handle)); 72 Java_SandboxedProcessLauncher_stop(env, static_cast<jint>(handle));
71 } 73 }
72 74
73 bool RegisterSandboxedProcessLauncher(JNIEnv* env) { 75 bool RegisterSandboxedProcessLauncher(JNIEnv* env) {
74 return RegisterNativesImpl(env); 76 return RegisterNativesImpl(env);
75 } 77 }
76 78
77 } // namespace content 79 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/public/android/java/src/org/chromium/content/browser/SandboxedProcessLauncher.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698