OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 <limits> | 5 #include <limits> |
6 | 6 |
7 #include "chrome/browser/jankometer.h" | 7 #include "chrome/browser/jankometer.h" |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 //------------------------------------------------------------------------------ | 78 //------------------------------------------------------------------------------ |
79 class JankObserver : public base::RefCountedThreadSafe<JankObserver>, | 79 class JankObserver : public base::RefCountedThreadSafe<JankObserver>, |
80 public MessageLoopForUI::Observer { | 80 public MessageLoopForUI::Observer { |
81 public: | 81 public: |
82 JankObserver(const char* thread_name, | 82 JankObserver(const char* thread_name, |
83 const TimeDelta& excessive_duration, | 83 const TimeDelta& excessive_duration, |
84 bool watchdog_enable) | 84 bool watchdog_enable) |
85 : MaxMessageDelay_(excessive_duration), | 85 : MaxMessageDelay_(excessive_duration), |
86 slow_processing_counter_(std::string("Chrome.SlowMsg") + thread_name), | 86 slow_processing_counter_(std::string("Chrome.SlowMsg") + thread_name), |
87 queueing_delay_counter_(std::string("Chrome.DelayMsg") + thread_name), | 87 queueing_delay_counter_(std::string("Chrome.DelayMsg") + thread_name), |
88 process_times_((std::wstring(L"Chrome.ProcMsgL ") | 88 process_times_((std::string("Chrome.ProcMsgL ") + |
89 + ASCIIToWide(thread_name)).c_str(), 1, 3600000, 50), | 89 thread_name).c_str(), 1, 3600000, 50), |
90 total_times_((std::wstring(L"Chrome.TotalMsgL ") | 90 total_times_((std::string("Chrome.TotalMsgL ") + |
91 + ASCIIToWide(thread_name)).c_str(), 1, 3600000, 50), | 91 thread_name).c_str(), 1, 3600000, 50), |
92 total_time_watchdog_(excessive_duration, thread_name, watchdog_enable) { | 92 total_time_watchdog_(excessive_duration, thread_name, watchdog_enable) { |
93 process_times_.SetFlags(kUmaTargetedHistogramFlag); | 93 process_times_.SetFlags(kUmaTargetedHistogramFlag); |
94 total_times_.SetFlags(kUmaTargetedHistogramFlag); | 94 total_times_.SetFlags(kUmaTargetedHistogramFlag); |
95 } | 95 } |
96 | 96 |
97 // Attaches the observer to the current thread's message loop. You can only | 97 // Attaches the observer to the current thread's message loop. You can only |
98 // attach to the current thread, so this function can be invoked on another | 98 // attach to the current thread, so this function can be invoked on another |
99 // thread to attach it. | 99 // thread to attach it. |
100 void AttachToCurrentThread() { | 100 void AttachToCurrentThread() { |
101 // TODO(darin): support monitoring jankiness on non-UI threads! | 101 // TODO(darin): support monitoring jankiness on non-UI threads! |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
220 ui_observer->Release(); | 220 ui_observer->Release(); |
221 ui_observer = NULL; | 221 ui_observer = NULL; |
222 } | 222 } |
223 if (io_observer) { | 223 if (io_observer) { |
224 // IO thread can't be running when we remove observers. | 224 // IO thread can't be running when we remove observers. |
225 DCHECK((!g_browser_process) || !(g_browser_process->io_thread())); | 225 DCHECK((!g_browser_process) || !(g_browser_process->io_thread())); |
226 io_observer->Release(); | 226 io_observer->Release(); |
227 io_observer = NULL; | 227 io_observer = NULL; |
228 } | 228 } |
229 } | 229 } |
230 | |
OLD | NEW |