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

Unified Diff: content/app/android/sandboxed_process_service.cc

Issue 10546079: Added sandboxed process service. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Init Created 8 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: content/app/android/sandboxed_process_service.cc
diff --git a/content/app/android/sandboxed_process_service.cc b/content/app/android/sandboxed_process_service.cc
new file mode 100644
index 0000000000000000000000000000000000000000..7b0a3c7e7cca09216f62264a3f892c5d41b1a057
--- /dev/null
+++ b/content/app/android/sandboxed_process_service.cc
@@ -0,0 +1,114 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "content/app/android/sandboxed_process_service.h"
+
+#include "base/global_descriptors_posix.h"
+#include "base/logging.h"
+#include "content/common/android/surface_texture_peer.h"
+#if !defined(ANDROID_UPSTREAM_BRINGUP)
+#include "content/common/chrome_descriptors.h"
+#endif
+#include "content/public/app/android_library_loader_hooks.h"
+#include "ipc/ipc_descriptors.h"
+#include "jni/sandboxed_process_service_jni.h"
+
+using base::android::AttachCurrentThread;
+using base::android::CheckException;
+
+namespace {
+
+class SurfaceTexturePeerSandboxedImpl : public content::SurfaceTexturePeer {
+ public:
+ // |service| is the instance of
+ // org.chromium.content.app.SandboxedProcessService.
+ SurfaceTexturePeerSandboxedImpl(jobject service)
+ : service_(service) {
+ }
+
+ virtual ~SurfaceTexturePeerSandboxedImpl() {
+ }
+
+ virtual void EstablishSurfaceTexturePeer(base::ProcessHandle pid,
+ SurfaceTextureTarget type,
+ jobject j_surface_texture,
+ int primary_id,
+ int secondary_id) {
+ JNIEnv* env = base::android::AttachCurrentThread();
+ Java_SandboxedProcessService_establishSurfaceTexturePeer(env, service_,
+ pid, type, j_surface_texture, primary_id, secondary_id);
+ CheckException(env);
+ }
+
+ private:
+ // The instance of org.chromium.content.app.SandboxedProcessService.
+ jobject service_;
+
+ DISALLOW_COPY_AND_ASSIGN(SurfaceTexturePeerSandboxedImpl);
+};
+
+// Chrome actually uses the renderer code path for all of its sandboxed
+// processes such as renderers, plugins, etc.
+void InternalInitSandboxedProcess(int ipc_fd,
+ int crash_fd,
+ int chrome_pak_fd,
+ int locale_pak_fd,
+ JNIEnv* env,
+ jclass clazz,
+ jobject context,
+ jobject service) {
+ // Set up the IPC file descriptor mapping.
+ base::GlobalDescriptors::GetInstance()->Set(kPrimaryIPCChannel, ipc_fd);
+#if defined(USE_LINUX_BREAKPAD)
+ if (crash_fd > 0) {
+ base::GlobalDescriptors::GetInstance()->Set(kCrashDumpSignal, crash_fd);
+ }
+#endif
+
+#if !defined(ANDROID_UPSTREAM_BRINGUP)
Yaron 2012/06/11 19:46:22 Please remove this. It has to refactored anyway (c
jam 2012/06/11 20:13:17 +1. content also doesn't know about how embedders
michaelbai 2012/06/11 20:30:16 Done.
michaelbai 2012/06/11 20:30:16 I left them here as a remainder here for somebody
+ CHECK(chrome_pak_fd) << "Invalid chrome pak descriptor.";
+ CHECK(locale_pak_fd) << "Invalid locale pak descriptor.";
+ base::GlobalDescriptors::GetInstance()->Set(
+ kAndroidChromePakDescriptor, chrome_pak_fd);
+ base::GlobalDescriptors::GetInstance()->Set(
+ kAndroidLocalePakDescriptor, locale_pak_fd);
+ SurfaceTexturePeer::InitInstance(
+ new SurfaceTexturePeerSandboxedImpl(service));
+#endif
+}
+
+} // namespace <anonymous>
+
+static void InitSandboxedProcess(JNIEnv* env,
+ jclass clazz,
+ jobject context,
+ jobject service,
+ jint ipc_fd,
+ jint crash_fd,
+ jint chrome_pak_fd,
+ jint locale_pak_fd) {
+ InternalInitSandboxedProcess(static_cast<int>(ipc_fd),
+ static_cast<int>(crash_fd), static_cast<int>(chrome_pak_fd),
+ static_cast<int>(locale_pak_fd), env, clazz, context, service);
+
+ // sandboxed process can't be reused. There is no need to wait for the browser
+ // to unbind the service. Just exit and done.
+ LOG(INFO) << "SandboxedProcessService: Drop out of SandboxedProcessMain.";
+}
+
+static void ExitSandboxedProcess(JNIEnv* env, jclass clazz) {
+ LOG(INFO) << "SandboxedProcessService: Exiting sandboxed process.";
+ // TODO(tedchoc): These methods should also be in the content namespace to
+ // avoid specifying it in the LibraryLoaderExitHook call.
+ content::LibraryLoaderExitHook();
+ _exit(0);
+}
+
+namespace content {
+
+bool RegisterSandboxedProcessService(JNIEnv* env) {
+ return RegisterNativesImpl(env);
+}
+
+} // namespace content

Powered by Google App Engine
This is Rietveld 408576698