| 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 "chrome/common/profiling.h" | 5 #include "chrome/common/profiling.h" |
| 6 | 6 |
| 7 #include "base/at_exit.h" | 7 #include "base/at_exit.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/debug/profiler.h" | 10 #include "base/debug/profiler.h" |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 const base::CommandLine& command_line = | 51 const base::CommandLine& command_line = |
| 52 *base::CommandLine::ForCurrentProcess(); | 52 *base::CommandLine::ForCurrentProcess(); |
| 53 if (command_line.HasSwitch(switches::kProfilingFile)) | 53 if (command_line.HasSwitch(switches::kProfilingFile)) |
| 54 profile_name = command_line.GetSwitchValueASCII(switches::kProfilingFile); | 54 profile_name = command_line.GetSwitchValueASCII(switches::kProfilingFile); |
| 55 else | 55 else |
| 56 profile_name = std::string(kDefaultProfileName); | 56 profile_name = std::string(kDefaultProfileName); |
| 57 std::string process_type = | 57 std::string process_type = |
| 58 command_line.GetSwitchValueASCII(switches::kProcessType); | 58 command_line.GetSwitchValueASCII(switches::kProcessType); |
| 59 std::string type = process_type.empty() ? | 59 std::string type = process_type.empty() ? |
| 60 std::string("browser") : std::string(process_type); | 60 std::string("browser") : std::string(process_type); |
| 61 ReplaceSubstringsAfterOffset(&profile_name, 0, "{type}", type.c_str()); | 61 base::ReplaceSubstringsAfterOffset(&profile_name, 0, "{type}", type); |
| 62 } | 62 } |
| 63 return profile_name; | 63 return profile_name; |
| 64 } | 64 } |
| 65 | 65 |
| 66 void FlushProfilingData(base::Thread* thread) { | 66 void FlushProfilingData(base::Thread* thread) { |
| 67 static const int kProfilingFlushSeconds = 10; | 67 static const int kProfilingFlushSeconds = 10; |
| 68 | 68 |
| 69 if (!Profiling::BeingProfiled()) | 69 if (!Profiling::BeingProfiled()) |
| 70 return; | 70 return; |
| 71 | 71 |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 return base::debug::BeingProfiled(); | 190 return base::debug::BeingProfiled(); |
| 191 } | 191 } |
| 192 | 192 |
| 193 // static | 193 // static |
| 194 void Profiling::Toggle() { | 194 void Profiling::Toggle() { |
| 195 if (BeingProfiled()) | 195 if (BeingProfiled()) |
| 196 Stop(); | 196 Stop(); |
| 197 else | 197 else |
| 198 Start(); | 198 Start(); |
| 199 } | 199 } |
| OLD | NEW |