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

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 m_handler->setClient(0);
Mads Ager (chromium) 2014/06/18 09:09:26 Do we need to guard this: if (!m_stopped) m_h
haraken 2014/06/18 09:17:08 Looks nicer.
keishi 2014/06/18 10:48:00 Done.
84 } 88 }
85 89
86 String RTCDataChannel::label() const 90 String RTCDataChannel::label() const
87 { 91 {
88 return m_handler->label(); 92 return m_handler->label();
89 } 93 }
90 94
91 bool RTCDataChannel::reliable() const 95 bool RTCDataChannel::reliable() const
92 { 96 {
93 return m_handler->isReliable(); 97 return m_handler->isReliable();
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 WillBeHeapVector<RefPtrWillBeMember<Event> > events; 310 WillBeHeapVector<RefPtrWillBeMember<Event> > events;
307 events.swap(m_scheduledEvents); 311 events.swap(m_scheduledEvents);
308 312
309 WillBeHeapVector<RefPtrWillBeMember<Event> >::iterator it = events.begin(); 313 WillBeHeapVector<RefPtrWillBeMember<Event> >::iterator it = events.begin();
310 for (; it != events.end(); ++it) 314 for (; it != events.end(); ++it)
311 dispatchEvent((*it).release()); 315 dispatchEvent((*it).release());
312 316
313 events.clear(); 317 events.clear();
314 } 318 }
315 319
320 #if ENABLE(OILPAN)
321 void RTCDataChannel::clearWeakMembers(Visitor* visitor)
322 {
323 if (!visitor->isAlive(m_connection))
324 stop();
325 }
326 #endif
327
316 void RTCDataChannel::trace(Visitor* visitor) 328 void RTCDataChannel::trace(Visitor* visitor)
317 { 329 {
318 visitor->trace(m_scheduledEvents); 330 visitor->trace(m_scheduledEvents);
331 #if ENABLE(OILPAN)
Mads Ager (chromium) 2014/06/18 09:09:26 Do you need this #if? If you do I would just put t
keishi 2014/06/18 10:48:00 Done. We need it because m_connection is oilpan on
332 visitor->trace(m_connection);
haraken 2014/06/18 09:17:08 You can remove this trace, and explicitly do 'm_co
Mads Ager (chromium) 2014/06/18 09:32:45 Auch, good catch Haraken! Actually you *have* to r
keishi 2014/06/18 10:48:00 Done.
333 visitor->registerWeakMembers<RTCDataChannel, &RTCDataChannel::clearWeakMembe rs>(this);
334 #endif
319 EventTargetWithInlineData::trace(visitor); 335 EventTargetWithInlineData::trace(visitor);
320 } 336 }
321 337
322 } // namespace WebCore 338 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698