| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 class JankObserver : public base::RefCountedThreadSafe<JankObserver>, | 85 class JankObserver : public base::RefCountedThreadSafe<JankObserver>, |
| 86 public MessageLoopForUI::Observer { | 86 public MessageLoopForUI::Observer { |
| 87 public: | 87 public: |
| 88 JankObserver(const char* thread_name, | 88 JankObserver(const char* thread_name, |
| 89 const TimeDelta& excessive_duration, | 89 const TimeDelta& excessive_duration, |
| 90 bool watchdog_enable) | 90 bool watchdog_enable) |
| 91 : MaxMessageDelay_(excessive_duration), | 91 : MaxMessageDelay_(excessive_duration), |
| 92 slow_processing_counter_(std::string("Chrome.SlowMsg") + thread_name), | 92 slow_processing_counter_(std::string("Chrome.SlowMsg") + thread_name), |
| 93 queueing_delay_counter_(std::string("Chrome.DelayMsg") + thread_name), | 93 queueing_delay_counter_(std::string("Chrome.DelayMsg") + thread_name), |
| 94 total_time_watchdog_(excessive_duration, thread_name, watchdog_enable) { | 94 total_time_watchdog_(excessive_duration, thread_name, watchdog_enable) { |
| 95 process_times_ = Histogram::HistogramFactoryGet( | 95 process_times_ = Histogram::FactoryGet( |
| 96 (std::string("Chrome.ProcMsgL ") + thread_name), | 96 std::string("Chrome.ProcMsgL ") + thread_name, |
| 97 1, 3600000, 50); | 97 1, 3600000, 50, Histogram::kUmaTargetedHistogramFlag); |
| 98 total_times_ = Histogram::HistogramFactoryGet( | 98 total_times_ = Histogram::FactoryGet( |
| 99 (std::string("Chrome.TotalMsgL ") + thread_name), | 99 std::string("Chrome.TotalMsgL ") + thread_name, |
| 100 1, 3600000, 50); | 100 1, 3600000, 50, Histogram::kUmaTargetedHistogramFlag); |
| 101 process_times_->SetFlags(kUmaTargetedHistogramFlag); | |
| 102 total_times_->SetFlags(kUmaTargetedHistogramFlag); | |
| 103 } | 101 } |
| 104 | 102 |
| 105 // Attaches the observer to the current thread's message loop. You can only | 103 // Attaches the observer to the current thread's message loop. You can only |
| 106 // attach to the current thread, so this function can be invoked on another | 104 // attach to the current thread, so this function can be invoked on another |
| 107 // thread to attach it. | 105 // thread to attach it. |
| 108 void AttachToCurrentThread() { | 106 void AttachToCurrentThread() { |
| 109 // TODO(darin): support monitoring jankiness on non-UI threads! | 107 // TODO(darin): support monitoring jankiness on non-UI threads! |
| 110 if (MessageLoop::current()->type() == MessageLoop::TYPE_UI) | 108 if (MessageLoop::current()->type() == MessageLoop::TYPE_UI) |
| 111 MessageLoopForUI::current()->AddObserver(this); | 109 MessageLoopForUI::current()->AddObserver(this); |
| 112 } | 110 } |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 267 ui_observer->Release(); | 265 ui_observer->Release(); |
| 268 ui_observer = NULL; | 266 ui_observer = NULL; |
| 269 } | 267 } |
| 270 if (io_observer) { | 268 if (io_observer) { |
| 271 // IO thread can't be running when we remove observers. | 269 // IO thread can't be running when we remove observers. |
| 272 DCHECK((!g_browser_process) || !(g_browser_process->io_thread())); | 270 DCHECK((!g_browser_process) || !(g_browser_process->io_thread())); |
| 273 io_observer->Release(); | 271 io_observer->Release(); |
| 274 io_observer = NULL; | 272 io_observer = NULL; |
| 275 } | 273 } |
| 276 } | 274 } |
| OLD | NEW |