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

Side by Side Diff: third_party/WebKit/Source/modules/presentation/PresentationAvailability.h

Issue 2567913002: Rename ActiveDOMObject to SuspendableObject (Closed)
Patch Set: Created 4 years 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 PresentationAvailability_h 5 #ifndef PresentationAvailability_h
6 #define PresentationAvailability_h 6 #define PresentationAvailability_h
7 7
8 #include "bindings/core/v8/ActiveScriptWrappable.h" 8 #include "bindings/core/v8/ActiveScriptWrappable.h"
9 #include "core/dom/ActiveDOMObject.h" 9 #include "core/dom/SuspendableObject.h"
10 #include "core/events/EventTarget.h" 10 #include "core/events/EventTarget.h"
11 #include "core/page/PageVisibilityObserver.h" 11 #include "core/page/PageVisibilityObserver.h"
12 #include "modules/ModulesExport.h" 12 #include "modules/ModulesExport.h"
13 #include "platform/weborigin/KURL.h" 13 #include "platform/weborigin/KURL.h"
14 #include "public/platform/WebURL.h" 14 #include "public/platform/WebURL.h"
15 #include "public/platform/modules/presentation/WebPresentationAvailabilityObserv er.h" 15 #include "public/platform/modules/presentation/WebPresentationAvailabilityObserv er.h"
16 16
17 namespace blink { 17 namespace blink {
18 18
19 class ExecutionContext; 19 class ExecutionContext;
20 class ScriptPromiseResolver; 20 class ScriptPromiseResolver;
21 21
22 // Expose whether there is a presentation display available for |url|. The 22 // Expose whether there is a presentation display available for |url|. The
23 // object will be initialized with a default value passed via ::take() and will 23 // object will be initialized with a default value passed via ::take() and will
24 // then subscribe to receive callbacks if the status for |url| were to 24 // then subscribe to receive callbacks if the status for |url| were to
25 // change. The object will only listen to changes when required. 25 // change. The object will only listen to changes when required.
26 class MODULES_EXPORT PresentationAvailability final 26 class MODULES_EXPORT PresentationAvailability final
27 : public EventTargetWithInlineData, 27 : public EventTargetWithInlineData,
28 public ActiveScriptWrappable, 28 public ActiveScriptWrappable,
29 public ActiveDOMObject, 29 public SuspendableObject,
30 public PageVisibilityObserver, 30 public PageVisibilityObserver,
31 public WebPresentationAvailabilityObserver { 31 public WebPresentationAvailabilityObserver {
32 USING_GARBAGE_COLLECTED_MIXIN(PresentationAvailability); 32 USING_GARBAGE_COLLECTED_MIXIN(PresentationAvailability);
33 DEFINE_WRAPPERTYPEINFO(); 33 DEFINE_WRAPPERTYPEINFO();
34 34
35 public: 35 public:
36 static PresentationAvailability* take(ScriptPromiseResolver*, 36 static PresentationAvailability* take(ScriptPromiseResolver*,
37 const KURL&, 37 const KURL&,
38 bool); 38 bool);
39 ~PresentationAvailability() override; 39 ~PresentationAvailability() override;
40 40
41 // EventTarget implementation. 41 // EventTarget implementation.
42 const AtomicString& interfaceName() const override; 42 const AtomicString& interfaceName() const override;
43 ExecutionContext* getExecutionContext() const override; 43 ExecutionContext* getExecutionContext() const override;
44 44
45 // WebPresentationAvailabilityObserver implementation. 45 // WebPresentationAvailabilityObserver implementation.
46 void availabilityChanged(bool) override; 46 void availabilityChanged(bool) override;
47 const WebURL url() const override; 47 const WebURL url() const override;
48 48
49 // ScriptWrappable implementation. 49 // ScriptWrappable implementation.
50 bool hasPendingActivity() const final; 50 bool hasPendingActivity() const final;
51 51
52 // ActiveDOMObject implementation. 52 // SuspendableObject implementation.
53 void suspend() override; 53 void suspend() override;
54 void resume() override; 54 void resume() override;
55 void contextDestroyed() override; 55 void contextDestroyed() override;
56 56
57 // PageVisibilityObserver implementation. 57 // PageVisibilityObserver implementation.
58 void pageVisibilityChanged() override; 58 void pageVisibilityChanged() override;
59 59
60 bool value() const; 60 bool value() const;
61 61
62 DEFINE_ATTRIBUTE_EVENT_LISTENER(change); 62 DEFINE_ATTRIBUTE_EVENT_LISTENER(change);
63 63
64 DECLARE_VIRTUAL_TRACE(); 64 DECLARE_VIRTUAL_TRACE();
65 65
66 protected: 66 protected:
67 // EventTarget implementation. 67 // EventTarget implementation.
68 void addedEventListener(const AtomicString& eventType, 68 void addedEventListener(const AtomicString& eventType,
69 RegisteredEventListener&) override; 69 RegisteredEventListener&) override;
70 70
71 private: 71 private:
72 // Current state of the ActiveDOMObject. It is Active when created. It 72 // Current state of the SuspendableObject. It is Active when created. It
73 // becomes Suspended when suspend() is called and moves back to Active if 73 // becomes Suspended when suspend() is called and moves back to Active if
74 // resume() is called. It becomes Inactive when stop() is called or at 74 // resume() is called. It becomes Inactive when stop() is called or at
75 // destruction time. 75 // destruction time.
76 enum class State : char { 76 enum class State : char {
77 Active, 77 Active,
78 Suspended, 78 Suspended,
79 Inactive, 79 Inactive,
80 }; 80 };
81 81
82 PresentationAvailability(ExecutionContext*, const KURL&, bool); 82 PresentationAvailability(ExecutionContext*, const KURL&, bool);
83 83
84 void setState(State); 84 void setState(State);
85 void updateListening(); 85 void updateListening();
86 86
87 const KURL m_url; 87 const KURL m_url;
88 bool m_value; 88 bool m_value;
89 State m_state; 89 State m_state;
90 }; 90 };
91 91
92 } // namespace blink 92 } // namespace blink
93 93
94 #endif // PresentationAvailability_h 94 #endif // PresentationAvailability_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698