| 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/PresentationReceiver.h" | 5 #include "modules/presentation/PresentationReceiver.h" |
| 6 | 6 |
| 7 #include "bindings/core/v8/ScriptPromise.h" | 7 #include "bindings/core/v8/ScriptPromise.h" |
| 8 #include "bindings/core/v8/ScriptPromiseResolver.h" | 8 #include "bindings/core/v8/ScriptPromiseResolver.h" |
| 9 #include "core/dom/DOMException.h" | 9 #include "core/dom/DOMException.h" |
| 10 #include "core/dom/Document.h" | 10 #include "core/dom/Document.h" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 ConnectionListProperty::Ready); | 32 ConnectionListProperty::Ready); |
| 33 | 33 |
| 34 if (!m_connectionList->isEmpty() && | 34 if (!m_connectionList->isEmpty() && |
| 35 m_connectionListProperty->getState() == | 35 m_connectionListProperty->getState() == |
| 36 ScriptPromisePropertyBase::Pending) | 36 ScriptPromisePropertyBase::Pending) |
| 37 m_connectionListProperty->resolve(m_connectionList); | 37 m_connectionListProperty->resolve(m_connectionList); |
| 38 | 38 |
| 39 return m_connectionListProperty->promise(scriptState->world()); | 39 return m_connectionListProperty->promise(scriptState->world()); |
| 40 } | 40 } |
| 41 | 41 |
| 42 void PresentationReceiver::onReceiverConnectionAvailable( | 42 WebPresentationConnection* PresentationReceiver::onReceiverConnectionAvailable( |
| 43 const WebPresentationSessionInfo& sessionInfo) { | 43 const WebPresentationSessionInfo& sessionInfo) { |
| 44 // take() will call PresentationReceiver::registerConnection() | 44 // take() will call PresentationReceiver::registerConnection() |
| 45 // and register the connection. | 45 // and register the connection. |
| 46 auto connection = PresentationConnection::take(this, sessionInfo); | 46 auto connection = PresentationConnection::take(this, sessionInfo); |
| 47 | 47 |
| 48 // receiver.connectionList property not accessed | 48 // receiver.connectionList property not accessed |
| 49 if (!m_connectionListProperty) | 49 if (!m_connectionListProperty) |
| 50 return; | 50 return nullptr; |
| 51 | 51 |
| 52 if (m_connectionListProperty->getState() == | 52 if (m_connectionListProperty->getState() == |
| 53 ScriptPromisePropertyBase::Pending) | 53 ScriptPromisePropertyBase::Pending) |
| 54 m_connectionListProperty->resolve(m_connectionList); | 54 m_connectionListProperty->resolve(m_connectionList); |
| 55 else if (m_connectionListProperty->getState() == | 55 else if (m_connectionListProperty->getState() == |
| 56 ScriptPromisePropertyBase::Resolved) | 56 ScriptPromisePropertyBase::Resolved) |
| 57 m_connectionList->dispatchConnectionAvailableEvent(connection); | 57 m_connectionList->dispatchConnectionAvailableEvent(connection); |
| 58 |
| 59 return connection; |
| 58 } | 60 } |
| 59 | 61 |
| 60 void PresentationReceiver::registerConnection( | 62 void PresentationReceiver::registerConnection( |
| 61 PresentationConnection* connection) { | 63 PresentationConnection* connection) { |
| 62 DCHECK(m_connectionList); | 64 DCHECK(m_connectionList); |
| 63 m_connectionList->addConnection(connection); | 65 m_connectionList->addConnection(connection); |
| 64 } | 66 } |
| 65 | 67 |
| 66 DEFINE_TRACE(PresentationReceiver) { | 68 DEFINE_TRACE(PresentationReceiver) { |
| 67 visitor->trace(m_connectionList); | 69 visitor->trace(m_connectionList); |
| 68 visitor->trace(m_connectionListProperty); | 70 visitor->trace(m_connectionListProperty); |
| 69 ContextClient::trace(visitor); | 71 ContextClient::trace(visitor); |
| 70 } | 72 } |
| 71 | 73 |
| 72 } // namespace blink | 74 } // namespace blink |
| OLD | NEW |