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 CONTENT_RENDERER_PRESENTATION_PRESENTATION_DISPATCHER_H_ | 5 #ifndef CONTENT_RENDERER_PRESENTATION_PRESENTATION_DISPATCHER_H_ |
6 #define CONTENT_RENDERER_PRESENTATION_PRESENTATION_DISPATCHER_H_ | 6 #define CONTENT_RENDERER_PRESENTATION_PRESENTATION_DISPATCHER_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
(...skipping 15 matching lines...) Expand all Loading... | |
26 class WebPresentationAvailabilityObserver; | 26 class WebPresentationAvailabilityObserver; |
27 class WebPresentationReceiver; | 27 class WebPresentationReceiver; |
28 class WebString; | 28 class WebString; |
29 class WebURL; | 29 class WebURL; |
30 template <typename T> | 30 template <typename T> |
31 class WebVector; | 31 class WebVector; |
32 } // namespace blink | 32 } // namespace blink |
33 | 33 |
34 namespace content { | 34 namespace content { |
35 | 35 |
36 class PresentationConnectionProxy; | |
imcheng
2016/11/01 17:20:30
nit: add blank line below
zhaobin
2016/11/02 03:55:48
Done.
| |
36 // PresentationDispatcher is a delegate for Presentation API messages used by | 37 // PresentationDispatcher is a delegate for Presentation API messages used by |
37 // Blink. It forwards the calls to the Mojo PresentationService. | 38 // Blink. It forwards the calls to the Mojo PresentationService. |
38 class CONTENT_EXPORT PresentationDispatcher | 39 class CONTENT_EXPORT PresentationDispatcher |
39 : public RenderFrameObserver, | 40 : public RenderFrameObserver, |
40 public NON_EXPORTED_BASE(blink::WebPresentationClient), | 41 public NON_EXPORTED_BASE(blink::WebPresentationClient), |
41 public NON_EXPORTED_BASE(blink::mojom::PresentationServiceClient) { | 42 public NON_EXPORTED_BASE(blink::mojom::PresentationServiceClient) { |
42 public: | 43 public: |
43 explicit PresentationDispatcher(RenderFrame* render_frame); | 44 explicit PresentationDispatcher(RenderFrame* render_frame); |
44 ~PresentationDispatcher() override; | 45 ~PresentationDispatcher() override; |
45 | 46 |
47 static blink::mojom::SessionMessagePtr ToMojoTextMessage( | |
imcheng
2016/11/01 17:20:30
do these need to be public static methods or can t
zhaobin
2016/11/02 03:55:48
Done.
| |
48 const blink::WebString& message); | |
49 static blink::mojom::SessionMessagePtr ToMojoBinaryMessage( | |
50 blink::mojom::PresentationMessageType type, | |
51 const uint8_t* data, | |
52 size_t length); | |
53 | |
46 private: | 54 private: |
47 struct SendMessageRequest { | 55 struct SendMessageRequest { |
48 SendMessageRequest(blink::mojom::PresentationSessionInfoPtr session_info, | 56 SendMessageRequest(blink::mojom::PresentationSessionInfoPtr session_info, |
49 blink::mojom::SessionMessagePtr message); | 57 blink::mojom::SessionMessagePtr message); |
50 ~SendMessageRequest(); | 58 ~SendMessageRequest(); |
51 | 59 |
52 blink::mojom::PresentationSessionInfoPtr session_info; | 60 blink::mojom::PresentationSessionInfoPtr session_info; |
53 blink::mojom::SessionMessagePtr message; | 61 blink::mojom::SessionMessagePtr message; |
54 }; | 62 }; |
55 | 63 |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
118 blink::mojom::PresentationSessionInfoPtr session_info, | 126 blink::mojom::PresentationSessionInfoPtr session_info, |
119 std::vector<blink::mojom::SessionMessagePtr> messages) override; | 127 std::vector<blink::mojom::SessionMessagePtr> messages) override; |
120 void OnDefaultSessionStarted( | 128 void OnDefaultSessionStarted( |
121 blink::mojom::PresentationSessionInfoPtr session_info) override; | 129 blink::mojom::PresentationSessionInfoPtr session_info) override; |
122 | 130 |
123 void OnSessionCreated( | 131 void OnSessionCreated( |
124 blink::WebPresentationConnectionClientCallbacks* callback, | 132 blink::WebPresentationConnectionClientCallbacks* callback, |
125 blink::mojom::PresentationSessionInfoPtr session_info, | 133 blink::mojom::PresentationSessionInfoPtr session_info, |
126 blink::mojom::PresentationErrorPtr error); | 134 blink::mojom::PresentationErrorPtr error); |
127 void OnReceiverConnectionAvailable( | 135 void OnReceiverConnectionAvailable( |
128 blink::mojom::PresentationSessionInfoPtr) override; | 136 blink::mojom::PresentationSessionInfoPtr, |
137 blink::mojom::PresentationConnectionPtr) override; | |
129 | 138 |
130 // Call to PresentationService to send the message in |request|. | 139 // Call to PresentationService to send the message in |request|. |
131 // |session_info| and |message| of |reuqest| will be consumed. | 140 // |session_info| and |message| of |reuqest| will be consumed. |
132 // |HandleSendMessageRequests| will be invoked after the send is attempted. | 141 // |HandleSendMessageRequests| will be invoked after the send is attempted. |
133 void DoSendMessage(SendMessageRequest* request); | 142 void DoSendMessage(SendMessageRequest* request); |
134 void HandleSendMessageRequests(bool success); | 143 void HandleSendMessageRequests(bool success); |
135 | 144 |
136 void ConnectToPresentationServiceIfNeeded(); | 145 void ConnectToPresentationServiceIfNeeded(); |
137 | 146 |
138 void UpdateListeningState(); | 147 void UpdateListeningState(); |
148 std::unique_ptr<PresentationConnectionProxy> | |
149 CreateAndSetControllerConnectionProxy( | |
150 blink::mojom::PresentationSessionInfoPtr session_info); | |
139 | 151 |
140 // Used as a weak reference. Can be null since lifetime is bound to the frame. | 152 // Used as a weak reference. Can be null since lifetime is bound to the frame. |
141 blink::WebPresentationController* controller_; | 153 blink::WebPresentationController* controller_; |
142 blink::WebPresentationReceiver* receiver_; | 154 blink::WebPresentationReceiver* receiver_; |
143 blink::mojom::PresentationServicePtr presentation_service_; | 155 blink::mojom::PresentationServicePtr presentation_service_; |
144 mojo::Binding<blink::mojom::PresentationServiceClient> binding_; | 156 mojo::Binding<blink::mojom::PresentationServiceClient> binding_; |
145 | 157 |
146 // Message requests are queued here and only one message at a time is sent | 158 // Message requests are queued here and only one message at a time is sent |
147 // over mojo channel. | 159 // over mojo channel. |
148 using MessageRequestQueue = std::queue<std::unique_ptr<SendMessageRequest>>; | 160 using MessageRequestQueue = std::queue<std::unique_ptr<SendMessageRequest>>; |
(...skipping 29 matching lines...) Expand all Loading... | |
178 // Updates the listening state of availability for |status| and notifies the | 190 // Updates the listening state of availability for |status| and notifies the |
179 // client. | 191 // client. |
180 void UpdateListeningState(AvailabilityStatus* status); | 192 void UpdateListeningState(AvailabilityStatus* status); |
181 | 193 |
182 DISALLOW_COPY_AND_ASSIGN(PresentationDispatcher); | 194 DISALLOW_COPY_AND_ASSIGN(PresentationDispatcher); |
183 }; | 195 }; |
184 | 196 |
185 } // namespace content | 197 } // namespace content |
186 | 198 |
187 #endif // CONTENT_RENDERER_PRESENTATION_PRESENTATION_DISPATCHER_H_ | 199 #endif // CONTENT_RENDERER_PRESENTATION_PRESENTATION_DISPATCHER_H_ |
OLD | NEW |