| 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/dom/Document.h" | 7 #include "core/dom/Document.h" |
| 8 #include "core/frame/LocalFrame.h" | 8 #include "core/frame/LocalFrame.h" |
| 9 #include "modules/presentation/PresentationConnection.h" | 9 #include "modules/presentation/PresentationConnection.h" |
| 10 #include "public/platform/WebString.h" | 10 #include "public/platform/WebString.h" |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 return m_client; | 59 return m_client; |
| 60 } | 60 } |
| 61 | 61 |
| 62 DEFINE_TRACE(PresentationController) { | 62 DEFINE_TRACE(PresentationController) { |
| 63 visitor->trace(m_presentation); | 63 visitor->trace(m_presentation); |
| 64 visitor->trace(m_connections); | 64 visitor->trace(m_connections); |
| 65 Supplement<LocalFrame>::trace(visitor); | 65 Supplement<LocalFrame>::trace(visitor); |
| 66 ContextLifecycleObserver::trace(visitor); | 66 ContextLifecycleObserver::trace(visitor); |
| 67 } | 67 } |
| 68 | 68 |
| 69 WebPresentationConnection* PresentationController::didStartDefaultSession( | 69 WebPresentationConnection* PresentationController::didStartDefaultPresentation( |
| 70 const WebPresentationSessionInfo& sessionInfo) { | 70 const WebPresentationInfo& presentationInfo) { |
| 71 if (!m_presentation || !m_presentation->defaultRequest()) | 71 if (!m_presentation || !m_presentation->defaultRequest()) |
| 72 return nullptr; | 72 return nullptr; |
| 73 | 73 |
| 74 return PresentationConnection::take(this, sessionInfo, | 74 return PresentationConnection::take(this, presentationInfo, |
| 75 m_presentation->defaultRequest()); | 75 m_presentation->defaultRequest()); |
| 76 } | 76 } |
| 77 | 77 |
| 78 void PresentationController::didChangeSessionState( | 78 void PresentationController::didChangeConnectionState( |
| 79 const WebPresentationSessionInfo& sessionInfo, | 79 const WebPresentationInfo& presentationInfo, |
| 80 WebPresentationConnectionState state) { | 80 WebPresentationConnectionState state) { |
| 81 PresentationConnection* connection = findConnection(sessionInfo); | 81 PresentationConnection* connection = findConnection(presentationInfo); |
| 82 if (!connection) | 82 if (!connection) |
| 83 return; | 83 return; |
| 84 connection->didChangeState(state); | 84 connection->didChangeState(state); |
| 85 } | 85 } |
| 86 | 86 |
| 87 void PresentationController::didCloseConnection( | 87 void PresentationController::didCloseConnection( |
| 88 const WebPresentationSessionInfo& sessionInfo, | 88 const WebPresentationInfo& presentationInfo, |
| 89 WebPresentationConnectionCloseReason reason, | 89 WebPresentationConnectionCloseReason reason, |
| 90 const WebString& message) { | 90 const WebString& message) { |
| 91 PresentationConnection* connection = findConnection(sessionInfo); | 91 PresentationConnection* connection = findConnection(presentationInfo); |
| 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::didReceiveConnectionTextMessage( |
| 98 const WebPresentationSessionInfo& sessionInfo, | 98 const WebPresentationInfo& presentationInfo, |
| 99 const WebString& message) { | 99 const WebString& message) { |
| 100 PresentationConnection* connection = findConnection(sessionInfo); | 100 PresentationConnection* connection = findConnection(presentationInfo); |
| 101 if (!connection) | 101 if (!connection) |
| 102 return; | 102 return; |
| 103 connection->didReceiveTextMessage(message); | 103 connection->didReceiveTextMessage(message); |
| 104 } | 104 } |
| 105 | 105 |
| 106 void PresentationController::didReceiveSessionBinaryMessage( | 106 void PresentationController::didReceiveConnectionBinaryMessage( |
| 107 const WebPresentationSessionInfo& sessionInfo, | 107 const WebPresentationInfo& presentationInfo, |
| 108 const uint8_t* data, | 108 const uint8_t* data, |
| 109 size_t length) { | 109 size_t length) { |
| 110 PresentationConnection* connection = findConnection(sessionInfo); | 110 PresentationConnection* connection = findConnection(presentationInfo); |
| 111 if (!connection) | 111 if (!connection) |
| 112 return; | 112 return; |
| 113 connection->didReceiveBinaryMessage(data, length); | 113 connection->didReceiveBinaryMessage(data, length); |
| 114 } | 114 } |
| 115 | 115 |
| 116 void PresentationController::setPresentation(Presentation* presentation) { | 116 void PresentationController::setPresentation(Presentation* presentation) { |
| 117 m_presentation = presentation; | 117 m_presentation = presentation; |
| 118 } | 118 } |
| 119 | 119 |
| 120 void PresentationController::setDefaultRequestUrl( | 120 void PresentationController::setDefaultRequestUrl( |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 WebPresentationConnectionState::Terminated && | 152 WebPresentationConnectionState::Terminated && |
| 153 connection->matches(presentationId, presentationUrl)) { | 153 connection->matches(presentationId, presentationUrl)) { |
| 154 return connection.get(); | 154 return connection.get(); |
| 155 } | 155 } |
| 156 } | 156 } |
| 157 } | 157 } |
| 158 return nullptr; | 158 return nullptr; |
| 159 } | 159 } |
| 160 | 160 |
| 161 PresentationConnection* PresentationController::findConnection( | 161 PresentationConnection* PresentationController::findConnection( |
| 162 const WebPresentationSessionInfo& sessionInfo) { | 162 const WebPresentationInfo& presentationInfo) { |
| 163 for (const auto& connection : m_connections) { | 163 for (const auto& connection : m_connections) { |
| 164 if (connection->matches(sessionInfo)) | 164 if (connection->matches(presentationInfo)) |
| 165 return connection.get(); | 165 return connection.get(); |
| 166 } | 166 } |
| 167 | 167 |
| 168 return nullptr; | 168 return nullptr; |
| 169 } | 169 } |
| 170 | 170 |
| 171 } // namespace blink | 171 } // namespace blink |
| OLD | NEW |