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

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

Issue 10949027: Close leaking FDs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed last comments and synced. Created 8 years, 2 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
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/sandboxed_process_service.h" 5 #include "content/app/android/sandboxed_process_service.h"
6 6
7 #include "base/android/jni_array.h" 7 #include "base/android/jni_array.h"
8 #include "base/global_descriptors_posix.h" 8 #include "base/global_descriptors_posix.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "content/common/android/surface_texture_peer.h" 10 #include "content/common/android/surface_texture_peer.h"
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 43
44 private: 44 private:
45 // The instance of org.chromium.content.app.SandboxedProcessService. 45 // The instance of org.chromium.content.app.SandboxedProcessService.
46 jobject service_; 46 jobject service_;
47 47
48 DISALLOW_COPY_AND_ASSIGN(SurfaceTexturePeerSandboxedImpl); 48 DISALLOW_COPY_AND_ASSIGN(SurfaceTexturePeerSandboxedImpl);
49 }; 49 };
50 50
51 // Chrome actually uses the renderer code path for all of its sandboxed 51 // Chrome actually uses the renderer code path for all of its sandboxed
52 // processes such as renderers, plugins, etc. 52 // processes such as renderers, plugins, etc.
53 void InternalInitSandboxedProcess(int ipc_fd, 53 void InternalInitSandboxedProcess(const std::vector<int>& file_ids,
54 const std::vector<int>& extra_file_ids, 54 const std::vector<int>& file_fds,
55 const std::vector<int>& extra_file_fds,
56 JNIEnv* env, 55 JNIEnv* env,
57 jclass clazz, 56 jclass clazz,
58 jobject context, 57 jobject context,
59 jobject service) { 58 jobject service) {
60 // Set up the IPC file descriptor mapping. 59 // Register the file descriptors.
61 base::GlobalDescriptors::GetInstance()->Set(kPrimaryIPCChannel, ipc_fd); 60 // This includes the IPC channel, the crash dump signals and resource related
62 // Register the extra file descriptors. 61 // files.
63 // This usually include the crash dump signals and resource related files. 62 DCHECK(file_fds.size() == file_ids.size());
64 DCHECK(extra_file_fds.size() == extra_file_ids.size()); 63 for (size_t i = 0; i < file_ids.size(); ++i)
65 for (size_t i = 0; i < extra_file_ids.size(); ++i) { 64 base::GlobalDescriptors::GetInstance()->Set(file_ids[i], file_fds[i]);
66 base::GlobalDescriptors::GetInstance()->Set(extra_file_ids[i],
67 extra_file_fds[i]);
68 }
69 65
70 content::SurfaceTexturePeer::InitInstance( 66 content::SurfaceTexturePeer::InitInstance(
71 new SurfaceTexturePeerSandboxedImpl(service)); 67 new SurfaceTexturePeerSandboxedImpl(service));
72 68
73 } 69 }
74 70
75 } // namespace <anonymous> 71 } // namespace <anonymous>
76 72
77 namespace content { 73 namespace content {
78 74
79 void InitSandboxedProcess(JNIEnv* env, 75 void InitSandboxedProcess(JNIEnv* env,
80 jclass clazz, 76 jclass clazz,
81 jobject context, 77 jobject context,
82 jobject service, 78 jobject service,
83 jint ipc_fd, 79 jintArray j_file_ids,
84 jintArray j_extra_file_ids, 80 jintArray j_file_fds) {
85 jintArray j_extra_file_fds) { 81 std::vector<int> file_ids;
86 std::vector<int> extra_file_ids; 82 std::vector<int> file_fds;
87 std::vector<int> extra_file_fds; 83 JavaIntArrayToIntVector(env, j_file_ids, &file_ids);
88 JavaIntArrayToIntVector(env, j_extra_file_ids, &extra_file_ids); 84 JavaIntArrayToIntVector(env, j_file_fds, &file_fds);
89 JavaIntArrayToIntVector(env, j_extra_file_fds, &extra_file_fds);
90 85
91 InternalInitSandboxedProcess(static_cast<int>(ipc_fd), 86 InternalInitSandboxedProcess(
92 extra_file_ids, extra_file_fds, 87 file_ids, file_fds, env, clazz, context, service);
93 env, clazz, context, service);
94 } 88 }
95 89
96 void ExitSandboxedProcess(JNIEnv* env, jclass clazz) { 90 void ExitSandboxedProcess(JNIEnv* env, jclass clazz) {
97 LOG(INFO) << "SandboxedProcessService: Exiting sandboxed process."; 91 LOG(INFO) << "SandboxedProcessService: Exiting sandboxed process.";
98 LibraryLoaderExitHook(); 92 LibraryLoaderExitHook();
99 _exit(0); 93 _exit(0);
100 } 94 }
101 95
102 bool RegisterSandboxedProcessService(JNIEnv* env) { 96 bool RegisterSandboxedProcessService(JNIEnv* env) {
103 return RegisterNativesImpl(env); 97 return RegisterNativesImpl(env);
104 } 98 }
105 99
106 } // namespace content 100 } // namespace content
OLDNEW
« no previous file with comments | « chrome/browser/chrome_content_browser_client.cc ('k') | content/browser/android/sandboxed_process_launcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698