зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1800344 part 2: Fold nsSyncStreamListener::Create() into NS_NewSyncStreamListener(). r=necko-reviewers,kershaw
While we're at it: remove one layer of unnecessary error handling in NS_NewSyncStreamListener, since it's clearer now that we'll be getting infallible allocation. Differential Revision: https://phabricator.services.mozilla.com/D161949
This commit is contained in:
Родитель
0b2fc296cd
Коммит
32bd9256f4
|
@ -1041,15 +1041,12 @@ nsresult NS_NewStreamLoader(
|
|||
|
||||
nsresult NS_NewSyncStreamListener(nsIStreamListener** result,
|
||||
nsIInputStream** stream) {
|
||||
nsCOMPtr<nsISyncStreamListener> listener = nsSyncStreamListener::Create();
|
||||
if (listener) {
|
||||
nsresult rv = listener->GetInputStream(stream);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
listener.forget(result);
|
||||
}
|
||||
return rv;
|
||||
nsCOMPtr<nsISyncStreamListener> listener = new nsSyncStreamListener();
|
||||
nsresult rv = listener->GetInputStream(stream);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
listener.forget(result);
|
||||
}
|
||||
return NS_ERROR_FAILURE;
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult NS_ImplementChannelOpen(nsIChannel* channel, nsIInputStream** result) {
|
||||
|
|
|
@ -12,21 +12,13 @@
|
|||
using namespace mozilla::net;
|
||||
|
||||
nsSyncStreamListener::nsSyncStreamListener() {
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
NS_NewPipe(getter_AddRefs(mPipeIn), getter_AddRefs(mPipeOut),
|
||||
mozilla::net::nsIOService::gDefaultSegmentSize,
|
||||
UINT32_MAX, // no size limit
|
||||
false, false);
|
||||
}
|
||||
|
||||
// NOTE: Next patch in this series will remove this.
|
||||
// static
|
||||
already_AddRefed<nsISyncStreamListener> nsSyncStreamListener::Create() {
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
RefPtr<nsSyncStreamListener> inst = new nsSyncStreamListener();
|
||||
return inst.forget();
|
||||
}
|
||||
|
||||
nsresult nsSyncStreamListener::WaitForData() {
|
||||
mKeepWaiting = true;
|
||||
|
||||
|
|
|
@ -22,9 +22,10 @@ class nsSyncStreamListener final : public nsISyncStreamListener,
|
|||
NS_DECL_NSISYNCSTREAMLISTENER
|
||||
NS_DECL_NSIINPUTSTREAM
|
||||
|
||||
static already_AddRefed<nsISyncStreamListener> Create();
|
||||
|
||||
private:
|
||||
// Factory method:
|
||||
friend nsresult NS_NewSyncStreamListener(nsIStreamListener** result,
|
||||
nsIInputStream** stream);
|
||||
nsSyncStreamListener();
|
||||
~nsSyncStreamListener() = default;
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче