OLD | NEW |
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 PresentationController_h | 5 #ifndef PresentationController_h |
6 #define PresentationController_h | 6 #define PresentationController_h |
7 | 7 |
8 #include "core/dom/ContextLifecycleObserver.h" | 8 #include "core/dom/ContextLifecycleObserver.h" |
9 #include "core/frame/LocalFrame.h" | 9 #include "core/frame/LocalFrame.h" |
10 #include "modules/ModulesExport.h" | 10 #include "modules/ModulesExport.h" |
(...skipping 27 matching lines...) Expand all Loading... |
38 static PresentationController* from(LocalFrame&); | 38 static PresentationController* from(LocalFrame&); |
39 | 39 |
40 static void provideTo(LocalFrame&, WebPresentationClient*); | 40 static void provideTo(LocalFrame&, WebPresentationClient*); |
41 | 41 |
42 WebPresentationClient* client(); | 42 WebPresentationClient* client(); |
43 | 43 |
44 // Implementation of Supplement. | 44 // Implementation of Supplement. |
45 DECLARE_VIRTUAL_TRACE(); | 45 DECLARE_VIRTUAL_TRACE(); |
46 | 46 |
47 // Implementation of WebPresentationController. | 47 // Implementation of WebPresentationController. |
48 WebPresentationConnection* didStartDefaultSession( | 48 WebPresentationConnection* didStartDefaultPresentation( |
49 const WebPresentationSessionInfo&) override; | 49 const WebPresentationInfo&) override; |
50 void didChangeSessionState(const WebPresentationSessionInfo&, | 50 void didChangeConnectionState(const WebPresentationInfo&, |
51 WebPresentationConnectionState) override; | 51 WebPresentationConnectionState) override; |
52 void didCloseConnection(const WebPresentationSessionInfo&, | 52 void didCloseConnection(const WebPresentationInfo&, |
53 WebPresentationConnectionCloseReason, | 53 WebPresentationConnectionCloseReason, |
54 const WebString& message) override; | 54 const WebString& message) override; |
55 void didReceiveSessionTextMessage(const WebPresentationSessionInfo&, | 55 void didReceiveConnectionTextMessage(const WebPresentationInfo&, |
56 const WebString&) override; | 56 const WebString&) override; |
57 void didReceiveSessionBinaryMessage(const WebPresentationSessionInfo&, | 57 void didReceiveConnectionBinaryMessage(const WebPresentationInfo&, |
58 const uint8_t* data, | 58 const uint8_t* data, |
59 size_t length) override; | 59 size_t length) override; |
60 | 60 |
61 // Called by the Presentation object to advertize itself to the controller. | 61 // Called by the Presentation object to advertize itself to the controller. |
62 // The Presentation object is kept as a WeakMember in order to avoid keeping | 62 // The Presentation object is kept as a WeakMember in order to avoid keeping |
63 // it alive when it is no longer in the tree. | 63 // it alive when it is no longer in the tree. |
64 void setPresentation(Presentation*); | 64 void setPresentation(Presentation*); |
65 | 65 |
66 // Called by the Presentation object when the default request is updated | 66 // Called by the Presentation object when the default request is updated |
67 // in order to notify the client about the change of default presentation | 67 // in order to notify the client about the change of default presentation |
68 // url. | 68 // url. |
69 void setDefaultRequestUrl(const WTF::Vector<KURL>&); | 69 void setDefaultRequestUrl(const WTF::Vector<KURL>&); |
70 | 70 |
71 // Handling of running connections. | 71 // Handling of running connections. |
72 void registerConnection(PresentationConnection*); | 72 void registerConnection(PresentationConnection*); |
73 | 73 |
74 // Return a connection in |m_connections| with id equals to |presentationId|, | 74 // Return a connection in |m_connections| with id equals to |presentationId|, |
75 // url equals to one of |presentationUrls|, and state is not terminated. | 75 // url equals to one of |presentationUrls|, and state is not terminated. |
76 // Return null if such a connection does not exist. | 76 // Return null if such a connection does not exist. |
77 PresentationConnection* findExistingConnection( | 77 PresentationConnection* findExistingConnection( |
78 const blink::WebVector<blink::WebURL>& presentationUrls, | 78 const blink::WebVector<blink::WebURL>& presentationUrls, |
79 const blink::WebString& presentationId); | 79 const blink::WebString& presentationId); |
80 | 80 |
81 private: | 81 private: |
82 PresentationController(LocalFrame&, WebPresentationClient*); | 82 PresentationController(LocalFrame&, WebPresentationClient*); |
83 | 83 |
84 // Implementation of ContextLifecycleObserver. | 84 // Implementation of ContextLifecycleObserver. |
85 void contextDestroyed(ExecutionContext*) override; | 85 void contextDestroyed(ExecutionContext*) override; |
86 | 86 |
87 // Return the connection associated with the given |connectionClient| or | 87 // Return the connection associated with the given |connectionClient| or |
88 // null if it doesn't exist. | 88 // null if it doesn't exist. |
89 PresentationConnection* findConnection(const WebPresentationSessionInfo&); | 89 PresentationConnection* findConnection(const WebPresentationInfo&); |
90 | 90 |
91 // The WebPresentationClient which allows communicating with the embedder. | 91 // The WebPresentationClient which allows communicating with the embedder. |
92 // It is not owned by the PresentationController but the controller will | 92 // It is not owned by the PresentationController but the controller will |
93 // set it to null when the LocalFrame will be detached at which point the | 93 // set it to null when the LocalFrame will be detached at which point the |
94 // client can't be used. | 94 // client can't be used. |
95 WebPresentationClient* m_client; | 95 WebPresentationClient* m_client; |
96 | 96 |
97 // Default PresentationRequest used by the embedder. | 97 // Default PresentationRequest used by the embedder. |
98 // Member<PresentationRequest> m_defaultRequest; | 98 // Member<PresentationRequest> m_defaultRequest; |
99 WeakMember<Presentation> m_presentation; | 99 WeakMember<Presentation> m_presentation; |
100 | 100 |
101 // The presentation connections associated with that frame. | 101 // The presentation connections associated with that frame. |
102 // TODO(mlamouri): the PresentationController will keep any created | 102 // TODO(mlamouri): the PresentationController will keep any created |
103 // connections alive until the frame is detached. These should be weak ptr | 103 // connections alive until the frame is detached. These should be weak ptr |
104 // so that the connection can be GC'd. | 104 // so that the connection can be GC'd. |
105 HeapHashSet<Member<PresentationConnection>> m_connections; | 105 HeapHashSet<Member<PresentationConnection>> m_connections; |
106 }; | 106 }; |
107 | 107 |
108 } // namespace blink | 108 } // namespace blink |
109 | 109 |
110 #endif // PresentationController_h | 110 #endif // PresentationController_h |
OLD | NEW |