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

Side by Side Diff: chrome/common/profiling.cc

Issue 9215005: Revert 117824 - Convert use of int ms to TimeDelta in files owned by brettw. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 11 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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"
11 #include "base/lazy_instance.h" 11 #include "base/lazy_instance.h"
(...skipping 22 matching lines...) Expand all
34 return profile_name; 34 return profile_name;
35 } 35 }
36 36
37 void FlushProfilingData(base::Thread* thread) { 37 void FlushProfilingData(base::Thread* thread) {
38 static const int kProfilingFlushSeconds = 10; 38 static const int kProfilingFlushSeconds = 10;
39 39
40 if (!Profiling::BeingProfiled()) 40 if (!Profiling::BeingProfiled())
41 return; 41 return;
42 42
43 base::debug::FlushProfiling(); 43 base::debug::FlushProfiling();
44 static int flush_seconds; 44 static int flush_seconds = 0;
45 if (!flush_seconds) { 45 if (!flush_seconds) {
46 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); 46 const CommandLine& command_line = *CommandLine::ForCurrentProcess();
47 std::string profiling_flush = 47 std::string profiling_flush =
48 command_line.GetSwitchValueASCII(switches::kProfilingFlush); 48 command_line.GetSwitchValueASCII(switches::kProfilingFlush);
49 if (!profiling_flush.empty()) { 49 if (!profiling_flush.empty()) {
50 flush_seconds = atoi(profiling_flush.c_str()); 50 flush_seconds = atoi(profiling_flush.c_str());
51 DCHECK(flush_seconds > 0); 51 DCHECK(flush_seconds > 0);
52 } else { 52 } else {
53 flush_seconds = kProfilingFlushSeconds; 53 flush_seconds = kProfilingFlushSeconds;
54 } 54 }
55 } 55 }
56 thread->message_loop()->PostDelayedTask( 56 thread->message_loop()->PostDelayedTask(
57 FROM_HERE, 57 FROM_HERE, base::Bind(&FlushProfilingData, thread), flush_seconds * 1000);
58 base::Bind(&FlushProfilingData, thread),
59 base::TimeDelta::FromSeconds(flush_seconds));
60 } 58 }
61 59
62 class ProfilingThreadControl { 60 class ProfilingThreadControl {
63 public: 61 public:
64 ProfilingThreadControl() : thread_(NULL) {} 62 ProfilingThreadControl() : thread_(NULL) {}
65 63
66 void Start() { 64 void Start() {
67 base::AutoLock locked(lock_); 65 base::AutoLock locked(lock_);
68 66
69 if (thread_ && thread_->IsRunning()) 67 if (thread_ && thread_->IsRunning())
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 return base::debug::BeingProfiled(); 132 return base::debug::BeingProfiled();
135 } 133 }
136 134
137 // static 135 // static
138 void Profiling::Toggle() { 136 void Profiling::Toggle() {
139 if (BeingProfiled()) 137 if (BeingProfiled())
140 Stop(); 138 Stop();
141 else 139 else
142 Start(); 140 Start();
143 } 141 }
OLDNEW
« no previous file with comments | « chrome/common/important_file_writer_unittest.cc ('k') | chrome/common/service_process_util_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698