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

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

Issue 18478003: Vibration cannot be canceled during pattern vibration. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Vibration cannot be canceled during pattern vibration. 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
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 77
78 if (!m_pattern.size()) 78 if (!m_pattern.size())
79 return true; 79 return true;
80 80
81 if (m_pattern.size() == 1 && !m_pattern[0]) { 81 if (m_pattern.size() == 1 && !m_pattern[0]) {
82 m_pattern.clear(); 82 m_pattern.clear();
83 return true; 83 return true;
84 } 84 }
85 85
86 m_timerStart.startOneShot(0); 86 m_timerStart.startOneShot(0);
87 m_isVibrating = true;
abarth-chromium 2013/07/08 21:04:59 Is that true? Don't we need to wait until the one
kihong 2013/07/12 11:04:13 If we move this to the timerStartFired(), there is
87 return true; 88 return true;
88 } 89 }
89 90
90 void NavigatorVibration::cancelVibration() 91 void NavigatorVibration::cancelVibration()
91 { 92 {
92 m_pattern.clear(); 93 m_pattern.clear();
93 if (m_isVibrating) { 94 if (m_isVibrating) {
94 WebKit::Platform::current()->cancelVibration(); 95 WebKit::Platform::current()->cancelVibration();
95 m_isVibrating = false; 96 m_isVibrating = false;
96 m_timerStop.stop(); 97 m_timerStop.stop();
97 } 98 }
98 } 99 }
99 100
100 void NavigatorVibration::suspendVibration() 101 void NavigatorVibration::suspendVibration()
101 { 102 {
102 if (!m_isVibrating) 103 if (!m_isVibrating)
103 return; 104 return;
104 105
105 m_pattern.insert(0, m_timerStop.nextFireInterval()); 106 m_pattern.insert(0, m_timerStop.nextFireInterval());
106 m_timerStop.stop(); 107 m_timerStop.stop();
107 cancelVibration(); 108 cancelVibration();
108 } 109 }
109 110
110 void NavigatorVibration::resumeVibration() 111 void NavigatorVibration::resumeVibration()
111 { 112 {
112 ASSERT(!m_timerStart.isActive()); 113 ASSERT(!m_timerStart.isActive());
113 114
114 m_timerStart.startOneShot(0); 115 m_timerStart.startOneShot(0);
116 m_isVibrating = true;
115 } 117 }
116 118
117 void NavigatorVibration::timerStartFired(Timer<NavigatorVibration>* timer) 119 void NavigatorVibration::timerStartFired(Timer<NavigatorVibration>* timer)
118 { 120 {
119 ASSERT_UNUSED(timer, timer == &m_timerStart); 121 ASSERT_UNUSED(timer, timer == &m_timerStart);
120 122
121 if (m_pattern.size()) { 123 if (m_pattern.size()) {
122 m_isVibrating = true;
123 WebKit::Platform::current()->vibrate(m_pattern[0]); 124 WebKit::Platform::current()->vibrate(m_pattern[0]);
124 m_timerStop.startOneShot(m_pattern[0] / 1000.0); 125 m_timerStop.startOneShot(m_pattern[0] / 1000.0);
125 m_pattern.remove(0); 126 m_pattern.remove(0);
126 } 127 }
127 } 128 }
128 129
129 void NavigatorVibration::timerStopFired(Timer<NavigatorVibration>* timer) 130 void NavigatorVibration::timerStopFired(Timer<NavigatorVibration>* timer)
130 { 131 {
131 ASSERT_UNUSED(timer, timer == &m_timerStop); 132 ASSERT_UNUSED(timer, timer == &m_timerStop);
132 133
133 m_isVibrating = false; 134 if (m_pattern.isEmpty())
135 m_isVibrating = false;
134 136
135 if (m_pattern.size()) { 137 if (m_pattern.size()) {
136 m_timerStart.startOneShot(m_pattern[0] / 1000.0); 138 m_timerStart.startOneShot(m_pattern[0] / 1000.0);
137 m_pattern.remove(0); 139 m_pattern.remove(0);
138 } 140 }
139 } 141 }
140 142
141 bool NavigatorVibration::vibrate(Navigator* navigator, unsigned time) 143 bool NavigatorVibration::vibrate(Navigator* navigator, unsigned time)
142 { 144 {
143 VibrationPattern pattern; 145 VibrationPattern pattern;
(...skipping 21 matching lines...) Expand all
165 } 167 }
166 return navigatorVibration; 168 return navigatorVibration;
167 } 169 }
168 170
169 const char* NavigatorVibration::supplementName() 171 const char* NavigatorVibration::supplementName()
170 { 172 {
171 return "NavigatorVibration"; 173 return "NavigatorVibration";
172 } 174 }
173 175
174 } // namespace WebCore 176 } // namespace WebCore
OLDNEW
« Source/core/testing/Internals.cpp ('K') | « Source/modules/vibration/NavigatorVibration.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698