зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1044658 - 5/6 - remove asWeakPtr - r=froydnj
This commit is contained in:
Родитель
fca4408490
Коммит
c50ccf8dba
|
@ -4334,7 +4334,7 @@ void
|
|||
nsIDocument::SetContainer(nsDocShell* aContainer)
|
||||
{
|
||||
if (aContainer) {
|
||||
mDocumentContainer = aContainer->asWeakPtr();
|
||||
mDocumentContainer = aContainer;
|
||||
} else {
|
||||
mDocumentContainer = WeakPtr<nsDocShell>();
|
||||
}
|
||||
|
|
|
@ -1042,7 +1042,7 @@ public:
|
|||
PrepareEditorEvent(nsTextEditorState &aState,
|
||||
nsIContent *aOwnerContent,
|
||||
const nsAString &aCurrentValue)
|
||||
: mState(aState.asWeakPtr())
|
||||
: mState(&aState)
|
||||
, mOwnerContent(aOwnerContent)
|
||||
, mCurrentValue(aCurrentValue)
|
||||
{
|
||||
|
|
|
@ -72,7 +72,7 @@ AudioListener::SetOrientation(double aX, double aY, double aZ,
|
|||
void
|
||||
AudioListener::RegisterPannerNode(PannerNode* aPannerNode)
|
||||
{
|
||||
mPanners.AppendElement(aPannerNode->asWeakPtr());
|
||||
mPanners.AppendElement(aPannerNode);
|
||||
|
||||
// Let the panner node know about our parameters
|
||||
aPannerNode->SendThreeDPointParameterToStream(PannerNode::LISTENER_POSITION, mPosition);
|
||||
|
|
|
@ -700,7 +700,7 @@ SpeechRecognition::Start(const Optional<NonNull<DOMMediaStream>>& aStream, Error
|
|||
mRecognitionService = do_GetService(speechRecognitionServiceCID.get(), &rv);
|
||||
NS_ENSURE_SUCCESS_VOID(rv);
|
||||
|
||||
rv = mRecognitionService->Initialize(this->asWeakPtr());
|
||||
rv = mRecognitionService->Initialize(this);
|
||||
NS_ENSURE_SUCCESS_VOID(rv);
|
||||
|
||||
MediaStreamConstraints constraints;
|
||||
|
|
|
@ -193,7 +193,7 @@ public:
|
|||
MOZ_ASSERT(!aSrcFrame->GetIsPaletted());
|
||||
MOZ_ASSERT(aScale.width > 0 && aScale.height > 0);
|
||||
|
||||
weakImage = aImage->asWeakPtr();
|
||||
weakImage = aImage;
|
||||
srcRect = aSrcFrame->GetRect();
|
||||
|
||||
nsIntRect dstRect = srcRect;
|
||||
|
@ -1041,7 +1041,7 @@ RasterImage::GetImageContainer(LayerManager* aManager, ImageContainer **_retval)
|
|||
// We only need to be careful about holding on to the image when it is
|
||||
// discardable by the OS.
|
||||
if (CanForciblyDiscardAndRedecode()) {
|
||||
mImageContainerCache = mImageContainer->asWeakPtr();
|
||||
mImageContainerCache = mImageContainer;
|
||||
mImageContainer = nullptr;
|
||||
}
|
||||
|
||||
|
|
|
@ -813,7 +813,7 @@ class imgDecodeRequestor : public nsRunnable
|
|||
{
|
||||
public:
|
||||
imgDecodeRequestor(RasterImage &aContainer) {
|
||||
mContainer = aContainer.asWeakPtr();
|
||||
mContainer = &aContainer;
|
||||
}
|
||||
NS_IMETHOD Run() {
|
||||
if (mContainer)
|
||||
|
|
|
@ -24,7 +24,7 @@ class imgStatusTrackerObserver : public imgDecoderObserver
|
|||
{
|
||||
public:
|
||||
imgStatusTrackerObserver(imgStatusTracker* aTracker)
|
||||
: mTracker(aTracker->asWeakPtr())
|
||||
: mTracker(aTracker)
|
||||
{
|
||||
MOZ_ASSERT(aTracker);
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ public:
|
|||
void SetTracker(imgStatusTracker* aTracker)
|
||||
{
|
||||
MOZ_ASSERT(aTracker);
|
||||
mTracker = aTracker->asWeakPtr();
|
||||
mTracker = aTracker;
|
||||
}
|
||||
|
||||
/** imgDecoderObserver methods **/
|
||||
|
@ -553,7 +553,7 @@ imgStatusTracker::SyncNotify(imgRequestProxy* proxy)
|
|||
}
|
||||
|
||||
ProxyArray array;
|
||||
array.AppendElement(proxy->asWeakPtr());
|
||||
array.AppendElement(proxy);
|
||||
SyncNotifyState(array, !!mImage, mState, r, mHadLastPart);
|
||||
}
|
||||
|
||||
|
@ -584,7 +584,7 @@ void
|
|||
imgStatusTracker::AddConsumer(imgRequestProxy* aConsumer)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
mConsumers.AppendElementUnlessExists(aConsumer->asWeakPtr());
|
||||
mConsumers.AppendElementUnlessExists(aConsumer);
|
||||
}
|
||||
|
||||
// XXX - The last argument should go away.
|
||||
|
|
|
@ -189,7 +189,7 @@ private:
|
|||
};
|
||||
|
||||
MessageChannel::MessageChannel(MessageListener *aListener)
|
||||
: mListener(aListener->asWeakPtr()),
|
||||
: mListener(aListener),
|
||||
mChannelState(ChannelClosed),
|
||||
mSide(UnknownSide),
|
||||
mLink(nullptr),
|
||||
|
|
|
@ -600,7 +600,7 @@ nsDocumentViewer::SyncParentSubDocMap()
|
|||
NS_IMETHODIMP
|
||||
nsDocumentViewer::SetContainer(nsIDocShell* aContainer)
|
||||
{
|
||||
mContainer = static_cast<nsDocShell*>(aContainer)->asWeakPtr();
|
||||
mContainer = static_cast<nsDocShell*>(aContainer);
|
||||
if (mPresContext) {
|
||||
mPresContext->SetContainer(mContainer);
|
||||
}
|
||||
|
@ -1537,7 +1537,7 @@ DetachContainerRecurse(nsIDocShell *aShell)
|
|||
nsCOMPtr<nsIPresShell> presShell;
|
||||
viewer->GetPresShell(getter_AddRefs(presShell));
|
||||
if (presShell) {
|
||||
auto weakShell = static_cast<nsDocShell*>(aShell)->asWeakPtr();
|
||||
auto weakShell = static_cast<nsDocShell*>(aShell);
|
||||
presShell->SetForwardingContainer(weakShell);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1516,7 +1516,7 @@ void
|
|||
nsPresContext::SetContainer(nsIDocShell* aDocShell)
|
||||
{
|
||||
if (aDocShell) {
|
||||
mContainer = static_cast<nsDocShell*>(aDocShell)->asWeakPtr();
|
||||
mContainer = static_cast<nsDocShell*>(aDocShell);
|
||||
} else {
|
||||
mContainer = WeakPtr<nsDocShell>();
|
||||
}
|
||||
|
|
|
@ -38,12 +38,12 @@
|
|||
*
|
||||
* C* ptr = new C();
|
||||
*
|
||||
* // Get weak pointers to ptr. The first time asWeakPtr is called
|
||||
* // a reference counted WeakReference object is created that
|
||||
* // Get weak pointers to ptr. The first time a weak pointer
|
||||
* // is obtained, a reference counted WeakReference object is created that
|
||||
* // can live beyond the lifetime of 'ptr'. The WeakReference
|
||||
* // object will be notified of 'ptr's destruction.
|
||||
* WeakPtr<C> weak = ptr->asWeakPtr();
|
||||
* WeakPtr<C> other = ptr->asWeakPtr();
|
||||
* WeakPtr<C> weak = ptr;
|
||||
* WeakPtr<C> other = ptr;
|
||||
*
|
||||
* // Test a weak pointer for validity before using it.
|
||||
* if (weak) {
|
||||
|
@ -130,18 +130,6 @@ private:
|
|||
template <typename T>
|
||||
class SupportsWeakPtr
|
||||
{
|
||||
public:
|
||||
|
||||
const T* asWeakPtr() const
|
||||
{
|
||||
return static_cast<const T*>(this);
|
||||
}
|
||||
|
||||
T* asWeakPtr()
|
||||
{
|
||||
return static_cast<T*>(this);
|
||||
}
|
||||
|
||||
protected:
|
||||
~SupportsWeakPtr()
|
||||
{
|
||||
|
|
|
@ -27,8 +27,8 @@ Example()
|
|||
// a reference counted WeakReference object is created that
|
||||
// can live beyond the lifetime of 'ptr'. The WeakReference
|
||||
// object will be notified of 'ptr's destruction.
|
||||
WeakPtr<C> weak = ptr->asWeakPtr();
|
||||
WeakPtr<C> other = ptr->asWeakPtr();
|
||||
WeakPtr<C> weak = ptr;
|
||||
WeakPtr<C> other = ptr;
|
||||
|
||||
// Test a weak pointer for validity before using it.
|
||||
if (weak) {
|
||||
|
@ -59,11 +59,11 @@ main()
|
|||
A* a2 = new A;
|
||||
|
||||
a->mData = 5;
|
||||
WeakPtr<A> ptr = a->asWeakPtr();
|
||||
WeakPtr<A> ptr = a;
|
||||
{
|
||||
WeakPtr<A> ptr2 = a->asWeakPtr();
|
||||
WeakPtr<A> ptr2 = a;
|
||||
MOZ_RELEASE_ASSERT(ptr->mData == 5);
|
||||
WeakPtr<A> ptr3 = a->asWeakPtr();
|
||||
WeakPtr<A> ptr3 = a;
|
||||
MOZ_RELEASE_ASSERT(ptr->mData == 5);
|
||||
}
|
||||
|
||||
|
|
|
@ -200,7 +200,7 @@ DataChannelConnection::DataChannelConnection(DataConnectionListener *listener) :
|
|||
mState = CLOSED;
|
||||
mSocket = nullptr;
|
||||
mMasterSocket = nullptr;
|
||||
mListener = listener->asWeakPtr();
|
||||
mListener = listener;
|
||||
mLocalPort = 0;
|
||||
mRemotePort = 0;
|
||||
mDeferTimeout = 10;
|
||||
|
|
|
@ -1985,7 +1985,7 @@ void
|
|||
nsOfflineCacheUpdate::SetOwner(nsOfflineCacheUpdateOwner *aOwner)
|
||||
{
|
||||
NS_ASSERTION(!mOwner, "Tried to set cache update owner twice.");
|
||||
mOwner = aOwner->asWeakPtr();
|
||||
mOwner = aOwner;
|
||||
}
|
||||
|
||||
bool
|
||||
|
|
|
@ -121,7 +121,7 @@ MessageLoopIdleTask::Run()
|
|||
}
|
||||
|
||||
MessageLoopTimerCallback::MessageLoopTimerCallback(MessageLoopIdleTask* aTask)
|
||||
: mTask(aTask->asWeakPtr())
|
||||
: mTask(aTask)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче