1/* 2 * Copyright (C) 2013 Nokia Corporation and/or its subsidiary(-ies). 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 1. Redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer. 9 * 2. Redistributions in binary form must reproduce the above copyright 10 * notice, this list of conditions and the following disclaimer in the 11 * documentation and/or other materials provided with the distribution. 12 * 13 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 14 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 15 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 16 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 17 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 18 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 19 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 20 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 21 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 */ 25 26#include "config.h" 27 28#if ENABLE(MEDIA_STREAM) 29 30#include "RTCNotifiersMock.h" 31 32#include "DOMError.h" 33#include "RTCDataChannelHandlerMock.h" 34#include "RTCSessionDescriptionDescriptor.h" 35#include "RTCSessionDescriptionRequest.h" 36#include "RTCVoidRequest.h" 37 38namespace WebCore { 39 40SessionRequestNotifier::SessionRequestNotifier(PassRefPtr<RTCSessionDescriptionRequest> request, PassRefPtr<RTCSessionDescriptionDescriptor> descriptor, const String& errorName) 41 : m_request(request) 42 , m_descriptor(descriptor) 43 , m_errorName(errorName) 44{ 45} 46 47void SessionRequestNotifier::fire() 48{ 49 if (m_descriptor) 50 m_request->requestSucceeded(m_descriptor); 51 else 52 m_request->requestFailed(m_errorName); 53} 54 55VoidRequestNotifier::VoidRequestNotifier(PassRefPtr<RTCVoidRequest> request, bool success, const String& errorName) 56 : m_request(request) 57 , m_success(success) 58 , m_errorName(errorName) 59{ 60} 61 62void VoidRequestNotifier::fire() 63{ 64 if (m_success) 65 m_request->requestSucceeded(); 66 else 67 m_request->requestFailed(m_errorName); 68} 69 70IceConnectionNotifier::IceConnectionNotifier(RTCPeerConnectionHandlerClient* client, RTCPeerConnectionHandlerClient::IceConnectionState connectionState, RTCPeerConnectionHandlerClient::IceGatheringState gatheringState) 71 : m_client(client) 72 , m_connectionState(connectionState) 73 , m_gatheringState(gatheringState) 74{ 75} 76 77void IceConnectionNotifier::fire() 78{ 79 m_client->didChangeIceGatheringState(m_gatheringState); 80 m_client->didChangeIceConnectionState(m_connectionState); 81} 82 83SignalingStateNotifier::SignalingStateNotifier(RTCPeerConnectionHandlerClient* client, RTCPeerConnectionHandlerClient::SignalingState signalingState) 84 : m_client(client) 85 , m_signalingState(signalingState) 86{ 87} 88 89void SignalingStateNotifier::fire() 90{ 91 m_client->didChangeSignalingState(m_signalingState); 92} 93 94RemoteDataChannelNotifier::RemoteDataChannelNotifier(RTCPeerConnectionHandlerClient* client) 95 : m_client(client) 96{ 97} 98 99void RemoteDataChannelNotifier::fire() 100{ 101 m_client->didAddRemoteDataChannel(std::make_unique<RTCDataChannelHandlerMock>("RTCDataChannelHandlerMock", RTCDataChannelInit())); 102} 103 104DataChannelStateNotifier::DataChannelStateNotifier(RTCDataChannelHandlerClient* client, RTCDataChannelHandlerClient::ReadyState state) 105 : m_client(client) 106 , m_state(state) 107{ 108} 109 110void DataChannelStateNotifier::fire() 111{ 112 m_client->didChangeReadyState(m_state); 113} 114 115} // namespace WebCore 116 117#endif // ENABLE(MEDIA_STREAM) 118