Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Side by Side Diff: Source/modules/mediastream/RTCDataChannel.cpp

Issue 342683002: Oilpan: Use weak processing to stop a closed RTCPeerConnection (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fixed Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 static void throwCouldNotSendDataException(ExceptionState& exceptionState) 44 static void throwCouldNotSendDataException(ExceptionState& exceptionState)
45 { 45 {
46 exceptionState.throwDOMException(NetworkError, "Could not send data"); 46 exceptionState.throwDOMException(NetworkError, "Could not send data");
47 } 47 }
48 48
49 static void throwNoBlobSupportException(ExceptionState& exceptionState) 49 static void throwNoBlobSupportException(ExceptionState& exceptionState)
50 { 50 {
51 exceptionState.throwDOMException(NotSupportedError, "Blob support not implem ented yet"); 51 exceptionState.throwDOMException(NotSupportedError, "Blob support not implem ented yet");
52 } 52 }
53 53
54 PassRefPtrWillBeRawPtr<RTCDataChannel> RTCDataChannel::create(ExecutionContext* context, PassOwnPtr<blink::WebRTCDataChannelHandler> handler) 54 PassRefPtrWillBeRawPtr<RTCDataChannel> RTCDataChannel::create(ExecutionContext* context, RTCPeerConnection* connection, PassOwnPtr<blink::WebRTCDataChannelHandl er> handler)
55 { 55 {
56 ASSERT(handler); 56 ASSERT(handler);
57 return adoptRefWillBeRefCountedGarbageCollected(new RTCDataChannel(context, handler)); 57 return adoptRefWillBeRefCountedGarbageCollected(new RTCDataChannel(context, connection, handler));
58 } 58 }
59 59
60 PassRefPtrWillBeRawPtr<RTCDataChannel> RTCDataChannel::create(ExecutionContext* context, blink::WebRTCPeerConnectionHandler* peerConnectionHandler, const String & label, const blink::WebRTCDataChannelInit& init, ExceptionState& exceptionStat e) 60 PassRefPtrWillBeRawPtr<RTCDataChannel> RTCDataChannel::create(ExecutionContext* context, RTCPeerConnection* connection, blink::WebRTCPeerConnectionHandler* peer ConnectionHandler, const String& label, const blink::WebRTCDataChannelInit& init , ExceptionState& exceptionState)
61 { 61 {
62 OwnPtr<blink::WebRTCDataChannelHandler> handler = adoptPtr(peerConnectionHan dler->createDataChannel(label, init)); 62 OwnPtr<blink::WebRTCDataChannelHandler> handler = adoptPtr(peerConnectionHan dler->createDataChannel(label, init));
63 if (!handler) { 63 if (!handler) {
64 exceptionState.throwDOMException(NotSupportedError, "RTCDataChannel is n ot supported"); 64 exceptionState.throwDOMException(NotSupportedError, "RTCDataChannel is n ot supported");
65 return nullptr; 65 return nullptr;
66 } 66 }
67 return adoptRefWillBeRefCountedGarbageCollected(new RTCDataChannel(context, handler.release())); 67 return adoptRefWillBeRefCountedGarbageCollected(new RTCDataChannel(context, connection, handler.release()));
68 } 68 }
69 69
70 RTCDataChannel::RTCDataChannel(ExecutionContext* context, PassOwnPtr<blink::WebR TCDataChannelHandler> handler) 70 RTCDataChannel::RTCDataChannel(ExecutionContext* context, RTCPeerConnection* con nection, PassOwnPtr<blink::WebRTCDataChannelHandler> handler)
71 : m_executionContext(context) 71 : m_executionContext(context)
72 , m_handler(handler) 72 , m_handler(handler)
73 , m_stopped(false) 73 , m_stopped(false)
74 , m_readyState(ReadyStateConnecting) 74 , m_readyState(ReadyStateConnecting)
75 , m_binaryType(BinaryTypeArrayBuffer) 75 , m_binaryType(BinaryTypeArrayBuffer)
76 , m_scheduledEventTimer(this, &RTCDataChannel::scheduledEventTimerFired) 76 , m_scheduledEventTimer(this, &RTCDataChannel::scheduledEventTimerFired)
77 #if ENABLE(OILPAN)
78 , m_connection(connection)
79 #endif
77 { 80 {
78 ScriptWrappable::init(this); 81 ScriptWrappable::init(this);
79 m_handler->setClient(this); 82 m_handler->setClient(this);
80 } 83 }
81 84
82 RTCDataChannel::~RTCDataChannel() 85 RTCDataChannel::~RTCDataChannel()
83 { 86 {
87 #if ENABLE(OILPAN)
88 // If the peer connection and the data channel die in the same
89 // GC cycle stop has not been called and we need to notify the
90 // client that the channel is gone.
91 if (!m_stopped)
92 m_handler->setClient(0);
93 #else
94 ASSERT(m_stopped);
Henrik Grunell 2014/06/18 11:49:13 I'm not sure why we would assert this?
Mads Ager (chromium) 2014/06/18 12:35:13 Is it not the case that an RTCDataChannel needs to
Henrik Grunell 2014/06/18 18:21:56 I'm by no means an expert on the data channels its
95 #endif
84 } 96 }
85 97
86 String RTCDataChannel::label() const 98 String RTCDataChannel::label() const
87 { 99 {
88 return m_handler->label(); 100 return m_handler->label();
89 } 101 }
90 102
91 bool RTCDataChannel::reliable() const 103 bool RTCDataChannel::reliable() const
92 { 104 {
93 return m_handler->isReliable(); 105 return m_handler->isReliable();
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 WillBeHeapVector<RefPtrWillBeMember<Event> > events; 318 WillBeHeapVector<RefPtrWillBeMember<Event> > events;
307 events.swap(m_scheduledEvents); 319 events.swap(m_scheduledEvents);
308 320
309 WillBeHeapVector<RefPtrWillBeMember<Event> >::iterator it = events.begin(); 321 WillBeHeapVector<RefPtrWillBeMember<Event> >::iterator it = events.begin();
310 for (; it != events.end(); ++it) 322 for (; it != events.end(); ++it)
311 dispatchEvent((*it).release()); 323 dispatchEvent((*it).release());
312 324
313 events.clear(); 325 events.clear();
314 } 326 }
315 327
328 #if ENABLE(OILPAN)
329 void RTCDataChannel::clearWeakMembers(Visitor* visitor)
330 {
331 if (visitor->isAlive(m_connection))
332 return;
333 stop();
334 m_connection = nullptr;
335 }
336 #endif
337
316 void RTCDataChannel::trace(Visitor* visitor) 338 void RTCDataChannel::trace(Visitor* visitor)
317 { 339 {
340 #if ENABLE(OILPAN)
318 visitor->trace(m_scheduledEvents); 341 visitor->trace(m_scheduledEvents);
342 visitor->registerWeakMembers<RTCDataChannel, &RTCDataChannel::clearWeakMembe rs>(this);
343 #endif
319 EventTargetWithInlineData::trace(visitor); 344 EventTargetWithInlineData::trace(visitor);
320 } 345 }
321 346
322 } // namespace WebCore 347 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/modules/mediastream/RTCDataChannel.h ('k') | Source/modules/mediastream/RTCPeerConnection.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698