Bug 1044658 - 5/6 - remove asWeakPtr - r=froydnj

This commit is contained in:
Benoit Jacob 2014-07-30 15:52:05 -04:00
Родитель fca4408490
Коммит c50ccf8dba
15 изменённых файлов: 27 добавлений и 39 удалений

Просмотреть файл

@ -4334,7 +4334,7 @@ void
nsIDocument::SetContainer(nsDocShell* aContainer) nsIDocument::SetContainer(nsDocShell* aContainer)
{ {
if (aContainer) { if (aContainer) {
mDocumentContainer = aContainer->asWeakPtr(); mDocumentContainer = aContainer;
} else { } else {
mDocumentContainer = WeakPtr<nsDocShell>(); mDocumentContainer = WeakPtr<nsDocShell>();
} }

Просмотреть файл

@ -1042,7 +1042,7 @@ public:
PrepareEditorEvent(nsTextEditorState &aState, PrepareEditorEvent(nsTextEditorState &aState,
nsIContent *aOwnerContent, nsIContent *aOwnerContent,
const nsAString &aCurrentValue) const nsAString &aCurrentValue)
: mState(aState.asWeakPtr()) : mState(&aState)
, mOwnerContent(aOwnerContent) , mOwnerContent(aOwnerContent)
, mCurrentValue(aCurrentValue) , mCurrentValue(aCurrentValue)
{ {

Просмотреть файл

@ -72,7 +72,7 @@ AudioListener::SetOrientation(double aX, double aY, double aZ,
void void
AudioListener::RegisterPannerNode(PannerNode* aPannerNode) AudioListener::RegisterPannerNode(PannerNode* aPannerNode)
{ {
mPanners.AppendElement(aPannerNode->asWeakPtr()); mPanners.AppendElement(aPannerNode);
// Let the panner node know about our parameters // Let the panner node know about our parameters
aPannerNode->SendThreeDPointParameterToStream(PannerNode::LISTENER_POSITION, mPosition); aPannerNode->SendThreeDPointParameterToStream(PannerNode::LISTENER_POSITION, mPosition);

Просмотреть файл

@ -700,7 +700,7 @@ SpeechRecognition::Start(const Optional<NonNull<DOMMediaStream>>& aStream, Error
mRecognitionService = do_GetService(speechRecognitionServiceCID.get(), &rv); mRecognitionService = do_GetService(speechRecognitionServiceCID.get(), &rv);
NS_ENSURE_SUCCESS_VOID(rv); NS_ENSURE_SUCCESS_VOID(rv);
rv = mRecognitionService->Initialize(this->asWeakPtr()); rv = mRecognitionService->Initialize(this);
NS_ENSURE_SUCCESS_VOID(rv); NS_ENSURE_SUCCESS_VOID(rv);
MediaStreamConstraints constraints; MediaStreamConstraints constraints;

Просмотреть файл

@ -193,7 +193,7 @@ public:
MOZ_ASSERT(!aSrcFrame->GetIsPaletted()); MOZ_ASSERT(!aSrcFrame->GetIsPaletted());
MOZ_ASSERT(aScale.width > 0 && aScale.height > 0); MOZ_ASSERT(aScale.width > 0 && aScale.height > 0);
weakImage = aImage->asWeakPtr(); weakImage = aImage;
srcRect = aSrcFrame->GetRect(); srcRect = aSrcFrame->GetRect();
nsIntRect dstRect = srcRect; 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 // We only need to be careful about holding on to the image when it is
// discardable by the OS. // discardable by the OS.
if (CanForciblyDiscardAndRedecode()) { if (CanForciblyDiscardAndRedecode()) {
mImageContainerCache = mImageContainer->asWeakPtr(); mImageContainerCache = mImageContainer;
mImageContainer = nullptr; mImageContainer = nullptr;
} }

Просмотреть файл

@ -813,7 +813,7 @@ class imgDecodeRequestor : public nsRunnable
{ {
public: public:
imgDecodeRequestor(RasterImage &aContainer) { imgDecodeRequestor(RasterImage &aContainer) {
mContainer = aContainer.asWeakPtr(); mContainer = &aContainer;
} }
NS_IMETHOD Run() { NS_IMETHOD Run() {
if (mContainer) if (mContainer)

Просмотреть файл

@ -24,7 +24,7 @@ class imgStatusTrackerObserver : public imgDecoderObserver
{ {
public: public:
imgStatusTrackerObserver(imgStatusTracker* aTracker) imgStatusTrackerObserver(imgStatusTracker* aTracker)
: mTracker(aTracker->asWeakPtr()) : mTracker(aTracker)
{ {
MOZ_ASSERT(aTracker); MOZ_ASSERT(aTracker);
} }
@ -32,7 +32,7 @@ public:
void SetTracker(imgStatusTracker* aTracker) void SetTracker(imgStatusTracker* aTracker)
{ {
MOZ_ASSERT(aTracker); MOZ_ASSERT(aTracker);
mTracker = aTracker->asWeakPtr(); mTracker = aTracker;
} }
/** imgDecoderObserver methods **/ /** imgDecoderObserver methods **/
@ -553,7 +553,7 @@ imgStatusTracker::SyncNotify(imgRequestProxy* proxy)
} }
ProxyArray array; ProxyArray array;
array.AppendElement(proxy->asWeakPtr()); array.AppendElement(proxy);
SyncNotifyState(array, !!mImage, mState, r, mHadLastPart); SyncNotifyState(array, !!mImage, mState, r, mHadLastPart);
} }
@ -584,7 +584,7 @@ void
imgStatusTracker::AddConsumer(imgRequestProxy* aConsumer) imgStatusTracker::AddConsumer(imgRequestProxy* aConsumer)
{ {
MOZ_ASSERT(NS_IsMainThread()); MOZ_ASSERT(NS_IsMainThread());
mConsumers.AppendElementUnlessExists(aConsumer->asWeakPtr()); mConsumers.AppendElementUnlessExists(aConsumer);
} }
// XXX - The last argument should go away. // XXX - The last argument should go away.

Просмотреть файл

@ -189,7 +189,7 @@ private:
}; };
MessageChannel::MessageChannel(MessageListener *aListener) MessageChannel::MessageChannel(MessageListener *aListener)
: mListener(aListener->asWeakPtr()), : mListener(aListener),
mChannelState(ChannelClosed), mChannelState(ChannelClosed),
mSide(UnknownSide), mSide(UnknownSide),
mLink(nullptr), mLink(nullptr),

Просмотреть файл

@ -600,7 +600,7 @@ nsDocumentViewer::SyncParentSubDocMap()
NS_IMETHODIMP NS_IMETHODIMP
nsDocumentViewer::SetContainer(nsIDocShell* aContainer) nsDocumentViewer::SetContainer(nsIDocShell* aContainer)
{ {
mContainer = static_cast<nsDocShell*>(aContainer)->asWeakPtr(); mContainer = static_cast<nsDocShell*>(aContainer);
if (mPresContext) { if (mPresContext) {
mPresContext->SetContainer(mContainer); mPresContext->SetContainer(mContainer);
} }
@ -1537,7 +1537,7 @@ DetachContainerRecurse(nsIDocShell *aShell)
nsCOMPtr<nsIPresShell> presShell; nsCOMPtr<nsIPresShell> presShell;
viewer->GetPresShell(getter_AddRefs(presShell)); viewer->GetPresShell(getter_AddRefs(presShell));
if (presShell) { if (presShell) {
auto weakShell = static_cast<nsDocShell*>(aShell)->asWeakPtr(); auto weakShell = static_cast<nsDocShell*>(aShell);
presShell->SetForwardingContainer(weakShell); presShell->SetForwardingContainer(weakShell);
} }
} }

Просмотреть файл

@ -1516,7 +1516,7 @@ void
nsPresContext::SetContainer(nsIDocShell* aDocShell) nsPresContext::SetContainer(nsIDocShell* aDocShell)
{ {
if (aDocShell) { if (aDocShell) {
mContainer = static_cast<nsDocShell*>(aDocShell)->asWeakPtr(); mContainer = static_cast<nsDocShell*>(aDocShell);
} else { } else {
mContainer = WeakPtr<nsDocShell>(); mContainer = WeakPtr<nsDocShell>();
} }

Просмотреть файл

@ -38,12 +38,12 @@
* *
* C* ptr = new C(); * C* ptr = new C();
* *
* // Get weak pointers to ptr. The first time asWeakPtr is called * // Get weak pointers to ptr. The first time a weak pointer
* // a reference counted WeakReference object is created that * // is obtained, a reference counted WeakReference object is created that
* // can live beyond the lifetime of 'ptr'. The WeakReference * // can live beyond the lifetime of 'ptr'. The WeakReference
* // object will be notified of 'ptr's destruction. * // object will be notified of 'ptr's destruction.
* WeakPtr<C> weak = ptr->asWeakPtr(); * WeakPtr<C> weak = ptr;
* WeakPtr<C> other = ptr->asWeakPtr(); * WeakPtr<C> other = ptr;
* *
* // Test a weak pointer for validity before using it. * // Test a weak pointer for validity before using it.
* if (weak) { * if (weak) {
@ -130,18 +130,6 @@ private:
template <typename T> template <typename T>
class SupportsWeakPtr class SupportsWeakPtr
{ {
public:
const T* asWeakPtr() const
{
return static_cast<const T*>(this);
}
T* asWeakPtr()
{
return static_cast<T*>(this);
}
protected: protected:
~SupportsWeakPtr() ~SupportsWeakPtr()
{ {

Просмотреть файл

@ -27,8 +27,8 @@ Example()
// a reference counted WeakReference object is created that // a reference counted WeakReference object is created that
// can live beyond the lifetime of 'ptr'. The WeakReference // can live beyond the lifetime of 'ptr'. The WeakReference
// object will be notified of 'ptr's destruction. // object will be notified of 'ptr's destruction.
WeakPtr<C> weak = ptr->asWeakPtr(); WeakPtr<C> weak = ptr;
WeakPtr<C> other = ptr->asWeakPtr(); WeakPtr<C> other = ptr;
// Test a weak pointer for validity before using it. // Test a weak pointer for validity before using it.
if (weak) { if (weak) {
@ -59,11 +59,11 @@ main()
A* a2 = new A; A* a2 = new A;
a->mData = 5; 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); MOZ_RELEASE_ASSERT(ptr->mData == 5);
WeakPtr<A> ptr3 = a->asWeakPtr(); WeakPtr<A> ptr3 = a;
MOZ_RELEASE_ASSERT(ptr->mData == 5); MOZ_RELEASE_ASSERT(ptr->mData == 5);
} }

Просмотреть файл

@ -200,7 +200,7 @@ DataChannelConnection::DataChannelConnection(DataConnectionListener *listener) :
mState = CLOSED; mState = CLOSED;
mSocket = nullptr; mSocket = nullptr;
mMasterSocket = nullptr; mMasterSocket = nullptr;
mListener = listener->asWeakPtr(); mListener = listener;
mLocalPort = 0; mLocalPort = 0;
mRemotePort = 0; mRemotePort = 0;
mDeferTimeout = 10; mDeferTimeout = 10;

Просмотреть файл

@ -1985,7 +1985,7 @@ void
nsOfflineCacheUpdate::SetOwner(nsOfflineCacheUpdateOwner *aOwner) nsOfflineCacheUpdate::SetOwner(nsOfflineCacheUpdateOwner *aOwner)
{ {
NS_ASSERTION(!mOwner, "Tried to set cache update owner twice."); NS_ASSERTION(!mOwner, "Tried to set cache update owner twice.");
mOwner = aOwner->asWeakPtr(); mOwner = aOwner;
} }
bool bool

Просмотреть файл

@ -121,7 +121,7 @@ MessageLoopIdleTask::Run()
} }
MessageLoopTimerCallback::MessageLoopTimerCallback(MessageLoopIdleTask* aTask) MessageLoopTimerCallback::MessageLoopTimerCallback(MessageLoopIdleTask* aTask)
: mTask(aTask->asWeakPtr()) : mTask(aTask)
{ {
} }