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

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

Issue 329093002: Allow PeerConnection to be garbage collected after close(). (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Code review. 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 * 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 20 matching lines...) Expand all
31 #include "config.h" 31 #include "config.h"
32 32
33 #include "modules/mediastream/RTCVoidRequestImpl.h" 33 #include "modules/mediastream/RTCVoidRequestImpl.h"
34 34
35 #include "core/html/VoidCallback.h" 35 #include "core/html/VoidCallback.h"
36 #include "modules/mediastream/RTCErrorCallback.h" 36 #include "modules/mediastream/RTCErrorCallback.h"
37 #include "modules/mediastream/RTCPeerConnection.h" 37 #include "modules/mediastream/RTCPeerConnection.h"
38 38
39 namespace WebCore { 39 namespace WebCore {
40 40
41 PassRefPtr<RTCVoidRequestImpl> RTCVoidRequestImpl::create(ExecutionContext* cont ext, PassOwnPtr<VoidCallback> successCallback, PassOwnPtr<RTCErrorCallback> erro rCallback) 41 PassRefPtr<RTCVoidRequestImpl> RTCVoidRequestImpl::create(ExecutionContext* cont ext, PassRefPtrWillBeRawPtr<RTCPeerConnection> requester, PassOwnPtr<VoidCallbac k> successCallback, PassOwnPtr<RTCErrorCallback> errorCallback)
42 { 42 {
43 RefPtr<RTCVoidRequestImpl> request = adoptRef(new RTCVoidRequestImpl(context , successCallback, errorCallback)); 43 RefPtr<RTCVoidRequestImpl> request = adoptRef(new RTCVoidRequestImpl(context , requester, successCallback, errorCallback));
44 request->suspendIfNeeded(); 44 request->suspendIfNeeded();
45 return request.release(); 45 return request.release();
46 } 46 }
47 47
48 RTCVoidRequestImpl::RTCVoidRequestImpl(ExecutionContext* context, PassOwnPtr<Voi dCallback> successCallback, PassOwnPtr<RTCErrorCallback> errorCallback) 48 RTCVoidRequestImpl::RTCVoidRequestImpl(ExecutionContext* context, PassRefPtrWill BeRawPtr<RTCPeerConnection> requester, PassOwnPtr<VoidCallback> successCallback, PassOwnPtr<RTCErrorCallback> errorCallback)
49 : ActiveDOMObject(context) 49 : ActiveDOMObject(context)
50 , m_successCallback(successCallback) 50 , m_successCallback(successCallback)
51 , m_errorCallback(errorCallback) 51 , m_errorCallback(errorCallback)
52 , m_requester(requester)
52 { 53 {
54 ASSERT(m_requester);
53 } 55 }
54 56
55 RTCVoidRequestImpl::~RTCVoidRequestImpl() 57 RTCVoidRequestImpl::~RTCVoidRequestImpl()
56 { 58 {
57 } 59 }
58 60
59 void RTCVoidRequestImpl::requestSucceeded() 61 void RTCVoidRequestImpl::requestSucceeded()
60 { 62 {
61 if (m_successCallback) 63 bool mayFireCallback = m_requester ? m_requester->requestMayFireNonStatsCall back() : false;
64 if (mayFireCallback && m_successCallback)
62 m_successCallback->handleEvent(); 65 m_successCallback->handleEvent();
63 66
64 clear(); 67 clear();
65 } 68 }
66 69
67 void RTCVoidRequestImpl::requestFailed(const String& error) 70 void RTCVoidRequestImpl::requestFailed(const String& error)
68 { 71 {
69 if (m_errorCallback.get()) 72 bool mayFireCallback = m_requester ? m_requester->requestMayFireNonStatsCall back() : false;
73 if (mayFireCallback && m_errorCallback.get())
70 m_errorCallback->handleEvent(error); 74 m_errorCallback->handleEvent(error);
71 75
72 clear(); 76 clear();
73 } 77 }
74 78
75 void RTCVoidRequestImpl::stop() 79 void RTCVoidRequestImpl::stop()
76 { 80 {
77 clear(); 81 clear();
78 } 82 }
79 83
80 void RTCVoidRequestImpl::clear() 84 void RTCVoidRequestImpl::clear()
81 { 85 {
82 m_successCallback.clear(); 86 m_successCallback.clear();
83 m_errorCallback.clear(); 87 m_errorCallback.clear();
88 m_requester.clear();
84 } 89 }
85 90
86 } // namespace WebCore 91 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698