зеркало из 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,
|
nsresult NS_NewSyncStreamListener(nsIStreamListener** result,
|
||||||
nsIInputStream** stream) {
|
nsIInputStream** stream) {
|
||||||
nsCOMPtr<nsISyncStreamListener> listener = nsSyncStreamListener::Create();
|
nsCOMPtr<nsISyncStreamListener> listener = new nsSyncStreamListener();
|
||||||
if (listener) {
|
nsresult rv = listener->GetInputStream(stream);
|
||||||
nsresult rv = listener->GetInputStream(stream);
|
if (NS_SUCCEEDED(rv)) {
|
||||||
if (NS_SUCCEEDED(rv)) {
|
listener.forget(result);
|
||||||
listener.forget(result);
|
|
||||||
}
|
|
||||||
return rv;
|
|
||||||
}
|
}
|
||||||
return NS_ERROR_FAILURE;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult NS_ImplementChannelOpen(nsIChannel* channel, nsIInputStream** result) {
|
nsresult NS_ImplementChannelOpen(nsIChannel* channel, nsIInputStream** result) {
|
||||||
|
|
|
@ -12,21 +12,13 @@
|
||||||
using namespace mozilla::net;
|
using namespace mozilla::net;
|
||||||
|
|
||||||
nsSyncStreamListener::nsSyncStreamListener() {
|
nsSyncStreamListener::nsSyncStreamListener() {
|
||||||
|
MOZ_ASSERT(NS_IsMainThread());
|
||||||
NS_NewPipe(getter_AddRefs(mPipeIn), getter_AddRefs(mPipeOut),
|
NS_NewPipe(getter_AddRefs(mPipeIn), getter_AddRefs(mPipeOut),
|
||||||
mozilla::net::nsIOService::gDefaultSegmentSize,
|
mozilla::net::nsIOService::gDefaultSegmentSize,
|
||||||
UINT32_MAX, // no size limit
|
UINT32_MAX, // no size limit
|
||||||
false, false);
|
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() {
|
nsresult nsSyncStreamListener::WaitForData() {
|
||||||
mKeepWaiting = true;
|
mKeepWaiting = true;
|
||||||
|
|
||||||
|
|
|
@ -22,9 +22,10 @@ class nsSyncStreamListener final : public nsISyncStreamListener,
|
||||||
NS_DECL_NSISYNCSTREAMLISTENER
|
NS_DECL_NSISYNCSTREAMLISTENER
|
||||||
NS_DECL_NSIINPUTSTREAM
|
NS_DECL_NSIINPUTSTREAM
|
||||||
|
|
||||||
static already_AddRefed<nsISyncStreamListener> Create();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
// Factory method:
|
||||||
|
friend nsresult NS_NewSyncStreamListener(nsIStreamListener** result,
|
||||||
|
nsIInputStream** stream);
|
||||||
nsSyncStreamListener();
|
nsSyncStreamListener();
|
||||||
~nsSyncStreamListener() = default;
|
~nsSyncStreamListener() = default;
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче