Chromium Code Reviews| 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 42 // Blink. It forwards the calls to the Mojo PresentationService. | 42 // Blink. It forwards the calls to the Mojo PresentationService. |
| 43 class CONTENT_EXPORT PresentationDispatcher | 43 class CONTENT_EXPORT PresentationDispatcher |
| 44 : public RenderFrameObserver, | 44 : public RenderFrameObserver, |
| 45 public NON_EXPORTED_BASE(blink::WebPresentationClient), | 45 public NON_EXPORTED_BASE(blink::WebPresentationClient), |
| 46 public NON_EXPORTED_BASE(blink::mojom::PresentationServiceClient) { | 46 public NON_EXPORTED_BASE(blink::mojom::PresentationServiceClient) { |
| 47 public: | 47 public: |
| 48 explicit PresentationDispatcher(RenderFrame* render_frame); | 48 explicit PresentationDispatcher(RenderFrame* render_frame); |
| 49 ~PresentationDispatcher() override; | 49 ~PresentationDispatcher() override; |
| 50 | 50 |
| 51 private: | 51 private: |
| 52 // TODO(zhaobin): remove friend class after moving message queue logic | |
| 53 // from PresentationDispatcher to PresentationConnectionProxy. | |
| 54 friend class PresentationConnectionProxy; | |
| 52 friend class TestPresentationDispatcher; | 55 friend class TestPresentationDispatcher; |
| 53 FRIEND_TEST_ALL_PREFIXES(PresentationDispatcherTest, TestStartSession); | 56 FRIEND_TEST_ALL_PREFIXES(PresentationDispatcherTest, TestStartSession); |
| 54 FRIEND_TEST_ALL_PREFIXES(PresentationDispatcherTest, TestStartSessionError); | 57 FRIEND_TEST_ALL_PREFIXES(PresentationDispatcherTest, TestStartSessionError); |
| 55 FRIEND_TEST_ALL_PREFIXES(PresentationDispatcherTest, TestJoinSession); | 58 FRIEND_TEST_ALL_PREFIXES(PresentationDispatcherTest, TestJoinSession); |
| 56 FRIEND_TEST_ALL_PREFIXES(PresentationDispatcherTest, TestJoinSessionError); | 59 FRIEND_TEST_ALL_PREFIXES(PresentationDispatcherTest, TestJoinSessionError); |
| 57 FRIEND_TEST_ALL_PREFIXES(PresentationDispatcherTest, TestSendString); | 60 FRIEND_TEST_ALL_PREFIXES(PresentationDispatcherTest, TestSendString); |
| 58 FRIEND_TEST_ALL_PREFIXES(PresentationDispatcherTest, TestSendArrayBuffer); | 61 FRIEND_TEST_ALL_PREFIXES(PresentationDispatcherTest, TestSendArrayBuffer); |
| 59 FRIEND_TEST_ALL_PREFIXES(PresentationDispatcherTest, TestSendBlobData); | 62 FRIEND_TEST_ALL_PREFIXES(PresentationDispatcherTest, TestSendBlobData); |
| 60 FRIEND_TEST_ALL_PREFIXES(PresentationDispatcherTest, TestCloseSession); | 63 FRIEND_TEST_ALL_PREFIXES(PresentationDispatcherTest, TestCloseSession); |
| 61 FRIEND_TEST_ALL_PREFIXES(PresentationDispatcherTest, TestTerminateSession); | 64 FRIEND_TEST_ALL_PREFIXES(PresentationDispatcherTest, TestTerminateSession); |
| 62 FRIEND_TEST_ALL_PREFIXES(PresentationDispatcherTest, | 65 FRIEND_TEST_ALL_PREFIXES(PresentationDispatcherTest, |
| 63 TestListenForScreenAvailability); | 66 TestListenForScreenAvailability); |
| 64 FRIEND_TEST_ALL_PREFIXES(PresentationDispatcherTest, | 67 FRIEND_TEST_ALL_PREFIXES(PresentationDispatcherTest, |
| 65 TestSetDefaultPresentationUrls); | 68 TestSetDefaultPresentationUrls); |
| 66 | 69 |
| 67 struct SendMessageRequest { | 70 struct SendMessageRequest { |
| 68 SendMessageRequest(blink::mojom::PresentationSessionInfoPtr session_info, | 71 SendMessageRequest( |
| 69 blink::mojom::ConnectionMessagePtr message); | 72 blink::mojom::PresentationSessionInfoPtr session_info, |
| 73 blink::mojom::ConnectionMessagePtr message, | |
| 74 const blink::WebPresentationConnectionProxy* connection_proxy); | |
| 70 ~SendMessageRequest(); | 75 ~SendMessageRequest(); |
| 71 | 76 |
| 72 blink::mojom::PresentationSessionInfoPtr session_info; | 77 blink::mojom::PresentationSessionInfoPtr session_info; |
| 73 blink::mojom::ConnectionMessagePtr message; | 78 blink::mojom::ConnectionMessagePtr message; |
| 79 const blink::WebPresentationConnectionProxy* connection_proxy; | |
|
imcheng
2017/01/20 20:15:43
Is this used in this patch? Please document what t
zhaobin
2017/01/23 19:38:49
Done.
| |
| 74 }; | 80 }; |
| 75 | 81 |
| 76 static SendMessageRequest* CreateSendTextMessageRequest( | 82 static SendMessageRequest* CreateSendTextMessageRequest( |
| 77 const blink::WebURL& presentationUrl, | 83 const blink::WebURL& presentationUrl, |
| 78 const blink::WebString& presentationId, | 84 const blink::WebString& presentationId, |
| 79 const blink::WebString& message); | 85 const blink::WebString& message, |
| 86 const blink::WebPresentationConnectionProxy* connection_proxy); | |
| 80 static SendMessageRequest* CreateSendBinaryMessageRequest( | 87 static SendMessageRequest* CreateSendBinaryMessageRequest( |
| 81 const blink::WebURL& presentationUrl, | 88 const blink::WebURL& presentationUrl, |
| 82 const blink::WebString& presentationId, | 89 const blink::WebString& presentationId, |
| 83 blink::mojom::PresentationMessageType type, | 90 blink::mojom::PresentationMessageType type, |
| 84 const uint8_t* data, | 91 const uint8_t* data, |
| 85 size_t length); | 92 size_t length, |
| 93 const blink::WebPresentationConnectionProxy* connection_proxy); | |
| 86 | 94 |
| 87 // WebPresentationClient implementation. | 95 // WebPresentationClient implementation. |
| 88 void setController(blink::WebPresentationController* controller) override; | 96 void setController(blink::WebPresentationController* controller) override; |
| 89 void setReceiver(blink::WebPresentationReceiver*) override; | 97 void setReceiver(blink::WebPresentationReceiver*) override; |
| 90 | |
| 91 void startSession(const blink::WebVector<blink::WebURL>& presentationUrls, | 98 void startSession(const blink::WebVector<blink::WebURL>& presentationUrls, |
| 92 std::unique_ptr<blink::WebPresentationConnectionCallback> | 99 std::unique_ptr<blink::WebPresentationConnectionCallbacks> |
| 93 callback) override; | 100 callback) override; |
| 94 void joinSession(const blink::WebVector<blink::WebURL>& presentationUrls, | 101 void joinSession(const blink::WebVector<blink::WebURL>& presentationUrls, |
| 95 const blink::WebString& presentationId, | 102 const blink::WebString& presentationId, |
| 96 std::unique_ptr<blink::WebPresentationConnectionCallback> | 103 std::unique_ptr<blink::WebPresentationConnectionCallbacks> |
| 97 callback) override; | 104 callback) override; |
| 98 void sendString(const blink::WebURL& presentationUrl, | 105 void sendString( |
| 99 const blink::WebString& presentationId, | 106 const blink::WebURL& presentationUrl, |
| 100 const blink::WebString& message) override; | 107 const blink::WebString& presentationId, |
| 101 void sendArrayBuffer(const blink::WebURL& presentationUrl, | 108 const blink::WebString& message, |
| 102 const blink::WebString& presentationId, | 109 const blink::WebPresentationConnectionProxy* connection_proxy) override; |
| 103 const uint8_t* data, | 110 void sendArrayBuffer( |
| 104 size_t length) override; | 111 const blink::WebURL& presentationUrl, |
| 105 void sendBlobData(const blink::WebURL& presentationUrl, | 112 const blink::WebString& presentationId, |
| 106 const blink::WebString& presentationId, | 113 const uint8_t* data, |
| 107 const uint8_t* data, | 114 size_t length, |
| 108 size_t length) override; | 115 const blink::WebPresentationConnectionProxy* connection_proxy) override; |
| 116 void sendBlobData( | |
| 117 const blink::WebURL& presentationUrl, | |
| 118 const blink::WebString& presentationId, | |
| 119 const uint8_t* data, | |
| 120 size_t length, | |
| 121 const blink::WebPresentationConnectionProxy* connection_proxy) override; | |
| 109 void closeSession(const blink::WebURL& presentationUrl, | 122 void closeSession(const blink::WebURL& presentationUrl, |
| 110 const blink::WebString& presentationId) override; | 123 const blink::WebString& presentationId) override; |
| 111 void terminateSession(const blink::WebURL& presentationUrl, | 124 void terminateSession(const blink::WebURL& presentationUrl, |
| 112 const blink::WebString& presentationId) override; | 125 const blink::WebString& presentationId) override; |
| 113 void getAvailability( | 126 void getAvailability( |
| 114 const blink::WebVector<blink::WebURL>& availabilityUrl, | 127 const blink::WebVector<blink::WebURL>& availabilityUrl, |
| 115 std::unique_ptr<blink::WebPresentationAvailabilityCallbacks> callbacks) | 128 std::unique_ptr<blink::WebPresentationAvailabilityCallbacks> callbacks) |
| 116 override; | 129 override; |
| 117 void startListening(blink::WebPresentationAvailabilityObserver*) override; | 130 void startListening(blink::WebPresentationAvailabilityObserver*) override; |
| 118 void stopListening(blink::WebPresentationAvailabilityObserver*) override; | 131 void stopListening(blink::WebPresentationAvailabilityObserver*) override; |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 135 blink::mojom::PresentationSessionInfoPtr session_info, | 148 blink::mojom::PresentationSessionInfoPtr session_info, |
| 136 blink::mojom::PresentationConnectionCloseReason reason, | 149 blink::mojom::PresentationConnectionCloseReason reason, |
| 137 const std::string& message) override; | 150 const std::string& message) override; |
| 138 void OnConnectionMessagesReceived( | 151 void OnConnectionMessagesReceived( |
| 139 blink::mojom::PresentationSessionInfoPtr session_info, | 152 blink::mojom::PresentationSessionInfoPtr session_info, |
| 140 std::vector<blink::mojom::ConnectionMessagePtr> messages) override; | 153 std::vector<blink::mojom::ConnectionMessagePtr> messages) override; |
| 141 void OnDefaultSessionStarted( | 154 void OnDefaultSessionStarted( |
| 142 blink::mojom::PresentationSessionInfoPtr session_info) override; | 155 blink::mojom::PresentationSessionInfoPtr session_info) override; |
| 143 | 156 |
| 144 void OnSessionCreated( | 157 void OnSessionCreated( |
| 145 std::unique_ptr<blink::WebPresentationConnectionCallback> callback, | 158 std::unique_ptr<blink::WebPresentationConnectionCallbacks> callback, |
| 146 blink::mojom::PresentationSessionInfoPtr session_info, | 159 blink::mojom::PresentationSessionInfoPtr session_info, |
| 147 blink::mojom::PresentationErrorPtr error); | 160 blink::mojom::PresentationErrorPtr error); |
| 148 void OnReceiverConnectionAvailable( | 161 void OnReceiverConnectionAvailable( |
| 149 blink::mojom::PresentationSessionInfoPtr, | 162 blink::mojom::PresentationSessionInfoPtr, |
| 150 blink::mojom::PresentationConnectionPtr, | 163 blink::mojom::PresentationConnectionPtr, |
| 151 blink::mojom::PresentationConnectionRequest) override; | 164 blink::mojom::PresentationConnectionRequest) override; |
| 152 | 165 |
| 153 // Call to PresentationService to send the message in |request|. | 166 // Call to PresentationService to send the message in |request|. |
| 154 // |session_info| and |message| of |reuqest| will be consumed. | 167 // |session_info| and |message| of |reuqest| will be consumed. |
| 155 // |HandleSendMessageRequests| will be invoked after the send is attempted. | 168 // |HandleSendMessageRequests| will be invoked after the send is attempted. |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 201 // Updates the listening state of availability for |status| and notifies the | 214 // Updates the listening state of availability for |status| and notifies the |
| 202 // client. | 215 // client. |
| 203 void UpdateListeningState(AvailabilityStatus* status); | 216 void UpdateListeningState(AvailabilityStatus* status); |
| 204 | 217 |
| 205 DISALLOW_COPY_AND_ASSIGN(PresentationDispatcher); | 218 DISALLOW_COPY_AND_ASSIGN(PresentationDispatcher); |
| 206 }; | 219 }; |
| 207 | 220 |
| 208 } // namespace content | 221 } // namespace content |
| 209 | 222 |
| 210 #endif // CONTENT_RENDERER_PRESENTATION_PRESENTATION_DISPATCHER_H_ | 223 #endif // CONTENT_RENDERER_PRESENTATION_PRESENTATION_DISPATCHER_H_ |
| OLD | NEW |