зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1222867 - part 1 - return already_AddRefed from WebSocketEventService::CreateFrameIfNeeded; r=mcmanus
The result of CreateFrameIfNeeded is always assigned to a RefPtr, so we can save a little code space by moving the AddRef into the callee, rather than doing it in the caller.
This commit is contained in:
Родитель
9130d219ea
Коммит
bb66fde0a0
|
@ -501,7 +501,7 @@ WebSocketEventService::ShutdownActorListener(WindowListener* aListener)
|
|||
aListener->mActor = nullptr;
|
||||
}
|
||||
|
||||
WebSocketFrame*
|
||||
already_AddRefed<WebSocketFrame>
|
||||
WebSocketEventService::CreateFrameIfNeeded(bool aFinBit, bool aRsvBit1,
|
||||
bool aRsvBit2, bool aRsvBit3,
|
||||
uint8_t aOpCode, bool aMaskBit,
|
||||
|
@ -512,11 +512,11 @@ WebSocketEventService::CreateFrameIfNeeded(bool aFinBit, bool aRsvBit1,
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
return new WebSocketFrame(aFinBit, aRsvBit1, aRsvBit2, aRsvBit3, aOpCode,
|
||||
aMaskBit, aMask, aPayload);
|
||||
return MakeAndAddRef<WebSocketFrame>(aFinBit, aRsvBit1, aRsvBit2, aRsvBit3,
|
||||
aOpCode, aMaskBit, aMask, aPayload);
|
||||
}
|
||||
|
||||
WebSocketFrame*
|
||||
already_AddRefed<WebSocketFrame>
|
||||
WebSocketEventService::CreateFrameIfNeeded(bool aFinBit, bool aRsvBit1,
|
||||
bool aRsvBit2, bool aRsvBit3,
|
||||
uint8_t aOpCode, bool aMaskBit,
|
||||
|
@ -533,11 +533,11 @@ WebSocketEventService::CreateFrameIfNeeded(bool aFinBit, bool aRsvBit1,
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
return new WebSocketFrame(aFinBit, aRsvBit1, aRsvBit2, aRsvBit3, aOpCode,
|
||||
aMaskBit, aMask, payloadStr);
|
||||
return MakeAndAddRef<WebSocketFrame>(aFinBit, aRsvBit1, aRsvBit2, aRsvBit3,
|
||||
aOpCode, aMaskBit, aMask, payloadStr);
|
||||
}
|
||||
|
||||
WebSocketFrame*
|
||||
already_AddRefed<WebSocketFrame>
|
||||
WebSocketEventService::CreateFrameIfNeeded(bool aFinBit, bool aRsvBit1,
|
||||
bool aRsvBit2, bool aRsvBit3,
|
||||
uint8_t aOpCode, bool aMaskBit,
|
||||
|
@ -570,8 +570,8 @@ WebSocketEventService::CreateFrameIfNeeded(bool aFinBit, bool aRsvBit1,
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
return new WebSocketFrame(aFinBit, aRsvBit1, aRsvBit2, aRsvBit3, aOpCode,
|
||||
aMaskBit, aMask, payloadStr);
|
||||
return MakeAndAddRef<WebSocketFrame>(aFinBit, aRsvBit1, aRsvBit2, aRsvBit3,
|
||||
aOpCode, aMaskBit, aMask, payloadStr);
|
||||
}
|
||||
|
||||
} // net namespace
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#ifndef mozilla_net_WebSocketEventService_h
|
||||
#define mozilla_net_WebSocketEventService_h
|
||||
|
||||
#include "mozilla/AlreadyAddRefed.h"
|
||||
#include "mozilla/Atomics.h"
|
||||
#include "nsIWebSocketEventService.h"
|
||||
#include "nsAutoPtr.h"
|
||||
|
@ -65,17 +66,17 @@ public:
|
|||
uint64_t aInnerWindowID,
|
||||
WebSocketFrame* aFrame);
|
||||
|
||||
WebSocketFrame*
|
||||
already_AddRefed<WebSocketFrame>
|
||||
CreateFrameIfNeeded(bool aFinBit, bool aRsvBit1, bool aRsvBit2, bool aRsvBit3,
|
||||
uint8_t aOpCode, bool aMaskBit, uint32_t aMask,
|
||||
const nsCString& aPayload);
|
||||
|
||||
WebSocketFrame*
|
||||
already_AddRefed<WebSocketFrame>
|
||||
CreateFrameIfNeeded(bool aFinBit, bool aRsvBit1, bool aRsvBit2, bool aRsvBit3,
|
||||
uint8_t aOpCode, bool aMaskBit, uint32_t aMask,
|
||||
uint8_t* aPayload, uint32_t aPayloadLength);
|
||||
|
||||
WebSocketFrame*
|
||||
already_AddRefed<WebSocketFrame>
|
||||
CreateFrameIfNeeded(bool aFinBit, bool aRsvBit1, bool aRsvBit2, bool aRsvBit3,
|
||||
uint8_t aOpCode, bool aMaskBit, uint32_t aMask,
|
||||
uint8_t* aPayloadInHdr, uint32_t aPayloadInHdrLength,
|
||||
|
|
Загрузка…
Ссылка в новой задаче