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

Side by Side Diff: Source/modules/device_orientation/DeviceMotionController.h

Issue 14460010: Implement the Blink part of the Device Motion API. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: fixed re-entrancy issue Created 7 years, 7 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 2010 Apple Inc. All rights reserved. 2 * Copyright 2010 Apple Inc. All rights reserved.
3 * Copyright (C) 2012 Samsung Electronics. All rights reserved. 3 * Copyright (C) 2012 Samsung Electronics. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above copyright 10 * * Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the 11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution. 12 * documentation and/or other materials provided with the distribution.
13 * 13 *
14 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY 14 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 17 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
18 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 18 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
19 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 19 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
20 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 20 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
21 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 21 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
22 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */ 25 */
26 26
27 #ifndef DeviceMotionController_h 27 #ifndef DeviceMotionController_h
28 #define DeviceMotionController_h 28 #define DeviceMotionController_h
29 29
30 #include "core/page/DeviceController.h" 30 #include "core/dom/Event.h"
31 #include "core/platform/Supplementable.h"
32 #include "core/platform/Timer.h"
31 33
32 namespace WebCore { 34 namespace WebCore {
33 35
34 class DeviceMotionClient;
35 class DeviceMotionData; 36 class DeviceMotionData;
37 class Document;
36 38
37 class DeviceMotionController : public DeviceController { 39 // This class doesn't inherit from DeviceController anymore, which is a temporar y solution.
Peter Beverloo 2013/05/08 13:15:01 This should start with FIXME:
timvolodine 2013/05/09 10:08:28 Done.
40 // Once the device orientation switches to the client-less design, move some of the
Peter Beverloo 2013/05/08 13:15:01 nit: s/the//
timvolodine 2013/05/09 10:08:28 Done.
41 // methods in this class to the DeviceController.
42 class DeviceMotionController : public Supplement<ScriptExecutionContext> {
43
38 public: 44 public:
39 ~DeviceMotionController() { }; 45 virtual ~DeviceMotionController();
40 46
41 static PassOwnPtr<DeviceMotionController> create(DeviceMotionClient*); 47 static const char* supplementName();
48 static DeviceMotionController* from(Document*);
42 49
43 void didChangeDeviceMotion(DeviceMotionData*); 50 void didChangeDeviceMotion(DeviceMotionData*);
44 DeviceMotionClient* deviceMotionClient(); 51 bool hasLastData();
45 52 PassRefPtr<Event> getLastEvent();
46 virtual bool hasLastData() OVERRIDE; 53 void dispatchDeviceEvent(const PassRefPtr<Event>);
47 virtual PassRefPtr<Event> getLastEvent() OVERRIDE; 54 void startUpdating();
48 55 void stopUpdating();
49 static const char* supplementName();
50 static DeviceMotionController* from(Page*);
51 static bool isActiveAt(Page*);
52 56
53 private: 57 private:
54 explicit DeviceMotionController(DeviceMotionClient*); 58 explicit DeviceMotionController(Document* document);
59
60 void fireDeviceEvent(Timer<DeviceMotionController>*);
61
62 Document* m_document;
63 bool m_isActive;
64 Timer<DeviceMotionController> m_timer;
55 }; 65 };
56 66
57 } // namespace WebCore 67 } // namespace WebCore
58 68
59 #endif // DeviceMotionController_h 69 #endif // DeviceMotionController_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698