| OLD | NEW |
| 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/renderer/renderer_main_platform_delegate.h" | 5 #include "content/renderer/renderer_main_platform_delegate.h" |
| 6 | 6 |
| 7 #include <errno.h> | 7 #include <errno.h> |
| 8 #include <sys/stat.h> | 8 #include <sys/stat.h> |
| 9 | 9 |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| 11 #include "base/debug/trace_memory.h" |
| 11 #include "base/file_util.h" | 12 #include "base/file_util.h" |
| 12 #include "base/logging.h" | 13 #include "base/logging.h" |
| 14 #include "base/message_loop.h" |
| 13 #include "content/common/sandbox_linux.h" | 15 #include "content/common/sandbox_linux.h" |
| 14 #include "content/public/common/content_switches.h" | 16 #include "content/public/common/content_switches.h" |
| 15 #include "content/public/common/sandbox_init.h" | 17 #include "content/public/common/sandbox_init.h" |
| 16 | 18 |
| 17 #ifdef ENABLE_VTUNE_JIT_INTERFACE | 19 #ifdef ENABLE_VTUNE_JIT_INTERFACE |
| 18 #include "v8/src/third_party/vtune/v8-vtune.h" | 20 #include "v8/src/third_party/vtune/v8-vtune.h" |
| 19 #endif | 21 #endif |
| 20 | 22 |
| 21 namespace content { | 23 namespace content { |
| 22 | 24 |
| 23 RendererMainPlatformDelegate::RendererMainPlatformDelegate( | 25 RendererMainPlatformDelegate::RendererMainPlatformDelegate( |
| 24 const MainFunctionParams& parameters) | 26 const MainFunctionParams& parameters) |
| 25 : parameters_(parameters) { | 27 : parameters_(parameters) { |
| 26 } | 28 } |
| 27 | 29 |
| 28 RendererMainPlatformDelegate::~RendererMainPlatformDelegate() { | 30 RendererMainPlatformDelegate::~RendererMainPlatformDelegate() { |
| 29 } | 31 } |
| 30 | 32 |
| 31 void RendererMainPlatformDelegate::PlatformInitialize() { | 33 void RendererMainPlatformDelegate::PlatformInitialize() { |
| 32 #ifdef ENABLE_VTUNE_JIT_INTERFACE | 34 #ifdef ENABLE_VTUNE_JIT_INTERFACE |
| 33 const CommandLine& command_line = parameters_.command_line; | 35 const CommandLine& command_line = parameters_.command_line; |
| 34 if (command_line.HasSwitch(switches::kEnableVtune)) | 36 if (command_line.HasSwitch(switches::kEnableVtune)) |
| 35 vTune::InitializeVtuneForV8(); | 37 vTune::InitializeVtuneForV8(); |
| 36 #endif | 38 #endif |
| 39 |
| 40 // TODO(jamescook): Only start this when tracing is flipped on. |
| 41 base::TraceMemoryStart(); |
| 42 |
| 37 } | 43 } |
| 38 | 44 |
| 39 void RendererMainPlatformDelegate::PlatformUninitialize() { | 45 void RendererMainPlatformDelegate::PlatformUninitialize() { |
| 46 base::TraceMemoryStop(); |
| 40 } | 47 } |
| 41 | 48 |
| 42 bool RendererMainPlatformDelegate::InitSandboxTests(bool no_sandbox) { | 49 bool RendererMainPlatformDelegate::InitSandboxTests(bool no_sandbox) { |
| 43 // The sandbox is started in the zygote process: zygote_main_linux.cc | 50 // The sandbox is started in the zygote process: zygote_main_linux.cc |
| 44 // http://code.google.com/p/chromium/wiki/LinuxSUIDSandbox | 51 // http://code.google.com/p/chromium/wiki/LinuxSUIDSandbox |
| 45 return true; | 52 return true; |
| 46 } | 53 } |
| 47 | 54 |
| 48 bool RendererMainPlatformDelegate::EnableSandbox() { | 55 bool RendererMainPlatformDelegate::EnableSandbox() { |
| 49 // The setuid sandbox is started in the zygote process: zygote_main_linux.cc | 56 // The setuid sandbox is started in the zygote process: zygote_main_linux.cc |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 errno = 0; | 92 errno = 0; |
| 86 // This should normally return EBADF since the first argument is bogus, | 93 // This should normally return EBADF since the first argument is bogus, |
| 87 // but we know that under the seccomp-bpf sandbox, this should return EPERM. | 94 // but we know that under the seccomp-bpf sandbox, this should return EPERM. |
| 88 CHECK_EQ(fchmod(-1, 07777), -1); | 95 CHECK_EQ(fchmod(-1, 07777), -1); |
| 89 CHECK_EQ(errno, EPERM); | 96 CHECK_EQ(errno, EPERM); |
| 90 } | 97 } |
| 91 #endif // __x86_64__ | 98 #endif // __x86_64__ |
| 92 } | 99 } |
| 93 | 100 |
| 94 } // namespace content | 101 } // namespace content |
| OLD | NEW |