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

Side by Side Diff: Source/modules/screen_orientation/ScreenOrientationController.h

Issue 419643008: Make Screen Orientation use Platform Events in order to handle polling. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@platform_events
Patch Set: rebase Created 6 years, 4 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 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef ScreenOrientationController_h 5 #ifndef ScreenOrientationController_h
6 #define ScreenOrientationController_h 6 #define ScreenOrientationController_h
7 7
8 #include "core/page/PageLifecycleObserver.h" 8 #include "core/frame/PlatformEventController.h"
9 #include "platform/Supplementable.h" 9 #include "platform/Supplementable.h"
10 #include "platform/Timer.h" 10 #include "platform/Timer.h"
11 #include "public/platform/WebLockOrientationCallback.h" 11 #include "public/platform/WebLockOrientationCallback.h"
12 #include "public/platform/WebScreenOrientationLockType.h" 12 #include "public/platform/WebScreenOrientationLockType.h"
13 #include "public/platform/WebScreenOrientationType.h" 13 #include "public/platform/WebScreenOrientationType.h"
14 14
15 namespace blink { 15 namespace blink {
16 class WebScreenOrientationClient; 16 class WebScreenOrientationClient;
17 } 17 }
18 18
19 namespace blink { 19 namespace blink {
20 20
21 class FrameView; 21 class FrameView;
22 class ScreenOrientation; 22 class ScreenOrientation;
23 23
24 class ScreenOrientationController FINAL 24 class ScreenOrientationController FINAL
25 : public NoBaseWillBeGarbageCollectedFinalized<ScreenOrientationController> 25 : public NoBaseWillBeGarbageCollectedFinalized<ScreenOrientationController>
26 , public WillBeHeapSupplement<LocalFrame> 26 , public WillBeHeapSupplement<LocalFrame>
27 , public PageLifecycleObserver { 27 , public PlatformEventController {
28 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(ScreenOrientationController); 28 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(ScreenOrientationController);
29 WTF_MAKE_NONCOPYABLE(ScreenOrientationController); 29 WTF_MAKE_NONCOPYABLE(ScreenOrientationController);
30 public: 30 public:
31 virtual ~ScreenOrientationController(); 31 virtual ~ScreenOrientationController();
32 32
33 virtual void persistentHostHasBeenDestroyed() OVERRIDE; 33 virtual void persistentHostHasBeenDestroyed() OVERRIDE;
34 34
35 void setOrientation(ScreenOrientation*); 35 void setOrientation(ScreenOrientation*);
36 void notifyOrientationChanged(); 36 void notifyOrientationChanged();
37 37
38 void lock(blink::WebScreenOrientationLockType, blink::WebLockOrientationCall back*); 38 void lock(blink::WebScreenOrientationLockType, blink::WebLockOrientationCall back*);
39 void unlock(); 39 void unlock();
40 40
41 const LocalFrame& frame() const; 41 const LocalFrame& frame() const;
42 42
43 static void provideTo(LocalFrame&, blink::WebScreenOrientationClient*); 43 static void provideTo(LocalFrame&, blink::WebScreenOrientationClient*);
44 static ScreenOrientationController* from(LocalFrame&); 44 static ScreenOrientationController* from(LocalFrame&);
45 static const char* supplementName(); 45 static const char* supplementName();
46 46
47 virtual void trace(Visitor*); 47 virtual void trace(Visitor*);
48 48
49 private: 49 private:
50 explicit ScreenOrientationController(LocalFrame&, blink::WebScreenOrientatio nClient*); 50 explicit ScreenOrientationController(LocalFrame&, blink::WebScreenOrientatio nClient*);
51 static blink::WebScreenOrientationType computeOrientation(FrameView*); 51 static blink::WebScreenOrientationType computeOrientation(FrameView*);
52 52
53 // Inherited from PageLifecycleObserver. 53 // Inherited from PlatformEventController.
54 virtual void didUpdateData() OVERRIDE;
55 virtual void registerWithDispatcher() OVERRIDE;
56 virtual void unregisterWithDispatcher() OVERRIDE;
57 virtual bool hasLastData() OVERRIDE;
54 virtual void pageVisibilityChanged() OVERRIDE; 58 virtual void pageVisibilityChanged() OVERRIDE;
55 59
60 void notifyDispatcher();
61
56 void updateOrientation(); 62 void updateOrientation();
57 63
58 void dispatchEventTimerFired(Timer<ScreenOrientationController>*); 64 void dispatchEventTimerFired(Timer<ScreenOrientationController>*);
59 65
60 PersistentWillBeMember<ScreenOrientation> m_orientation; 66 PersistentWillBeMember<ScreenOrientation> m_orientation;
61 blink::WebScreenOrientationClient* m_client; 67 blink::WebScreenOrientationClient* m_client;
62 LocalFrame& m_frame; 68 LocalFrame& m_frame;
63 Timer<ScreenOrientationController> m_dispatchEventTimer; 69 Timer<ScreenOrientationController> m_dispatchEventTimer;
64 }; 70 };
65 71
66 } // namespace blink 72 } // namespace blink
67 73
68 #endif // ScreenOrientationController_h 74 #endif // ScreenOrientationController_h
OLDNEW
« no previous file with comments | « Source/modules/modules.gypi ('k') | Source/modules/screen_orientation/ScreenOrientationController.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698