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

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

Issue 8483003: Callback API Change: Reimplement Bind(); support IgnoreResult, full currying, and use less types (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased Created 9 years, 1 month 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) 2011 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"
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
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, base::Bind(FlushProfilingData, thread), flush_seconds * 1000); 57 FROM_HERE, base::Bind(&FlushProfilingData, thread), flush_seconds * 1000);
58 } 58 }
59 59
60 class ProfilingThreadControl { 60 class ProfilingThreadControl {
61 public: 61 public:
62 ProfilingThreadControl() {} 62 ProfilingThreadControl() {}
63 63
64 void Start() { 64 void Start() {
65 base::AutoLock locked(lock_); 65 base::AutoLock locked(lock_);
66 66
67 if (thread_ && thread_->IsRunning()) 67 if (thread_ && thread_->IsRunning())
68 return; 68 return;
69 thread_ = new base::Thread("Profiling_Flush"); 69 thread_ = new base::Thread("Profiling_Flush");
70 thread_->Start(); 70 thread_->Start();
71 thread_->message_loop()->PostTask( 71 thread_->message_loop()->PostTask(
72 FROM_HERE, base::Bind(FlushProfilingData, thread_)); 72 FROM_HERE, base::Bind(&FlushProfilingData, thread_));
73 } 73 }
74 74
75 void Stop() { 75 void Stop() {
76 base::AutoLock locked(lock_); 76 base::AutoLock locked(lock_);
77 77
78 if (!thread_ || !thread_->IsRunning()) 78 if (!thread_ || !thread_->IsRunning())
79 return; 79 return;
80 thread_->Stop(); 80 thread_->Stop();
81 delete thread_; 81 delete thread_;
82 thread_ = NULL; 82 thread_ = NULL;
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 return base::debug::BeingProfiled(); 132 return base::debug::BeingProfiled();
133 } 133 }
134 134
135 // static 135 // static
136 void Profiling::Toggle() { 136 void Profiling::Toggle() {
137 if (BeingProfiled()) 137 if (BeingProfiled())
138 Stop(); 138 Stop();
139 else 139 else
140 Start(); 140 Start();
141 } 141 }
OLDNEW
« no previous file with comments | « chrome/browser/password_manager/password_store_x.cc ('k') | content/browser/cancelable_request.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698