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