| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * | 7 * |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 bool throwExceptionIfSignalingStateClosed(RTCPeerConnection::SignalingState stat
e, ExceptionState& exceptionState) | 93 bool throwExceptionIfSignalingStateClosed(RTCPeerConnection::SignalingState stat
e, ExceptionState& exceptionState) |
| 94 { | 94 { |
| 95 if (state == RTCPeerConnection::SignalingStateClosed) { | 95 if (state == RTCPeerConnection::SignalingStateClosed) { |
| 96 exceptionState.throwDOMException(InvalidStateError, kSignalingStateClose
dMessage); | 96 exceptionState.throwDOMException(InvalidStateError, kSignalingStateClose
dMessage); |
| 97 return true; | 97 return true; |
| 98 } | 98 } |
| 99 | 99 |
| 100 return false; | 100 return false; |
| 101 } | 101 } |
| 102 | 102 |
| 103 // Helper class for running error callbacks asynchronously | |
| 104 class ErrorCallbackTask : public WebTaskRunner::Task { | |
| 105 public: | |
| 106 static PassOwnPtr<ErrorCallbackTask> create(RTCPeerConnectionErrorCallback*
errorCallback, DOMException* exception) | |
| 107 { | |
| 108 return adoptPtr(new ErrorCallbackTask(errorCallback, exception)); | |
| 109 } | |
| 110 | |
| 111 ~ErrorCallbackTask() override = default; | |
| 112 | |
| 113 void run() override | |
| 114 { | |
| 115 m_errorCallback->handleEvent(m_exception); | |
| 116 } | |
| 117 | |
| 118 private: | |
| 119 ErrorCallbackTask(RTCPeerConnectionErrorCallback* errorCallback, DOMExceptio
n* exception) | |
| 120 : m_errorCallback(errorCallback) | |
| 121 , m_exception(exception) | |
| 122 { | |
| 123 ASSERT(errorCallback); | |
| 124 } | |
| 125 | |
| 126 Persistent<RTCPeerConnectionErrorCallback> m_errorCallback; | |
| 127 Persistent<DOMException> m_exception; | |
| 128 }; | |
| 129 | |
| 130 void asyncCallErrorCallback(RTCPeerConnectionErrorCallback* errorCallback, DOMEx
ception* exception) | 103 void asyncCallErrorCallback(RTCPeerConnectionErrorCallback* errorCallback, DOMEx
ception* exception) |
| 131 { | 104 { |
| 132 Microtask::enqueueMicrotask(ErrorCallbackTask::create(errorCallback, excepti
on)); | 105 ASSERT(errorCallback); |
| 106 Microtask::enqueueMicrotask(bind(&RTCPeerConnectionErrorCallback::handleEven
t, errorCallback, exception)); |
| 133 } | 107 } |
| 134 | 108 |
| 135 bool callErrorCallbackIfSignalingStateClosed(RTCPeerConnection::SignalingState s
tate, RTCPeerConnectionErrorCallback* errorCallback) | 109 bool callErrorCallbackIfSignalingStateClosed(RTCPeerConnection::SignalingState s
tate, RTCPeerConnectionErrorCallback* errorCallback) |
| 136 { | 110 { |
| 137 if (state == RTCPeerConnection::SignalingStateClosed) { | 111 if (state == RTCPeerConnection::SignalingStateClosed) { |
| 138 if (errorCallback) | 112 if (errorCallback) |
| 139 asyncCallErrorCallback(errorCallback, DOMException::create(InvalidSt
ateError, kSignalingStateClosedMessage)); | 113 asyncCallErrorCallback(errorCallback, DOMException::create(InvalidSt
ateError, kSignalingStateClosedMessage)); |
| 140 | 114 |
| 141 return true; | 115 return true; |
| 142 } | 116 } |
| (...skipping 1016 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1159 { | 1133 { |
| 1160 visitor->trace(m_localStreams); | 1134 visitor->trace(m_localStreams); |
| 1161 visitor->trace(m_remoteStreams); | 1135 visitor->trace(m_remoteStreams); |
| 1162 visitor->trace(m_dispatchScheduledEventRunner); | 1136 visitor->trace(m_dispatchScheduledEventRunner); |
| 1163 visitor->trace(m_scheduledEvents); | 1137 visitor->trace(m_scheduledEvents); |
| 1164 RefCountedGarbageCollectedEventTargetWithInlineData<RTCPeerConnection>::trac
e(visitor); | 1138 RefCountedGarbageCollectedEventTargetWithInlineData<RTCPeerConnection>::trac
e(visitor); |
| 1165 ActiveDOMObject::trace(visitor); | 1139 ActiveDOMObject::trace(visitor); |
| 1166 } | 1140 } |
| 1167 | 1141 |
| 1168 } // namespace blink | 1142 } // namespace blink |
| OLD | NEW |