| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "chrome/common/stack_sampling_configuration.h" | 5 #include "chrome/common/stack_sampling_configuration.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/lazy_instance.h" | 8 #include "base/lazy_instance.h" |
| 9 #include "base/rand_util.h" | 9 #include "base/rand_util.h" |
| 10 #include "build/build_config.h" | |
| 11 #include "chrome/common/channel_info.h" | 10 #include "chrome/common/channel_info.h" |
| 12 #include "chrome/common/chrome_switches.h" | 11 #include "chrome/common/chrome_switches.h" |
| 13 #include "components/version_info/version_info.h" | 12 #include "components/version_info/version_info.h" |
| 14 #include "content/public/common/content_switches.h" | 13 #include "content/public/common/content_switches.h" |
| 15 | 14 |
| 16 namespace { | 15 namespace { |
| 17 | 16 |
| 18 base::LazyInstance<StackSamplingConfiguration>::Leaky g_configuration = | 17 base::LazyInstance<StackSamplingConfiguration>::Leaky g_configuration = |
| 19 LAZY_INSTANCE_INITIALIZER; | 18 LAZY_INSTANCE_INITIALIZER; |
| 20 | 19 |
| 21 // The profiler is currently only implemented for Windows x64 and Mac x64. | 20 // The profiler is currently only implemented for Windows x64, and only runs on |
| 21 // trunk, canary, and dev. |
| 22 bool IsProfilerSupported() { | 22 bool IsProfilerSupported() { |
| 23 #if defined(OS_WIN) && defined(ARCH_CPU_X86_64) | 23 #if !defined(_WIN64) |
| 24 #if defined(GOOGLE_CHROME_BUILD) | 24 return false; |
| 25 // Only run on canary and dev. | |
| 26 const version_info::Channel channel = chrome::GetChannel(); | |
| 27 return channel == version_info::Channel::CANARY || | |
| 28 channel == version_info::Channel::DEV; | |
| 29 #else | |
| 30 return true; | |
| 31 #endif | |
| 32 #elif defined(OS_MACOSX) | |
| 33 // This is experimental, so only run on trunk. | |
| 34 #if defined(GOOGLE_CHROME_BUILD) | |
| 35 return false; | |
| 36 #else | |
| 37 return true; | |
| 38 #endif | |
| 39 #else | 25 #else |
| 40 return false; | 26 const version_info::Channel channel = chrome::GetChannel(); |
| 27 return (channel == version_info::Channel::UNKNOWN || |
| 28 channel == version_info::Channel::CANARY || |
| 29 channel == version_info::Channel::DEV); |
| 41 #endif | 30 #endif |
| 42 } | 31 } |
| 43 | 32 |
| 44 // Returns true if the current execution is taking place in the browser process. | 33 // Returns true if the current execution is taking place in the browser process. |
| 45 bool IsBrowserProcess() { | 34 bool IsBrowserProcess() { |
| 46 const base::CommandLine* command_line = | 35 const base::CommandLine* command_line = |
| 47 base::CommandLine::ForCurrentProcess(); | 36 base::CommandLine::ForCurrentProcess(); |
| 48 std::string process_type = | 37 std::string process_type = |
| 49 command_line->GetSwitchValueASCII(switches::kProcessType); | 38 command_line->GetSwitchValueASCII(switches::kProcessType); |
| 50 return process_type.empty(); | 39 return process_type.empty(); |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 { PROFILE_GPU_PROCESS, 0}, | 192 { PROFILE_GPU_PROCESS, 0}, |
| 204 { PROFILE_BROWSER_AND_GPU_PROCESS, 80}, | 193 { PROFILE_BROWSER_AND_GPU_PROCESS, 80}, |
| 205 { PROFILE_CONTROL, 10}, | 194 { PROFILE_CONTROL, 10}, |
| 206 { PROFILE_DISABLED, 10} | 195 { PROFILE_DISABLED, 10} |
| 207 }); | 196 }); |
| 208 | 197 |
| 209 default: | 198 default: |
| 210 return PROFILE_DISABLED; | 199 return PROFILE_DISABLED; |
| 211 } | 200 } |
| 212 } | 201 } |
| OLD | NEW |