| 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 #include "modules/presentation/PresentationController.h" | 5 #include "modules/presentation/PresentationController.h" |
| 6 | 6 |
| 7 #include "core/frame/LocalFrame.h" | 7 #include "core/frame/LocalFrame.h" |
| 8 #include "modules/presentation/PresentationConnection.h" | 8 #include "modules/presentation/PresentationConnection.h" |
| 9 #include "public/platform/modules/presentation/WebPresentationClient.h" | 9 #include "public/platform/modules/presentation/WebPresentationClient.h" |
| 10 #include "wtf/PtrUtil.h" | 10 #include "wtf/PtrUtil.h" |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 visitor->trace(m_presentation); | 58 visitor->trace(m_presentation); |
| 59 visitor->trace(m_connections); | 59 visitor->trace(m_connections); |
| 60 Supplement<LocalFrame>::trace(visitor); | 60 Supplement<LocalFrame>::trace(visitor); |
| 61 DOMWindowProperty::trace(visitor); | 61 DOMWindowProperty::trace(visitor); |
| 62 } | 62 } |
| 63 | 63 |
| 64 void PresentationController::didStartDefaultSession( | 64 void PresentationController::didStartDefaultSession( |
| 65 WebPresentationConnectionClient* connectionClient) { | 65 WebPresentationConnectionClient* connectionClient) { |
| 66 if (!m_presentation || !m_presentation->defaultRequest()) | 66 if (!m_presentation || !m_presentation->defaultRequest()) |
| 67 return; | 67 return; |
| 68 PresentationConnection::take(this, wrapUnique(connectionClient), | 68 PresentationConnection::take(this, WTF::wrapUnique(connectionClient), |
| 69 m_presentation->defaultRequest()); | 69 m_presentation->defaultRequest()); |
| 70 } | 70 } |
| 71 | 71 |
| 72 void PresentationController::didChangeSessionState( | 72 void PresentationController::didChangeSessionState( |
| 73 WebPresentationConnectionClient* connectionClient, | 73 WebPresentationConnectionClient* connectionClient, |
| 74 WebPresentationConnectionState state) { | 74 WebPresentationConnectionState state) { |
| 75 std::unique_ptr<WebPresentationConnectionClient> client = | 75 std::unique_ptr<WebPresentationConnectionClient> client = |
| 76 wrapUnique(connectionClient); | 76 WTF::wrapUnique(connectionClient); |
| 77 | 77 |
| 78 PresentationConnection* connection = findConnection(client.get()); | 78 PresentationConnection* connection = findConnection(client.get()); |
| 79 if (!connection) | 79 if (!connection) |
| 80 return; | 80 return; |
| 81 connection->didChangeState(state); | 81 connection->didChangeState(state); |
| 82 } | 82 } |
| 83 | 83 |
| 84 void PresentationController::didCloseConnection( | 84 void PresentationController::didCloseConnection( |
| 85 WebPresentationConnectionClient* connectionClient, | 85 WebPresentationConnectionClient* connectionClient, |
| 86 WebPresentationConnectionCloseReason reason, | 86 WebPresentationConnectionCloseReason reason, |
| 87 const WebString& message) { | 87 const WebString& message) { |
| 88 std::unique_ptr<WebPresentationConnectionClient> client = | 88 std::unique_ptr<WebPresentationConnectionClient> client = |
| 89 wrapUnique(connectionClient); | 89 WTF::wrapUnique(connectionClient); |
| 90 | 90 |
| 91 PresentationConnection* connection = findConnection(client.get()); | 91 PresentationConnection* connection = findConnection(client.get()); |
| 92 if (!connection) | 92 if (!connection) |
| 93 return; | 93 return; |
| 94 connection->didClose(reason, message); | 94 connection->didClose(reason, message); |
| 95 } | 95 } |
| 96 | 96 |
| 97 void PresentationController::didReceiveSessionTextMessage( | 97 void PresentationController::didReceiveSessionTextMessage( |
| 98 WebPresentationConnectionClient* connectionClient, | 98 WebPresentationConnectionClient* connectionClient, |
| 99 const WebString& message) { | 99 const WebString& message) { |
| 100 std::unique_ptr<WebPresentationConnectionClient> client = | 100 std::unique_ptr<WebPresentationConnectionClient> client = |
| 101 wrapUnique(connectionClient); | 101 WTF::wrapUnique(connectionClient); |
| 102 | 102 |
| 103 PresentationConnection* connection = findConnection(client.get()); | 103 PresentationConnection* connection = findConnection(client.get()); |
| 104 if (!connection) | 104 if (!connection) |
| 105 return; | 105 return; |
| 106 connection->didReceiveTextMessage(message); | 106 connection->didReceiveTextMessage(message); |
| 107 } | 107 } |
| 108 | 108 |
| 109 void PresentationController::didReceiveSessionBinaryMessage( | 109 void PresentationController::didReceiveSessionBinaryMessage( |
| 110 WebPresentationConnectionClient* connectionClient, | 110 WebPresentationConnectionClient* connectionClient, |
| 111 const uint8_t* data, | 111 const uint8_t* data, |
| 112 size_t length) { | 112 size_t length) { |
| 113 std::unique_ptr<WebPresentationConnectionClient> client = | 113 std::unique_ptr<WebPresentationConnectionClient> client = |
| 114 wrapUnique(connectionClient); | 114 WTF::wrapUnique(connectionClient); |
| 115 | 115 |
| 116 PresentationConnection* connection = findConnection(client.get()); | 116 PresentationConnection* connection = findConnection(client.get()); |
| 117 if (!connection) | 117 if (!connection) |
| 118 return; | 118 return; |
| 119 connection->didReceiveBinaryMessage(data, length); | 119 connection->didReceiveBinaryMessage(data, length); |
| 120 } | 120 } |
| 121 | 121 |
| 122 void PresentationController::setPresentation(Presentation* presentation) { | 122 void PresentationController::setPresentation(Presentation* presentation) { |
| 123 m_presentation = presentation; | 123 m_presentation = presentation; |
| 124 } | 124 } |
| (...skipping 27 matching lines...) Expand all Loading... |
| 152 WebPresentationConnectionClient* connectionClient) { | 152 WebPresentationConnectionClient* connectionClient) { |
| 153 for (const auto& connection : m_connections) { | 153 for (const auto& connection : m_connections) { |
| 154 if (connection->matches(connectionClient)) | 154 if (connection->matches(connectionClient)) |
| 155 return connection.get(); | 155 return connection.get(); |
| 156 } | 156 } |
| 157 | 157 |
| 158 return nullptr; | 158 return nullptr; |
| 159 } | 159 } |
| 160 | 160 |
| 161 } // namespace blink | 161 } // namespace blink |
| OLD | NEW |