Home | History | Annotate | Download | only in renderer
      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
      3 // found in the LICENSE file.
      4 
      5 #include "content/renderer/renderer_main_platform_delegate.h"
      6 
      7 #include "base/command_line.h"
      8 #include "base/logging.h"
      9 #include "content/public/common/content_switches.h"
     10 
     11 #ifdef USE_SECCOMP_BPF
     12 #include "content/common/sandbox_linux/android/sandbox_bpf_base_policy_android.h"
     13 #include "sandbox/linux/seccomp-bpf/sandbox_bpf.h"
     14 #endif
     15 
     16 #ifdef ENABLE_VTUNE_JIT_INTERFACE
     17 #include "v8/src/third_party/vtune/v8-vtune.h"
     18 #endif
     19 
     20 namespace content {
     21 
     22 RendererMainPlatformDelegate::RendererMainPlatformDelegate(
     23     const MainFunctionParams& parameters)
     24     : parameters_(parameters) {
     25 }
     26 
     27 RendererMainPlatformDelegate::~RendererMainPlatformDelegate() {
     28 }
     29 
     30 void RendererMainPlatformDelegate::PlatformInitialize() {
     31 #ifdef ENABLE_VTUNE_JIT_INTERFACE
     32   const CommandLine& command_line = parameters_.command_line;
     33   if (command_line.HasSwitch(switches::kEnableVtune))
     34     vTune::InitializeVtuneForV8();
     35 #endif
     36 }
     37 
     38 void RendererMainPlatformDelegate::PlatformUninitialize() {
     39 }
     40 
     41 bool RendererMainPlatformDelegate::EnableSandbox() {
     42 #ifdef USE_SECCOMP_BPF
     43   if (!base::CommandLine::ForCurrentProcess()->HasSwitch(
     44           switches::kEnableSeccompFilterSandbox)) {
     45     return true;
     46   }
     47 
     48   sandbox::SandboxBPF sandbox;
     49   sandbox.SetSandboxPolicy(new SandboxBPFBasePolicyAndroid());
     50   CHECK(sandbox.StartSandbox(sandbox::SandboxBPF::PROCESS_MULTI_THREADED));
     51 #endif
     52   return true;
     53 }
     54 
     55 }  // namespace content
     56