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

Side by Side Diff: Source/WebCore/page/DeviceController.h

Issue 13866007: WebKit & WebCore part of the device motion implementation using the platform layer. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@devicemotion-webcore
Patch Set: fixed Eric's comments. Created 7 years, 8 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) 2013 Google Inc. All rights reserved. 2 * Copyright 2010, The Android Open Source Project
abarth-chromium 2013/04/23 21:36:26 Why are you contributing under this copyright? Us
timvolodine 2013/04/24 12:36:03 This is an old class originally written under this
3 * Copyright (C) 2012 Samsung Electronics. All rights reserved.
3 * 4 *
4 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 6 * modification, are permitted provided that the following conditions
6 * met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
7 * 13 *
8 * * Redistributions of source code must retain the above copyright 14 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
9 * notice, this list of conditions and the following disclaimer. 15 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
10 * * Redistributions in binary form must reproduce the above 16 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
11 * copyright notice, this list of conditions and the following disclaimer 17 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
12 * in the documentation and/or other materials provided with the 18 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
13 * distribution. 19 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
14 * * Neither the name of Google Inc. nor the names of its 20 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
15 * contributors may be used to endorse or promote products derived from 21 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
16 * this software without specific prior written permission. 22 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
17 * 23 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24 * THE POSSIBILITY OF SUCH DAMAGE.
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 25 */
30 26
31 #ifndef DeviceController_h 27 #ifndef DeviceController_h
32 #define DeviceController_h 28 #define DeviceController_h
33 29
34 #include "DOMWindow.h" 30 #include "DOMWindow.h"
35 #include "Event.h" 31 #include "Event.h"
36 #include "Supplementable.h" 32 #include "Supplementable.h"
37 #include "Timer.h" 33 #include "Timer.h"
38 #include <wtf/HashCountedSet.h> 34 #include <wtf/HashCountedSet.h>
39 35
40 namespace WebCore { 36 namespace WebCore {
41 37
42 class DeviceClient; 38 class DeviceClient;
43 class Page; 39 class Page;
44 40
45 class DeviceController : public Supplement<Page> { 41 class DeviceController : public Supplement<Page> {
46 public: 42 public:
47 // FIXME(timvolodine): remove this constructor and all references to DeviceC lient
48 // once the device orientation is switched to platform implementation.
49 explicit DeviceController(DeviceClient*); 43 explicit DeviceController(DeviceClient*);
50 ~DeviceController() { } 44 ~DeviceController() { }
51 45
52 void addDeviceEventListener(DOMWindow*); 46 void addDeviceEventListener(DOMWindow*);
53 void removeDeviceEventListener(DOMWindow*); 47 void removeDeviceEventListener(DOMWindow*);
54 void removeAllDeviceEventListeners(DOMWindow*); 48 void removeAllDeviceEventListeners(DOMWindow*);
55 49
56 void dispatchDeviceEvent(PassRefPtr<Event>); 50 void dispatchDeviceEvent(PassRefPtr<Event>);
57 bool isActive() { return !m_listeners.isEmpty(); } 51 bool isActive() { return !m_listeners.isEmpty(); }
58 DeviceClient* client() { return m_client; } 52 DeviceClient* client() { return m_client; }
59 53
60 virtual bool hasLastData() { return false; } 54 virtual bool hasLastData() { return false; }
61 virtual PassRefPtr<Event> getLastEvent() { return 0; } 55 virtual PassRefPtr<Event> getLastEvent() { return 0; }
62 56
63 protected: 57 protected:
64 DeviceController() : m_timer(this, &DeviceController::fireDeviceEvent) { }
65 void fireDeviceEvent(Timer<DeviceController>*); 58 void fireDeviceEvent(Timer<DeviceController>*);
66 59
67 HashCountedSet<RefPtr<DOMWindow> > m_listeners; 60 HashCountedSet<RefPtr<DOMWindow> > m_listeners;
68 HashCountedSet<RefPtr<DOMWindow> > m_lastEventListeners; 61 HashCountedSet<RefPtr<DOMWindow> > m_lastEventListeners;
69 DeviceClient* m_client; 62 DeviceClient* m_client;
70 Timer<DeviceController> m_timer; 63 Timer<DeviceController> m_timer;
71 }; 64 };
72 65
73 } // namespace WebCore 66 } // namespace WebCore
74 67
75 #endif // DeviceController_h 68 #endif // DeviceController_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698