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

Side by Side Diff: Source/modules/vibration/NavigatorVibration.h

Issue 18777003: Extract simpler classes for observing context lifecycle and observe Page lifecycle inNavigatorVibra… (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Ensure m_scriptExecutionContext is maintained and not just null. Created 7 years, 5 months 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012 Samsung Electronics 2 * Copyright (C) 2012 Samsung Electronics
3 * 3 *
4 * This library is free software; you can redistribute it and/or 4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public 5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either 6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version. 7 * version 2 of the License, or (at your option) any later version.
8 * 8 *
9 * This library is distributed in the hope that it will be useful, 9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details. 12 * Library General Public License for more details.
13 * 13 *
14 * You should have received a copy of the GNU Library General Public License 14 * You should have received a copy of the GNU Library General Public License
15 * along with this library; see the file COPYING.LIB. If not, write to 15 * along with this library; see the file COPYING.LIB. If not, write to
16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA. 17 * Boston, MA 02110-1301, USA.
18 */ 18 */
19 19
20 #ifndef NavigatorVibration_h 20 #ifndef NavigatorVibration_h
21 #define NavigatorVibration_h 21 #define NavigatorVibration_h
22 22
23 #include "core/page/Navigator.h" 23 #include "core/page/Page.h"
24 #include "core/page/PageLifecycleObserver.h"
24 #include "core/platform/Timer.h" 25 #include "core/platform/Timer.h"
25 #include "wtf/PassOwnPtr.h" 26 #include "wtf/PassOwnPtr.h"
26 #include "wtf/Vector.h" 27 #include "wtf/Vector.h"
27 28
28 namespace WebCore { 29 namespace WebCore {
29 30
30 class NavigatorVibration : public Supplement<Navigator> { 31 class Navigator;
32
33 class NavigatorVibration
34 : public Supplement<Page>
35 , public PageLifecycleObserver {
31 public: 36 public:
32 typedef Vector<unsigned> VibrationPattern; 37 typedef Vector<unsigned> VibrationPattern;
33 38
34 ~NavigatorVibration(); 39 virtual ~NavigatorVibration();
35 40
36 bool vibrate(const VibrationPattern&); 41 bool vibrate(const VibrationPattern&);
37 void cancelVibration(); 42 void cancelVibration();
38 // FIXME : Hook suspendVibration() and resumeVibration() into the page
39 // visibility feature, when the document.hidden attribute is changed.
40 void suspendVibration();
41 void resumeVibration();
42 void timerStartFired(Timer<NavigatorVibration>*); 43 void timerStartFired(Timer<NavigatorVibration>*);
43 void timerStopFired(Timer<NavigatorVibration>*); 44 void timerStopFired(Timer<NavigatorVibration>*);
44 45
46 // Inherited from PageLifecycleObserver
47 virtual void pageVisibilityChanged() OVERRIDE;
48
45 static bool vibrate(Navigator*, unsigned time); 49 static bool vibrate(Navigator*, unsigned time);
46 static bool vibrate(Navigator*, const VibrationPattern&); 50 static bool vibrate(Navigator*, const VibrationPattern&);
47 static NavigatorVibration* from(Navigator*); 51 static NavigatorVibration* from(Page*);
48 52
49 private: 53 private:
50 NavigatorVibration(); 54 explicit NavigatorVibration(Page*);
51 static const char* supplementName(); 55 static const char* supplementName();
52 56
57 Page* m_page;
abarth-chromium 2013/07/09 18:27:52 We should be able to avoid this raw pointer by get
Michael van Ouwerkerk 2013/07/10 13:25:09 Done.
53 Timer<NavigatorVibration> m_timerStart; 58 Timer<NavigatorVibration> m_timerStart;
54 Timer<NavigatorVibration> m_timerStop; 59 Timer<NavigatorVibration> m_timerStop;
55 bool m_isVibrating; 60 bool m_isVibrating;
56 VibrationPattern m_pattern; 61 VibrationPattern m_pattern;
57 }; 62 };
58 63
59 } // namespace WebCore 64 } // namespace WebCore
60 65
61 #endif // NavigatorVibration_h 66 #endif // NavigatorVibration_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698