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

Side by Side Diff: third_party/WebKit/Source/modules/vibration/VibrationController.cpp

Issue 2643023005: Move VibrationController to TaskRunnerTimer. (Closed)
Patch Set: Created 3 years, 11 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
« no previous file with comments | « third_party/WebKit/Source/modules/vibration/VibrationController.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "modules/vibration/VibrationController.h" 20 #include "modules/vibration/VibrationController.h"
21 21
22 #include "bindings/modules/v8/UnsignedLongOrUnsignedLongSequence.h" 22 #include "bindings/modules/v8/UnsignedLongOrUnsignedLongSequence.h"
23 #include "core/dom/Document.h" 23 #include "core/dom/Document.h"
24 #include "core/dom/TaskRunnerHelper.h"
24 #include "core/frame/Navigator.h" 25 #include "core/frame/Navigator.h"
25 #include "core/page/Page.h" 26 #include "core/page/Page.h"
26 #include "platform/mojo/MojoHelper.h" 27 #include "platform/mojo/MojoHelper.h"
27 #include "public/platform/InterfaceProvider.h" 28 #include "public/platform/InterfaceProvider.h"
28 29
29 // Maximum number of entries in a vibration pattern. 30 // Maximum number of entries in a vibration pattern.
30 const unsigned kVibrationPatternLengthMax = 99; 31 const unsigned kVibrationPatternLengthMax = 99;
31 32
32 // Maximum duration of a vibration is 10 seconds. 33 // Maximum duration of a vibration is 10 seconds.
33 const unsigned kVibrationDurationMsMax = 10000; 34 const unsigned kVibrationDurationMsMax = 10000;
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 sanitized.push_back(pattern.getAsUnsignedLong()); 69 sanitized.push_back(pattern.getAsUnsignedLong());
69 else if (pattern.isUnsignedLongSequence()) 70 else if (pattern.isUnsignedLongSequence())
70 sanitized = pattern.getAsUnsignedLongSequence(); 71 sanitized = pattern.getAsUnsignedLongSequence();
71 72
72 return sanitizeVibrationPatternInternal(sanitized); 73 return sanitizeVibrationPatternInternal(sanitized);
73 } 74 }
74 75
75 VibrationController::VibrationController(Document& document) 76 VibrationController::VibrationController(Document& document)
76 : ContextLifecycleObserver(&document), 77 : ContextLifecycleObserver(&document),
77 PageVisibilityObserver(document.page()), 78 PageVisibilityObserver(document.page()),
78 m_timerDoVibrate(this, &VibrationController::doVibrate), 79 m_timerDoVibrate(
80 TaskRunnerHelper::get(TaskType::MiscPlatformAPI, &document),
81 this,
82 &VibrationController::doVibrate),
79 m_isRunning(false), 83 m_isRunning(false),
80 m_isCallingCancel(false), 84 m_isCallingCancel(false),
81 m_isCallingVibrate(false) { 85 m_isCallingVibrate(false) {
82 document.frame()->interfaceProvider()->getInterface( 86 document.frame()->interfaceProvider()->getInterface(
83 mojo::MakeRequest(&m_service)); 87 mojo::MakeRequest(&m_service));
84 } 88 }
85 89
86 VibrationController::~VibrationController() {} 90 VibrationController::~VibrationController() {}
87 91
88 bool VibrationController::vibrate(const VibrationPattern& pattern) { 92 bool VibrationController::vibrate(const VibrationPattern& pattern) {
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 if (!page()->isPageVisible()) 186 if (!page()->isPageVisible())
183 cancel(); 187 cancel();
184 } 188 }
185 189
186 DEFINE_TRACE(VibrationController) { 190 DEFINE_TRACE(VibrationController) {
187 ContextLifecycleObserver::trace(visitor); 191 ContextLifecycleObserver::trace(visitor);
188 PageVisibilityObserver::trace(visitor); 192 PageVisibilityObserver::trace(visitor);
189 } 193 }
190 194
191 } // namespace blink 195 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/modules/vibration/VibrationController.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698