Chromium Code Reviews| Index: chrome/browser/ui/panels/panel_mouse_watcher_timer.cc |
| diff --git a/chrome/browser/ui/panels/panel_mouse_watcher_gtk.cc b/chrome/browser/ui/panels/panel_mouse_watcher_timer.cc |
| similarity index 52% |
| rename from chrome/browser/ui/panels/panel_mouse_watcher_gtk.cc |
| rename to chrome/browser/ui/panels/panel_mouse_watcher_timer.cc |
| index 9ae6002e10b6ee71be7b129867e2e0a1d0a5f810..089d3e9bd83b56b7dcab8208449b3a3f084708dd 100644 |
| --- a/chrome/browser/ui/panels/panel_mouse_watcher_gtk.cc |
| +++ b/chrome/browser/ui/panels/panel_mouse_watcher_timer.cc |
| @@ -2,8 +2,6 @@ |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| -// #include "chrome/browser/ui/panels/panel_mouse_watcher_gtk.h" |
| - |
| #include "base/memory/singleton.h" |
| #include "base/time.h" |
| #include "base/timer.h" |
| @@ -11,14 +9,14 @@ |
| #include "chrome/browser/ui/panels/panel_mouse_watcher.h" |
| #include "ui/gfx/screen.h" |
| -// A timer based implementation of PanelMouseWatcher. Currently used on Gtk |
| -// but could be used on any platform. |
| -class PanelMouseWatcherGtk : public PanelMouseWatcher { |
| +// A timer based implementation of PanelMouseWatcher. Currently used for Gtk |
| +// and Mac panels implementations. |
| +class PanelMouseWatcherTimer : public PanelMouseWatcher { |
|
jennb
2011/09/21 21:21:26
Thanks for making this diff-able!
|
| public: |
| // Returns the singleton instance. |
| - static PanelMouseWatcherGtk* GetInstance(); |
| + static PanelMouseWatcherTimer* GetInstance(); |
| - virtual ~PanelMouseWatcherGtk(); |
| + virtual ~PanelMouseWatcherTimer(); |
| protected: |
| virtual void Start(); |
| @@ -28,50 +26,51 @@ class PanelMouseWatcherGtk : public PanelMouseWatcher { |
| // Specifies the rate at which we want to sample the mouse position. |
| static const int kMousePollingIntervalMs = 250; |
| - PanelMouseWatcherGtk(); |
| - friend struct DefaultSingletonTraits<PanelMouseWatcherGtk>; |
| + PanelMouseWatcherTimer(); |
| + friend struct DefaultSingletonTraits<PanelMouseWatcherTimer>; |
| // Timer callback function. |
| void DoWork(); |
| - friend class base::RepeatingTimer<PanelMouseWatcherGtk>; |
| + friend class base::RepeatingTimer<PanelMouseWatcherTimer>; |
| - // Timer used to track mouse movements. Gtk does not provide an easy way of |
| - // tracking mouse movements across applications. So we use a timer to |
| + // Timer used to track mouse movements. Some OSes do not provide an easy way |
| + // of tracking mouse movements across applications. So we use a timer to |
| // accomplish the same. This could also be more efficient as you end up |
| // getting a lot of notifications when tracking mouse movements. |
| - base::RepeatingTimer<PanelMouseWatcherGtk> timer_; |
| + base::RepeatingTimer<PanelMouseWatcherTimer> timer_; |
| - DISALLOW_COPY_AND_ASSIGN(PanelMouseWatcherGtk); |
| + DISALLOW_COPY_AND_ASSIGN(PanelMouseWatcherTimer); |
| }; |
| // static |
| PanelMouseWatcher* PanelMouseWatcher::GetInstance() { |
| - return PanelMouseWatcherGtk::GetInstance(); |
| + return PanelMouseWatcherTimer::GetInstance(); |
| } |
| // static |
| -PanelMouseWatcherGtk* PanelMouseWatcherGtk::GetInstance() { |
| - return Singleton<PanelMouseWatcherGtk>::get(); |
| +PanelMouseWatcherTimer* PanelMouseWatcherTimer::GetInstance() { |
| + return Singleton<PanelMouseWatcherTimer>::get(); |
| } |
| -PanelMouseWatcherGtk::PanelMouseWatcherGtk() : PanelMouseWatcher() { |
| +PanelMouseWatcherTimer::PanelMouseWatcherTimer() : PanelMouseWatcher() { |
| } |
| -PanelMouseWatcherGtk::~PanelMouseWatcherGtk() { |
| +PanelMouseWatcherTimer::~PanelMouseWatcherTimer() { |
| + DCHECK(!timer_.IsRunning()); |
| } |
| -void PanelMouseWatcherGtk::Start() { |
| +void PanelMouseWatcherTimer::Start() { |
| DCHECK(!timer_.IsRunning()); |
| timer_.Start(FROM_HERE, |
| base::TimeDelta::FromMilliseconds(kMousePollingIntervalMs), |
| - this, &PanelMouseWatcherGtk::DoWork); |
| + this, &PanelMouseWatcherTimer::DoWork); |
| } |
| -void PanelMouseWatcherGtk::Stop() { |
| +void PanelMouseWatcherTimer::Stop() { |
| DCHECK(timer_.IsRunning()); |
| timer_.Stop(); |
| } |
| -void PanelMouseWatcherGtk::DoWork() { |
| +void PanelMouseWatcherTimer::DoWork() { |
| HandleMouseMovement(gfx::Screen::GetCursorScreenPoint()); |
| } |