| 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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 const bool kPlaySounds = false; | 47 const bool kPlaySounds = false; |
| 48 | 48 |
| 49 //------------------------------------------------------------------------------ | 49 //------------------------------------------------------------------------------ |
| 50 // Provide a special watchdog to make it easy to set the breakpoint on this | 50 // Provide a special watchdog to make it easy to set the breakpoint on this |
| 51 // class only. | 51 // class only. |
| 52 class JankWatchdog : public Watchdog { | 52 class JankWatchdog : public Watchdog { |
| 53 public: | 53 public: |
| 54 JankWatchdog(const TimeDelta& duration, | 54 JankWatchdog(const TimeDelta& duration, |
| 55 const std::string& thread_watched_name, | 55 const std::string& thread_watched_name, |
| 56 bool enabled) | 56 bool enabled) |
| 57 : Watchdog(duration, ASCIIToWide(thread_watched_name), enabled), | 57 : Watchdog(duration, thread_watched_name, enabled), |
| 58 thread_name_watched_(thread_watched_name), | 58 thread_name_watched_(thread_watched_name), |
| 59 alarm_count_(0) { | 59 alarm_count_(0) { |
| 60 } | 60 } |
| 61 | 61 |
| 62 virtual ~JankWatchdog() {} | 62 virtual ~JankWatchdog() {} |
| 63 | 63 |
| 64 virtual void Alarm() { | 64 virtual void Alarm() { |
| 65 // Put break point here if you want to stop threads and look at what caused | 65 // Put break point here if you want to stop threads and look at what caused |
| 66 // the jankiness. | 66 // the jankiness. |
| 67 alarm_count_++; | 67 alarm_count_++; |
| 68 Watchdog::Alarm(); | 68 Watchdog::Alarm(); |
| 69 } | 69 } |
| 70 | 70 |
| 71 private: | 71 private: |
| 72 std::string thread_name_watched_; | 72 std::string thread_name_watched_; |
| 73 int alarm_count_; | 73 int alarm_count_; |
| 74 | 74 |
| 75 DISALLOW_EVIL_CONSTRUCTORS(JankWatchdog); | 75 DISALLOW_COPY_AND_ASSIGN(JankWatchdog); |
| 76 }; | 76 }; |
| 77 | 77 |
| 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), |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 | 230 |
| OLD | NEW |