| 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; |
| 37 |
| 36 // PresentationDispatcher is a delegate for Presentation API messages used by | 38 // PresentationDispatcher is a delegate for Presentation API messages used by |
| 37 // Blink. It forwards the calls to the Mojo PresentationService. | 39 // Blink. It forwards the calls to the Mojo PresentationService. |
| 38 class CONTENT_EXPORT PresentationDispatcher | 40 class CONTENT_EXPORT PresentationDispatcher |
| 39 : public RenderFrameObserver, | 41 : public RenderFrameObserver, |
| 40 public NON_EXPORTED_BASE(blink::WebPresentationClient), | 42 public NON_EXPORTED_BASE(blink::WebPresentationClient), |
| 41 public NON_EXPORTED_BASE(blink::mojom::PresentationServiceClient) { | 43 public NON_EXPORTED_BASE(blink::mojom::PresentationServiceClient) { |
| 42 public: | 44 public: |
| 43 explicit PresentationDispatcher(RenderFrame* render_frame); | 45 explicit PresentationDispatcher(RenderFrame* render_frame); |
| 44 ~PresentationDispatcher() override; | 46 ~PresentationDispatcher() override; |
| 45 | 47 |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 blink::mojom::PresentationSessionInfoPtr session_info, | 126 blink::mojom::PresentationSessionInfoPtr session_info, |
| 125 std::vector<blink::mojom::SessionMessagePtr> messages) override; | 127 std::vector<blink::mojom::SessionMessagePtr> messages) override; |
| 126 void OnDefaultSessionStarted( | 128 void OnDefaultSessionStarted( |
| 127 blink::mojom::PresentationSessionInfoPtr session_info) override; | 129 blink::mojom::PresentationSessionInfoPtr session_info) override; |
| 128 | 130 |
| 129 void OnSessionCreated( | 131 void OnSessionCreated( |
| 130 blink::WebPresentationConnectionClientCallbacks* callback, | 132 blink::WebPresentationConnectionClientCallbacks* callback, |
| 131 blink::mojom::PresentationSessionInfoPtr session_info, | 133 blink::mojom::PresentationSessionInfoPtr session_info, |
| 132 blink::mojom::PresentationErrorPtr error); | 134 blink::mojom::PresentationErrorPtr error); |
| 133 void OnReceiverConnectionAvailable( | 135 void OnReceiverConnectionAvailable( |
| 134 blink::mojom::PresentationSessionInfoPtr) override; | 136 blink::mojom::PresentationSessionInfoPtr, |
| 137 blink::mojom::PresentationConnectionPtr) override; |
| 135 | 138 |
| 136 // Call to PresentationService to send the message in |request|. | 139 // Call to PresentationService to send the message in |request|. |
| 137 // |session_info| and |message| of |reuqest| will be consumed. | 140 // |session_info| and |message| of |reuqest| will be consumed. |
| 138 // |HandleSendMessageRequests| will be invoked after the send is attempted. | 141 // |HandleSendMessageRequests| will be invoked after the send is attempted. |
| 139 void DoSendMessage( | 142 void DoSendMessage( |
| 140 SendMessageRequest* request, | 143 SendMessageRequest* request, |
| 141 const blink::WebPresentationConnectionProxy* connection_proxy); | 144 const blink::WebPresentationConnectionProxy* connection_proxy); |
| 142 void HandleSendMessageRequests( | 145 void HandleSendMessageRequests( |
| 143 const blink::WebPresentationConnectionProxy* connection_proxy, | 146 const blink::WebPresentationConnectionProxy* connection_proxy, |
| 144 bool success); | 147 bool success); |
| 145 | 148 |
| 146 void ConnectToPresentationServiceIfNeeded(); | 149 void ConnectToPresentationServiceIfNeeded(); |
| 147 | 150 |
| 148 void UpdateListeningState(); | 151 void UpdateListeningState(); |
| 152 std::unique_ptr<PresentationConnectionProxy> |
| 153 CreateAndSetControllerConnectionProxy( |
| 154 blink::mojom::PresentationSessionInfoPtr session_info); |
| 149 | 155 |
| 150 // Used as a weak reference. Can be null since lifetime is bound to the frame. | 156 // Used as a weak reference. Can be null since lifetime is bound to the frame. |
| 151 blink::WebPresentationController* controller_; | 157 blink::WebPresentationController* controller_; |
| 152 blink::WebPresentationReceiver* receiver_; | 158 blink::WebPresentationReceiver* receiver_; |
| 153 blink::mojom::PresentationServicePtr presentation_service_; | 159 blink::mojom::PresentationServicePtr presentation_service_; |
| 154 mojo::Binding<blink::mojom::PresentationServiceClient> binding_; | 160 mojo::Binding<blink::mojom::PresentationServiceClient> binding_; |
| 155 | 161 |
| 156 // Message requests are queued here and only one message at a time is sent | 162 // Message requests are queued here and only one message at a time is sent |
| 157 // over mojo channel. | 163 // over mojo channel. |
| 158 using MessageRequestQueue = std::queue<std::unique_ptr<SendMessageRequest>>; | 164 using MessageRequestQueue = std::queue<std::unique_ptr<SendMessageRequest>>; |
| (...skipping 29 matching lines...) Expand all Loading... |
| 188 // Updates the listening state of availability for |status| and notifies the | 194 // Updates the listening state of availability for |status| and notifies the |
| 189 // client. | 195 // client. |
| 190 void UpdateListeningState(AvailabilityStatus* status); | 196 void UpdateListeningState(AvailabilityStatus* status); |
| 191 | 197 |
| 192 DISALLOW_COPY_AND_ASSIGN(PresentationDispatcher); | 198 DISALLOW_COPY_AND_ASSIGN(PresentationDispatcher); |
| 193 }; | 199 }; |
| 194 | 200 |
| 195 } // namespace content | 201 } // namespace content |
| 196 | 202 |
| 197 #endif // CONTENT_RENDERER_PRESENTATION_PRESENTATION_DISPATCHER_H_ | 203 #endif // CONTENT_RENDERER_PRESENTATION_PRESENTATION_DISPATCHER_H_ |
| OLD | NEW |