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

Side by Side Diff: third_party/WebKit/Source/modules/screen_orientation/ScreenOrientationControllerImpl.h

Issue 2702103002: [ScreenOrientation] De-associate device.mojom.ScreenOrientation from legacy IPC channel.
Patch Set: Synchronize response of lock success with legacy IPC ViewMsg_Resize. Created 3 years, 10 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 ScreenOrientationControllerImpl_h 5 #ifndef ScreenOrientationControllerImpl_h
6 #define ScreenOrientationControllerImpl_h 6 #define ScreenOrientationControllerImpl_h
7 7
8 #include <memory>
9 #include <utility>
10
8 #include "core/dom/Document.h" 11 #include "core/dom/Document.h"
9 #include "core/frame/ScreenOrientationController.h" 12 #include "core/frame/ScreenOrientationController.h"
10 #include "core/page/PageVisibilityObserver.h" 13 #include "core/page/PageVisibilityObserver.h"
14 #include "device/screen_orientation/public/interfaces/screen_orientation.mojom-b link.h"
11 #include "modules/ModulesExport.h" 15 #include "modules/ModulesExport.h"
12 #include "public/platform/modules/screen_orientation/WebLockOrientationCallback. h" 16 #include "public/platform/modules/screen_orientation/WebLockOrientationCallback. h"
13 #include "public/platform/modules/screen_orientation/WebScreenOrientationLockTyp e.h" 17 #include "public/platform/modules/screen_orientation/WebScreenOrientationLockTyp e.h"
14 #include "public/platform/modules/screen_orientation/WebScreenOrientationType.h" 18 #include "public/platform/modules/screen_orientation/WebScreenOrientationType.h"
15 19
16 namespace blink { 20 namespace blink {
17 21
18 class ScreenOrientation; 22 class ScreenOrientation;
19 class WebScreenOrientationClient;
20 23
21 class MODULES_EXPORT ScreenOrientationControllerImpl final 24 class MODULES_EXPORT ScreenOrientationControllerImpl final
22 : public ScreenOrientationController, 25 : public ScreenOrientationController,
23 public ContextLifecycleObserver, 26 public ContextLifecycleObserver,
24 public PageVisibilityObserver { 27 public PageVisibilityObserver {
25 USING_GARBAGE_COLLECTED_MIXIN(ScreenOrientationControllerImpl); 28 USING_GARBAGE_COLLECTED_MIXIN(ScreenOrientationControllerImpl);
26 WTF_MAKE_NONCOPYABLE(ScreenOrientationControllerImpl); 29 WTF_MAKE_NONCOPYABLE(ScreenOrientationControllerImpl);
27 30
28 public: 31 public:
29 ~ScreenOrientationControllerImpl() override; 32 ~ScreenOrientationControllerImpl() override;
30 33
31 void setOrientation(ScreenOrientation*); 34 void setOrientation(ScreenOrientation*);
32 void notifyOrientationChanged(); 35 void notifyOrientationChanged();
33 36
34 // Implementation of ScreenOrientationController. 37 // Implementation of ScreenOrientationController.
35 void lock(WebScreenOrientationLockType, 38 void lock(WebScreenOrientationLockType,
36 std::unique_ptr<WebLockOrientationCallback>) override; 39 std::unique_ptr<WebLockOrientationCallback>) override;
37 void unlock() override; 40 void unlock() override;
38 bool maybeHasActiveLock() const override; 41 bool maybeHasActiveLock() const override;
39 42
40 static void provideTo(LocalFrame&, WebScreenOrientationClient*); 43 static void provideTo(LocalFrame&);
41 static ScreenOrientationControllerImpl* from(LocalFrame&); 44 static ScreenOrientationControllerImpl* from(LocalFrame&);
42 45
43 DECLARE_VIRTUAL_TRACE(); 46 DECLARE_VIRTUAL_TRACE();
44 47
45 private: 48 private:
46 ScreenOrientationControllerImpl(LocalFrame&, WebScreenOrientationClient*); 49 ScreenOrientationControllerImpl(LocalFrame&);
47 50
48 static WebScreenOrientationType computeOrientation(const IntRect&, uint16_t); 51 static WebScreenOrientationType computeOrientation(const IntRect&, uint16_t);
49 52
50 // Inherited from ContextLifecycleObserver. 53 // Inherited from ContextLifecycleObserver.
51 void contextDestroyed(ExecutionContext*) override; 54 void contextDestroyed(ExecutionContext*) override;
52 // Inherited from PageVisibilityObserver. 55 // Inherited from PageVisibilityObserver.
53 void pageVisibilityChanged() override; 56 void pageVisibilityChanged() override;
54 57
55 void notifyAccurateListen(); 58 void notifyAccurateListen();
56 59
57 void updateOrientation(); 60 void updateOrientation();
58 61
59 void dispatchEventTimerFired(TimerBase*); 62 void dispatchEventTimerFired(TimerBase*);
60 63
64 void onLockOrientationResult(
65 WebLockOrientationCallback*,
66 device::mojom::blink::ScreenOrientationLockResult,
67 WebScreenOrientationLockType);
68
69 void cancelPendingLock();
70
71 bool lockMatchesCurrentOrientation(WebScreenOrientationLockType);
72
61 bool isActive() const; 73 bool isActive() const;
62 bool isVisible() const; 74 bool isVisible() const;
63 bool isActiveAndVisible() const; 75 bool isActiveAndVisible() const;
64 76
65 Member<ScreenOrientation> m_orientation; 77 Member<ScreenOrientation> m_orientation;
66 WebScreenOrientationClient* m_client; 78 device::mojom::blink::ScreenOrientationPtr m_remoteScreenOrientation;
79 std::unique_ptr<WebLockOrientationCallback> m_pendingLockCallback;
80
81 using CallbackLockTypeMap =
82 std::map<std::unique_ptr<WebLockOrientationCallback>,
83 WebScreenOrientationLockType>;
84
85 // Lock orientation request has got SUCCESS response, but at that timing the
86 // new screen orientation value carried by legacy IPC ViewMsg_Resize has not
87 // arrived at blink side, so we pend those callbacks for such cases, until we
88 // find that the new screen orientation arrived and matched with what we
89 // wanted to lock to.
90 CallbackLockTypeMap m_waitCallbacks;
67 TaskRunnerTimer<ScreenOrientationControllerImpl> m_dispatchEventTimer; 91 TaskRunnerTimer<ScreenOrientationControllerImpl> m_dispatchEventTimer;
68 bool m_activeLock = false;
69 bool m_startedAccurateListen = false; 92 bool m_startedAccurateListen = false;
70 }; 93 };
71 94
72 } // namespace blink 95 } // namespace blink
73 96
74 #endif // ScreenOrientationControllerImpl_h 97 #endif // ScreenOrientationControllerImpl_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698