| 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" |
| 11 #include <memory> |
| 10 | 12 |
| 11 namespace blink { | 13 namespace blink { |
| 12 | 14 |
| 13 PresentationController::PresentationController(LocalFrame& frame, WebPresentatio
nClient* client) | 15 PresentationController::PresentationController(LocalFrame& frame, WebPresentatio
nClient* client) |
| 14 : LocalFrameLifecycleObserver(&frame) | 16 : LocalFrameLifecycleObserver(&frame) |
| 15 , m_client(client) | 17 , m_client(client) |
| 16 { | 18 { |
| 17 if (m_client) | 19 if (m_client) |
| 18 m_client->setController(this); | 20 m_client->setController(this); |
| 19 } | 21 } |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 visitor->trace(m_presentation); | 60 visitor->trace(m_presentation); |
| 59 visitor->trace(m_connections); | 61 visitor->trace(m_connections); |
| 60 Supplement<LocalFrame>::trace(visitor); | 62 Supplement<LocalFrame>::trace(visitor); |
| 61 LocalFrameLifecycleObserver::trace(visitor); | 63 LocalFrameLifecycleObserver::trace(visitor); |
| 62 } | 64 } |
| 63 | 65 |
| 64 void PresentationController::didStartDefaultSession(WebPresentationConnectionCli
ent* connectionClient) | 66 void PresentationController::didStartDefaultSession(WebPresentationConnectionCli
ent* connectionClient) |
| 65 { | 67 { |
| 66 if (!m_presentation || !m_presentation->defaultRequest()) | 68 if (!m_presentation || !m_presentation->defaultRequest()) |
| 67 return; | 69 return; |
| 68 PresentationConnection::take(this, adoptPtr(connectionClient), m_presentatio
n->defaultRequest()); | 70 PresentationConnection::take(this, wrapUnique(connectionClient), m_presentat
ion->defaultRequest()); |
| 69 } | 71 } |
| 70 | 72 |
| 71 void PresentationController::didChangeSessionState(WebPresentationConnectionClie
nt* connectionClient, WebPresentationConnectionState state) | 73 void PresentationController::didChangeSessionState(WebPresentationConnectionClie
nt* connectionClient, WebPresentationConnectionState state) |
| 72 { | 74 { |
| 73 OwnPtr<WebPresentationConnectionClient> client = adoptPtr(connectionClient); | 75 std::unique_ptr<WebPresentationConnectionClient> client = wrapUnique(connect
ionClient); |
| 74 | 76 |
| 75 PresentationConnection* connection = findConnection(client.get()); | 77 PresentationConnection* connection = findConnection(client.get()); |
| 76 if (!connection) | 78 if (!connection) |
| 77 return; | 79 return; |
| 78 connection->didChangeState(state); | 80 connection->didChangeState(state); |
| 79 } | 81 } |
| 80 | 82 |
| 81 void PresentationController::didCloseConnection(WebPresentationConnectionClient*
connectionClient, WebPresentationConnectionCloseReason reason, const WebString&
message) | 83 void PresentationController::didCloseConnection(WebPresentationConnectionClient*
connectionClient, WebPresentationConnectionCloseReason reason, const WebString&
message) |
| 82 { | 84 { |
| 83 OwnPtr<WebPresentationConnectionClient> client = adoptPtr(connectionClient); | 85 std::unique_ptr<WebPresentationConnectionClient> client = wrapUnique(connect
ionClient); |
| 84 | 86 |
| 85 PresentationConnection* connection = findConnection(client.get()); | 87 PresentationConnection* connection = findConnection(client.get()); |
| 86 if (!connection) | 88 if (!connection) |
| 87 return; | 89 return; |
| 88 connection->didClose(reason, message); | 90 connection->didClose(reason, message); |
| 89 } | 91 } |
| 90 | 92 |
| 91 void PresentationController::didReceiveSessionTextMessage(WebPresentationConnect
ionClient* connectionClient, const WebString& message) | 93 void PresentationController::didReceiveSessionTextMessage(WebPresentationConnect
ionClient* connectionClient, const WebString& message) |
| 92 { | 94 { |
| 93 OwnPtr<WebPresentationConnectionClient> client = adoptPtr(connectionClient); | 95 std::unique_ptr<WebPresentationConnectionClient> client = wrapUnique(connect
ionClient); |
| 94 | 96 |
| 95 PresentationConnection* connection = findConnection(client.get()); | 97 PresentationConnection* connection = findConnection(client.get()); |
| 96 if (!connection) | 98 if (!connection) |
| 97 return; | 99 return; |
| 98 connection->didReceiveTextMessage(message); | 100 connection->didReceiveTextMessage(message); |
| 99 } | 101 } |
| 100 | 102 |
| 101 void PresentationController::didReceiveSessionBinaryMessage(WebPresentationConne
ctionClient* connectionClient, const uint8_t* data, size_t length) | 103 void PresentationController::didReceiveSessionBinaryMessage(WebPresentationConne
ctionClient* connectionClient, const uint8_t* data, size_t length) |
| 102 { | 104 { |
| 103 OwnPtr<WebPresentationConnectionClient> client = adoptPtr(connectionClient); | 105 std::unique_ptr<WebPresentationConnectionClient> client = wrapUnique(connect
ionClient); |
| 104 | 106 |
| 105 PresentationConnection* connection = findConnection(client.get()); | 107 PresentationConnection* connection = findConnection(client.get()); |
| 106 if (!connection) | 108 if (!connection) |
| 107 return; | 109 return; |
| 108 connection->didReceiveBinaryMessage(data, length); | 110 connection->didReceiveBinaryMessage(data, length); |
| 109 } | 111 } |
| 110 | 112 |
| 111 void PresentationController::setPresentation(Presentation* presentation) | 113 void PresentationController::setPresentation(Presentation* presentation) |
| 112 { | 114 { |
| 113 m_presentation = presentation; | 115 m_presentation = presentation; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 141 { | 143 { |
| 142 for (const auto& connection : m_connections) { | 144 for (const auto& connection : m_connections) { |
| 143 if (connection->matches(connectionClient)) | 145 if (connection->matches(connectionClient)) |
| 144 return connection.get(); | 146 return connection.get(); |
| 145 } | 147 } |
| 146 | 148 |
| 147 return nullptr; | 149 return nullptr; |
| 148 } | 150 } |
| 149 | 151 |
| 150 } // namespace blink | 152 } // namespace blink |
| OLD | NEW |