Bug Summary

File:var/lib/jenkins/workspace/firefox-scan-build/netwerk/base/nsAsyncRedirectVerifyHelper.cpp
Warning:line 260, column 5
Value stored to 'rv' is never read

Annotated Source Code

Press '?' to see keyboard shortcuts

clang -cc1 -cc1 -triple x86_64-pc-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name Unified_cpp_netwerk_base1.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -analyzer-config-compatibility-mode=true -mrelocation-model pic -pic-level 2 -fhalf-no-semantic-interposition -mframe-pointer=all -relaxed-aliasing -ffp-contract=off -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/var/lib/jenkins/workspace/firefox-scan-build/obj-x86_64-pc-linux-gnu/netwerk/base -fcoverage-compilation-dir=/var/lib/jenkins/workspace/firefox-scan-build/obj-x86_64-pc-linux-gnu/netwerk/base -resource-dir /usr/lib/llvm-18/lib/clang/18 -include /var/lib/jenkins/workspace/firefox-scan-build/config/gcc_hidden.h -include /var/lib/jenkins/workspace/firefox-scan-build/obj-x86_64-pc-linux-gnu/mozilla-config.h -I /var/lib/jenkins/workspace/firefox-scan-build/obj-x86_64-pc-linux-gnu/dist/stl_wrappers -I /var/lib/jenkins/workspace/firefox-scan-build/obj-x86_64-pc-linux-gnu/dist/system_wrappers -U _FORTIFY_SOURCE -D _FORTIFY_SOURCE=2 -D DEBUG=1 -D MOZ_HAS_MOZGLUE -D MOZILLA_INTERNAL_API -D IMPL_LIBXUL -D MOZ_SUPPORT_LEAKCHECKING -D STATIC_EXPORTABLE_JS_API -I /var/lib/jenkins/workspace/firefox-scan-build/netwerk/base -I /var/lib/jenkins/workspace/firefox-scan-build/obj-x86_64-pc-linux-gnu/netwerk/base -I /var/lib/jenkins/workspace/firefox-scan-build/obj-x86_64-pc-linux-gnu/ipc/ipdl/_ipdlheaders -I /var/lib/jenkins/workspace/firefox-scan-build/ipc/chromium/src -I /var/lib/jenkins/workspace/firefox-scan-build/obj-x86_64-pc-linux-gnu/xpcom/components -I /var/lib/jenkins/workspace/firefox-scan-build/docshell/base -I /var/lib/jenkins/workspace/firefox-scan-build/dom/base -I /var/lib/jenkins/workspace/firefox-scan-build/js/xpconnect/src -I /var/lib/jenkins/workspace/firefox-scan-build/netwerk/dns -I /var/lib/jenkins/workspace/firefox-scan-build/netwerk/protocol/http -I /var/lib/jenkins/workspace/firefox-scan-build/netwerk/protocol/webtransport -I /var/lib/jenkins/workspace/firefox-scan-build/netwerk/socket -I /var/lib/jenkins/workspace/firefox-scan-build/netwerk/url-classifier -I /var/lib/jenkins/workspace/firefox-scan-build/security/manager/ssl -I /var/lib/jenkins/workspace/firefox-scan-build/xpcom/components -I /var/lib/jenkins/workspace/firefox-scan-build/obj-x86_64-pc-linux-gnu/dist/include -I /var/lib/jenkins/workspace/firefox-scan-build/obj-x86_64-pc-linux-gnu/dist/include/nspr -I /var/lib/jenkins/workspace/firefox-scan-build/obj-x86_64-pc-linux-gnu/dist/include/nss -D MOZILLA_CLIENT -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/14/../../../../include/c++/14 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/14/../../../../include/x86_64-linux-gnu/c++/14 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/14/../../../../include/c++/14/backward -internal-isystem /usr/lib/llvm-18/lib/clang/18/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/14/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -O2 -Wno-error=tautological-type-limit-compare -Wno-invalid-offsetof -Wno-range-loop-analysis -Wno-deprecated-anon-enum-enum-conversion -Wno-deprecated-enum-enum-conversion -Wno-deprecated-this-capture -Wno-inline-new-delete -Wno-error=deprecated-declarations -Wno-error=array-bounds -Wno-error=free-nonheap-object -Wno-error=atomic-alignment -Wno-error=deprecated-builtins -Wno-psabi -Wno-error=builtin-macro-redefined -Wno-vla-cxx-extension -Wno-unknown-warning-option -fdeprecated-macro -ferror-limit 19 -stack-protector 2 -fstack-clash-protection -ftrivial-auto-var-init=pattern -fno-rtti -fgnuc-version=4.2.1 -fno-aligned-allocation -vectorize-loops -vectorize-slp -analyzer-checker optin.performance.Padding -analyzer-output=html -analyzer-config stable-report-filename=true -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/scan-build-2024-07-27-022226-2793976-1 -x c++ Unified_cpp_netwerk_base1.cpp
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2/* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5
6#include "mozilla/Logging.h"
7#include "mozilla/SpinEventLoopUntil.h"
8#include "nsAsyncRedirectVerifyHelper.h"
9#include "nsThreadUtils.h"
10#include "nsNetUtil.h"
11
12#include "nsIOService.h"
13#include "nsIChannel.h"
14#include "nsIHttpChannelInternal.h"
15#include "nsIAsyncVerifyRedirectCallback.h"
16#include "nsILoadInfo.h"
17
18namespace mozilla {
19namespace net {
20
21static LazyLogModule gRedirectLog("nsRedirect");
22#undef LOG
23#define LOG(args)do { const ::mozilla::LogModule* moz_real_module = gStreamCopierLog
; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module
, mozilla::LogLevel::Debug)), 0))) { mozilla::detail::log_print
(moz_real_module, mozilla::LogLevel::Debug, MOZ_LOG_EXPAND_ARGS
args); } } while (0)
MOZ_LOG(gRedirectLog, LogLevel::Debug, args)do { const ::mozilla::LogModule* moz_real_module = gRedirectLog
; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module
, LogLevel::Debug)), 0))) { mozilla::detail::log_print(moz_real_module
, LogLevel::Debug, MOZ_LOG_EXPAND_ARGS args); } } while (0)
24
25NS_IMPL_ISUPPORTS(nsAsyncRedirectVerifyHelper, nsIAsyncVerifyRedirectCallback,MozExternalRefCountType nsAsyncRedirectVerifyHelper::AddRef(void
) { static_assert(!std::is_destructible_v<nsAsyncRedirectVerifyHelper
>, "Reference-counted class " "nsAsyncRedirectVerifyHelper"
" should not have a public destructor. " "Make this class's destructor non-public"
); do { static_assert( mozilla::detail::AssertionConditionType
<decltype(int32_t(mRefCnt) >= 0)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(int32_t(mRefCnt) >= 0))),
0))) { do { } while (false); MOZ_ReportAssertionFailure("int32_t(mRefCnt) >= 0"
" (" "illegal refcnt" ")", "/var/lib/jenkins/workspace/firefox-scan-build/netwerk/base/nsAsyncRedirectVerifyHelper.cpp"
, 26); AnnotateMozCrashReason("MOZ_ASSERT" "(" "int32_t(mRefCnt) >= 0"
") (" "illegal refcnt" ")"); do { *((volatile int*)__null) =
26; __attribute__((nomerge)) ::abort(); } while (false); } }
while (false); do { static_assert( mozilla::detail::AssertionConditionType
<decltype("nsAsyncRedirectVerifyHelper" != nullptr)>::isValid
, "invalid assertion condition"); if ((__builtin_expect(!!(!(
!!("nsAsyncRedirectVerifyHelper" != nullptr))), 0))) { do { }
while (false); MOZ_ReportAssertionFailure("\"nsAsyncRedirectVerifyHelper\" != nullptr"
" (" "Must specify a name" ")", "/var/lib/jenkins/workspace/firefox-scan-build/netwerk/base/nsAsyncRedirectVerifyHelper.cpp"
, 26); AnnotateMozCrashReason("MOZ_ASSERT" "(" "\"nsAsyncRedirectVerifyHelper\" != nullptr"
") (" "Must specify a name" ")"); do { *((volatile int*)__null
) = 26; __attribute__((nomerge)) ::abort(); } while (false); }
} while (false); if (!mRefCnt.isThreadSafe) _mOwningThread.AssertOwnership
("nsAsyncRedirectVerifyHelper" " not thread-safe"); nsrefcnt count
= ++mRefCnt; NS_LogAddRef((this), (count), ("nsAsyncRedirectVerifyHelper"
), (uint32_t)(sizeof(*this))); return count; } MozExternalRefCountType
nsAsyncRedirectVerifyHelper::Release(void) { do { static_assert
( mozilla::detail::AssertionConditionType<decltype(int32_t
(mRefCnt) > 0)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(int32_t(mRefCnt) > 0))), 0
))) { do { } while (false); MOZ_ReportAssertionFailure("int32_t(mRefCnt) > 0"
" (" "dup release" ")", "/var/lib/jenkins/workspace/firefox-scan-build/netwerk/base/nsAsyncRedirectVerifyHelper.cpp"
, 26); AnnotateMozCrashReason("MOZ_ASSERT" "(" "int32_t(mRefCnt) > 0"
") (" "dup release" ")"); do { *((volatile int*)__null) = 26
; __attribute__((nomerge)) ::abort(); } while (false); } } while
(false); do { static_assert( mozilla::detail::AssertionConditionType
<decltype("nsAsyncRedirectVerifyHelper" != nullptr)>::isValid
, "invalid assertion condition"); if ((__builtin_expect(!!(!(
!!("nsAsyncRedirectVerifyHelper" != nullptr))), 0))) { do { }
while (false); MOZ_ReportAssertionFailure("\"nsAsyncRedirectVerifyHelper\" != nullptr"
" (" "Must specify a name" ")", "/var/lib/jenkins/workspace/firefox-scan-build/netwerk/base/nsAsyncRedirectVerifyHelper.cpp"
, 26); AnnotateMozCrashReason("MOZ_ASSERT" "(" "\"nsAsyncRedirectVerifyHelper\" != nullptr"
") (" "Must specify a name" ")"); do { *((volatile int*)__null
) = 26; __attribute__((nomerge)) ::abort(); } while (false); }
} while (false); if (!mRefCnt.isThreadSafe) _mOwningThread.AssertOwnership
("nsAsyncRedirectVerifyHelper" " not thread-safe"); const char
* const nametmp = "nsAsyncRedirectVerifyHelper"; nsrefcnt count
= --mRefCnt; NS_LogRelease((this), (count), (nametmp)); if (
count == 0) { mRefCnt = 1; delete (this); return 0; } return count
; } nsresult nsAsyncRedirectVerifyHelper::QueryInterface(const
nsIID& aIID, void** aInstancePtr) { do { if (!(aInstancePtr
)) { NS_DebugBreak(NS_DEBUG_ASSERTION, "QueryInterface requires a non-NULL destination!"
, "aInstancePtr", "/var/lib/jenkins/workspace/firefox-scan-build/netwerk/base/nsAsyncRedirectVerifyHelper.cpp"
, 26); MOZ_PretendNoReturn(); } } while (0); nsresult rv = NS_ERROR_FAILURE
; static_assert(3 > 0, "Need more arguments to NS_INTERFACE_TABLE"
); static const QITableEntry table[] = { {&mozilla::detail
::kImplementedIID<nsAsyncRedirectVerifyHelper, nsIAsyncVerifyRedirectCallback
>, int32_t( reinterpret_cast<char*>(static_cast<nsIAsyncVerifyRedirectCallback
*>((nsAsyncRedirectVerifyHelper*)0x1000)) - reinterpret_cast
<char*>((nsAsyncRedirectVerifyHelper*)0x1000))}, {&
mozilla::detail::kImplementedIID<nsAsyncRedirectVerifyHelper
, nsIRunnable>, int32_t( reinterpret_cast<char*>(static_cast
<nsIRunnable*>((nsAsyncRedirectVerifyHelper*)0x1000)) -
reinterpret_cast<char*>((nsAsyncRedirectVerifyHelper*)
0x1000))}, {&mozilla::detail::kImplementedIID<nsAsyncRedirectVerifyHelper
, nsINamed>, int32_t( reinterpret_cast<char*>(static_cast
<nsINamed*>((nsAsyncRedirectVerifyHelper*)0x1000)) - reinterpret_cast
<char*>((nsAsyncRedirectVerifyHelper*)0x1000))}, {&
mozilla::detail::kImplementedIID<nsAsyncRedirectVerifyHelper
, nsISupports>, int32_t(reinterpret_cast<char*>(static_cast
<nsISupports*>( static_cast<nsIAsyncVerifyRedirectCallback
*>((nsAsyncRedirectVerifyHelper*)0x1000))) - reinterpret_cast
<char*>((nsAsyncRedirectVerifyHelper*)0x1000))}, { nullptr
, 0 } } ; static_assert((sizeof(table) / sizeof(table[0])) >
1, "need at least 1 interface"); rv = NS_TableDrivenQI(static_cast
<void*>(this), aIID, aInstancePtr, table); return rv; }
26 nsIRunnable, nsINamed)MozExternalRefCountType nsAsyncRedirectVerifyHelper::AddRef(void
) { static_assert(!std::is_destructible_v<nsAsyncRedirectVerifyHelper
>, "Reference-counted class " "nsAsyncRedirectVerifyHelper"
" should not have a public destructor. " "Make this class's destructor non-public"
); do { static_assert( mozilla::detail::AssertionConditionType
<decltype(int32_t(mRefCnt) >= 0)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(int32_t(mRefCnt) >= 0))),
0))) { do { } while (false); MOZ_ReportAssertionFailure("int32_t(mRefCnt) >= 0"
" (" "illegal refcnt" ")", "/var/lib/jenkins/workspace/firefox-scan-build/netwerk/base/nsAsyncRedirectVerifyHelper.cpp"
, 26); AnnotateMozCrashReason("MOZ_ASSERT" "(" "int32_t(mRefCnt) >= 0"
") (" "illegal refcnt" ")"); do { *((volatile int*)__null) =
26; __attribute__((nomerge)) ::abort(); } while (false); } }
while (false); do { static_assert( mozilla::detail::AssertionConditionType
<decltype("nsAsyncRedirectVerifyHelper" != nullptr)>::isValid
, "invalid assertion condition"); if ((__builtin_expect(!!(!(
!!("nsAsyncRedirectVerifyHelper" != nullptr))), 0))) { do { }
while (false); MOZ_ReportAssertionFailure("\"nsAsyncRedirectVerifyHelper\" != nullptr"
" (" "Must specify a name" ")", "/var/lib/jenkins/workspace/firefox-scan-build/netwerk/base/nsAsyncRedirectVerifyHelper.cpp"
, 26); AnnotateMozCrashReason("MOZ_ASSERT" "(" "\"nsAsyncRedirectVerifyHelper\" != nullptr"
") (" "Must specify a name" ")"); do { *((volatile int*)__null
) = 26; __attribute__((nomerge)) ::abort(); } while (false); }
} while (false); if (!mRefCnt.isThreadSafe) _mOwningThread.AssertOwnership
("nsAsyncRedirectVerifyHelper" " not thread-safe"); nsrefcnt count
= ++mRefCnt; NS_LogAddRef((this), (count), ("nsAsyncRedirectVerifyHelper"
), (uint32_t)(sizeof(*this))); return count; } MozExternalRefCountType
nsAsyncRedirectVerifyHelper::Release(void) { do { static_assert
( mozilla::detail::AssertionConditionType<decltype(int32_t
(mRefCnt) > 0)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(int32_t(mRefCnt) > 0))), 0
))) { do { } while (false); MOZ_ReportAssertionFailure("int32_t(mRefCnt) > 0"
" (" "dup release" ")", "/var/lib/jenkins/workspace/firefox-scan-build/netwerk/base/nsAsyncRedirectVerifyHelper.cpp"
, 26); AnnotateMozCrashReason("MOZ_ASSERT" "(" "int32_t(mRefCnt) > 0"
") (" "dup release" ")"); do { *((volatile int*)__null) = 26
; __attribute__((nomerge)) ::abort(); } while (false); } } while
(false); do { static_assert( mozilla::detail::AssertionConditionType
<decltype("nsAsyncRedirectVerifyHelper" != nullptr)>::isValid
, "invalid assertion condition"); if ((__builtin_expect(!!(!(
!!("nsAsyncRedirectVerifyHelper" != nullptr))), 0))) { do { }
while (false); MOZ_ReportAssertionFailure("\"nsAsyncRedirectVerifyHelper\" != nullptr"
" (" "Must specify a name" ")", "/var/lib/jenkins/workspace/firefox-scan-build/netwerk/base/nsAsyncRedirectVerifyHelper.cpp"
, 26); AnnotateMozCrashReason("MOZ_ASSERT" "(" "\"nsAsyncRedirectVerifyHelper\" != nullptr"
") (" "Must specify a name" ")"); do { *((volatile int*)__null
) = 26; __attribute__((nomerge)) ::abort(); } while (false); }
} while (false); if (!mRefCnt.isThreadSafe) _mOwningThread.AssertOwnership
("nsAsyncRedirectVerifyHelper" " not thread-safe"); const char
* const nametmp = "nsAsyncRedirectVerifyHelper"; nsrefcnt count
= --mRefCnt; NS_LogRelease((this), (count), (nametmp)); if (
count == 0) { mRefCnt = 1; delete (this); return 0; } return count
; } nsresult nsAsyncRedirectVerifyHelper::QueryInterface(const
nsIID& aIID, void** aInstancePtr) { do { if (!(aInstancePtr
)) { NS_DebugBreak(NS_DEBUG_ASSERTION, "QueryInterface requires a non-NULL destination!"
, "aInstancePtr", "/var/lib/jenkins/workspace/firefox-scan-build/netwerk/base/nsAsyncRedirectVerifyHelper.cpp"
, 26); MOZ_PretendNoReturn(); } } while (0); nsresult rv = NS_ERROR_FAILURE
; static_assert(3 > 0, "Need more arguments to NS_INTERFACE_TABLE"
); static const QITableEntry table[] = { {&mozilla::detail
::kImplementedIID<nsAsyncRedirectVerifyHelper, nsIAsyncVerifyRedirectCallback
>, int32_t( reinterpret_cast<char*>(static_cast<nsIAsyncVerifyRedirectCallback
*>((nsAsyncRedirectVerifyHelper*)0x1000)) - reinterpret_cast
<char*>((nsAsyncRedirectVerifyHelper*)0x1000))}, {&
mozilla::detail::kImplementedIID<nsAsyncRedirectVerifyHelper
, nsIRunnable>, int32_t( reinterpret_cast<char*>(static_cast
<nsIRunnable*>((nsAsyncRedirectVerifyHelper*)0x1000)) -
reinterpret_cast<char*>((nsAsyncRedirectVerifyHelper*)
0x1000))}, {&mozilla::detail::kImplementedIID<nsAsyncRedirectVerifyHelper
, nsINamed>, int32_t( reinterpret_cast<char*>(static_cast
<nsINamed*>((nsAsyncRedirectVerifyHelper*)0x1000)) - reinterpret_cast
<char*>((nsAsyncRedirectVerifyHelper*)0x1000))}, {&
mozilla::detail::kImplementedIID<nsAsyncRedirectVerifyHelper
, nsISupports>, int32_t(reinterpret_cast<char*>(static_cast
<nsISupports*>( static_cast<nsIAsyncVerifyRedirectCallback
*>((nsAsyncRedirectVerifyHelper*)0x1000))) - reinterpret_cast
<char*>((nsAsyncRedirectVerifyHelper*)0x1000))}, { nullptr
, 0 } } ; static_assert((sizeof(table) / sizeof(table[0])) >
1, "need at least 1 interface"); rv = NS_TableDrivenQI(static_cast
<void*>(this), aIID, aInstancePtr, table); return rv; }
27
28class nsAsyncVerifyRedirectCallbackEvent : public Runnable {
29 public:
30 nsAsyncVerifyRedirectCallbackEvent(nsIAsyncVerifyRedirectCallback* cb,
31 nsresult result)
32 : Runnable("nsAsyncVerifyRedirectCallbackEvent"),
33 mCallback(cb),
34 mResult(result) {}
35
36 NS_IMETHODvirtual nsresult Run() override {
37 LOG(do { const ::mozilla::LogModule* moz_real_module = gStreamCopierLog
; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module
, mozilla::LogLevel::Debug)), 0))) { mozilla::detail::log_print
(moz_real_module, mozilla::LogLevel::Debug, "nsAsyncVerifyRedirectCallbackEvent::Run() "
"callback to %p with result %" "x", mCallback.get(), static_cast
<uint32_t>(mResult)); } } while (0)
38 ("nsAsyncVerifyRedirectCallbackEvent::Run() "do { const ::mozilla::LogModule* moz_real_module = gStreamCopierLog
; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module
, mozilla::LogLevel::Debug)), 0))) { mozilla::detail::log_print
(moz_real_module, mozilla::LogLevel::Debug, "nsAsyncVerifyRedirectCallbackEvent::Run() "
"callback to %p with result %" "x", mCallback.get(), static_cast
<uint32_t>(mResult)); } } while (0)
39 "callback to %p with result %" PRIx32,do { const ::mozilla::LogModule* moz_real_module = gStreamCopierLog
; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module
, mozilla::LogLevel::Debug)), 0))) { mozilla::detail::log_print
(moz_real_module, mozilla::LogLevel::Debug, "nsAsyncVerifyRedirectCallbackEvent::Run() "
"callback to %p with result %" "x", mCallback.get(), static_cast
<uint32_t>(mResult)); } } while (0)
40 mCallback.get(), static_cast<uint32_t>(mResult)))do { const ::mozilla::LogModule* moz_real_module = gStreamCopierLog
; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module
, mozilla::LogLevel::Debug)), 0))) { mozilla::detail::log_print
(moz_real_module, mozilla::LogLevel::Debug, "nsAsyncVerifyRedirectCallbackEvent::Run() "
"callback to %p with result %" "x", mCallback.get(), static_cast
<uint32_t>(mResult)); } } while (0)
;
41 (void)mCallback->OnRedirectVerifyCallback(mResult);
42 return NS_OK;
43 }
44
45 private:
46 nsCOMPtr<nsIAsyncVerifyRedirectCallback> mCallback;
47 nsresult mResult;
48};
49
50nsAsyncRedirectVerifyHelper::~nsAsyncRedirectVerifyHelper() {
51 NS_ASSERTION(NS_FAILED(mResult) || mExpectedCallbacks == 0,do { if (!(((bool)(__builtin_expect(!!(NS_FAILED_impl(mResult
)), 0))) || mExpectedCallbacks == 0)) { NS_DebugBreak(NS_DEBUG_ASSERTION
, "Did not receive all required callbacks!", "NS_FAILED(mResult) || mExpectedCallbacks == 0"
, "/var/lib/jenkins/workspace/firefox-scan-build/netwerk/base/nsAsyncRedirectVerifyHelper.cpp"
, 52); MOZ_PretendNoReturn(); } } while (0)
52 "Did not receive all required callbacks!")do { if (!(((bool)(__builtin_expect(!!(NS_FAILED_impl(mResult
)), 0))) || mExpectedCallbacks == 0)) { NS_DebugBreak(NS_DEBUG_ASSERTION
, "Did not receive all required callbacks!", "NS_FAILED(mResult) || mExpectedCallbacks == 0"
, "/var/lib/jenkins/workspace/firefox-scan-build/netwerk/base/nsAsyncRedirectVerifyHelper.cpp"
, 52); MOZ_PretendNoReturn(); } } while (0)
;
53}
54
55nsresult nsAsyncRedirectVerifyHelper::Init(
56 nsIChannel* oldChan, nsIChannel* newChan, uint32_t flags,
57 nsIEventTarget* mainThreadEventTarget, bool synchronize) {
58 LOG(do { const ::mozilla::LogModule* moz_real_module = gStreamCopierLog
; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module
, mozilla::LogLevel::Debug)), 0))) { mozilla::detail::log_print
(moz_real_module, mozilla::LogLevel::Debug, "nsAsyncRedirectVerifyHelper::Init() "
"oldChan=%p newChan=%p", oldChan, newChan); } } while (0)
59 ("nsAsyncRedirectVerifyHelper::Init() "do { const ::mozilla::LogModule* moz_real_module = gStreamCopierLog
; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module
, mozilla::LogLevel::Debug)), 0))) { mozilla::detail::log_print
(moz_real_module, mozilla::LogLevel::Debug, "nsAsyncRedirectVerifyHelper::Init() "
"oldChan=%p newChan=%p", oldChan, newChan); } } while (0)
60 "oldChan=%p newChan=%p",do { const ::mozilla::LogModule* moz_real_module = gStreamCopierLog
; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module
, mozilla::LogLevel::Debug)), 0))) { mozilla::detail::log_print
(moz_real_module, mozilla::LogLevel::Debug, "nsAsyncRedirectVerifyHelper::Init() "
"oldChan=%p newChan=%p", oldChan, newChan); } } while (0)
61 oldChan, newChan))do { const ::mozilla::LogModule* moz_real_module = gStreamCopierLog
; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module
, mozilla::LogLevel::Debug)), 0))) { mozilla::detail::log_print
(moz_real_module, mozilla::LogLevel::Debug, "nsAsyncRedirectVerifyHelper::Init() "
"oldChan=%p newChan=%p", oldChan, newChan); } } while (0)
;
62 mOldChan = oldChan;
63 mNewChan = newChan;
64 mFlags = flags;
65 mCallbackEventTarget = NS_IsMainThread() && mainThreadEventTarget
66 ? mainThreadEventTarget
67 : GetCurrentSerialEventTarget();
68
69 if (!(flags & (nsIChannelEventSink::REDIRECT_INTERNAL |
70 nsIChannelEventSink::REDIRECT_STS_UPGRADE))) {
71 nsCOMPtr<nsILoadInfo> loadInfo = oldChan->LoadInfo();
72 if (loadInfo->GetDontFollowRedirects()) {
73 ExplicitCallback(NS_BINDING_ABORTED);
74 return NS_OK;
75 }
76 }
77
78 if (synchronize) mWaitingForRedirectCallback = true;
79
80 nsCOMPtr<nsIRunnable> runnable = this;
81 nsresult rv;
82 rv = mainThreadEventTarget
83 ? mainThreadEventTarget->Dispatch(runnable.forget())
84 : GetMainThreadSerialEventTarget()->Dispatch(runnable.forget());
85 NS_ENSURE_SUCCESS(rv, rv)do { nsresult __rv = rv; if (((bool)(__builtin_expect(!!(NS_FAILED_impl
(__rv)), 0)))) { const char* name = mozilla::GetStaticErrorName
(__rv); mozilla::SmprintfPointer msg = mozilla::Smprintf( "NS_ENSURE_SUCCESS(%s, %s) failed with "
"result 0x%" "X" "%s%s%s", "rv", "rv", static_cast<uint32_t
>(__rv), name ? " (" : "", name ? name : "", name ? ")" : ""
); NS_DebugBreak(NS_DEBUG_WARNING, msg.get(), nullptr, "/var/lib/jenkins/workspace/firefox-scan-build/netwerk/base/nsAsyncRedirectVerifyHelper.cpp"
, 85); return rv; } } while (false)
;
86
87 if (synchronize) {
88 if (!SpinEventLoopUntil("nsAsyncRedirectVerifyHelper::Init"_ns,
89 [&]() { return !mWaitingForRedirectCallback; })) {
90 return NS_ERROR_UNEXPECTED;
91 }
92 }
93
94 return NS_OK;
95}
96
97NS_IMETHODIMPnsresult
98nsAsyncRedirectVerifyHelper::OnRedirectVerifyCallback(nsresult result) {
99 LOG(do { const ::mozilla::LogModule* moz_real_module = gStreamCopierLog
; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module
, mozilla::LogLevel::Debug)), 0))) { mozilla::detail::log_print
(moz_real_module, mozilla::LogLevel::Debug, "nsAsyncRedirectVerifyHelper::OnRedirectVerifyCallback() "
"result=%" "x" " expectedCBs=%u mResult=%" "x", static_cast<
uint32_t>(result), mExpectedCallbacks, static_cast<uint32_t
>(mResult)); } } while (0)
100 ("nsAsyncRedirectVerifyHelper::OnRedirectVerifyCallback() "do { const ::mozilla::LogModule* moz_real_module = gStreamCopierLog
; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module
, mozilla::LogLevel::Debug)), 0))) { mozilla::detail::log_print
(moz_real_module, mozilla::LogLevel::Debug, "nsAsyncRedirectVerifyHelper::OnRedirectVerifyCallback() "
"result=%" "x" " expectedCBs=%u mResult=%" "x", static_cast<
uint32_t>(result), mExpectedCallbacks, static_cast<uint32_t
>(mResult)); } } while (0)
101 "result=%" PRIx32 " expectedCBs=%u mResult=%" PRIx32,do { const ::mozilla::LogModule* moz_real_module = gStreamCopierLog
; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module
, mozilla::LogLevel::Debug)), 0))) { mozilla::detail::log_print
(moz_real_module, mozilla::LogLevel::Debug, "nsAsyncRedirectVerifyHelper::OnRedirectVerifyCallback() "
"result=%" "x" " expectedCBs=%u mResult=%" "x", static_cast<
uint32_t>(result), mExpectedCallbacks, static_cast<uint32_t
>(mResult)); } } while (0)
102 static_cast<uint32_t>(result), mExpectedCallbacks,do { const ::mozilla::LogModule* moz_real_module = gStreamCopierLog
; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module
, mozilla::LogLevel::Debug)), 0))) { mozilla::detail::log_print
(moz_real_module, mozilla::LogLevel::Debug, "nsAsyncRedirectVerifyHelper::OnRedirectVerifyCallback() "
"result=%" "x" " expectedCBs=%u mResult=%" "x", static_cast<
uint32_t>(result), mExpectedCallbacks, static_cast<uint32_t
>(mResult)); } } while (0)
103 static_cast<uint32_t>(mResult)))do { const ::mozilla::LogModule* moz_real_module = gStreamCopierLog
; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module
, mozilla::LogLevel::Debug)), 0))) { mozilla::detail::log_print
(moz_real_module, mozilla::LogLevel::Debug, "nsAsyncRedirectVerifyHelper::OnRedirectVerifyCallback() "
"result=%" "x" " expectedCBs=%u mResult=%" "x", static_cast<
uint32_t>(result), mExpectedCallbacks, static_cast<uint32_t
>(mResult)); } } while (0)
;
104
105 MOZ_DIAGNOSTIC_ASSERT(do { static_assert( mozilla::detail::AssertionConditionType<
decltype(mExpectedCallbacks > 0)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(mExpectedCallbacks > 0)))
, 0))) { do { } while (false); MOZ_ReportAssertionFailure("mExpectedCallbacks > 0"
" (" "OnRedirectVerifyCallback called more times than expected"
")", "/var/lib/jenkins/workspace/firefox-scan-build/netwerk/base/nsAsyncRedirectVerifyHelper.cpp"
, 107); AnnotateMozCrashReason("MOZ_DIAGNOSTIC_ASSERT" "(" "mExpectedCallbacks > 0"
") (" "OnRedirectVerifyCallback called more times than expected"
")"); do { *((volatile int*)__null) = 107; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
106 mExpectedCallbacks > 0,do { static_assert( mozilla::detail::AssertionConditionType<
decltype(mExpectedCallbacks > 0)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(mExpectedCallbacks > 0)))
, 0))) { do { } while (false); MOZ_ReportAssertionFailure("mExpectedCallbacks > 0"
" (" "OnRedirectVerifyCallback called more times than expected"
")", "/var/lib/jenkins/workspace/firefox-scan-build/netwerk/base/nsAsyncRedirectVerifyHelper.cpp"
, 107); AnnotateMozCrashReason("MOZ_DIAGNOSTIC_ASSERT" "(" "mExpectedCallbacks > 0"
") (" "OnRedirectVerifyCallback called more times than expected"
")"); do { *((volatile int*)__null) = 107; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
107 "OnRedirectVerifyCallback called more times than expected")do { static_assert( mozilla::detail::AssertionConditionType<
decltype(mExpectedCallbacks > 0)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(mExpectedCallbacks > 0)))
, 0))) { do { } while (false); MOZ_ReportAssertionFailure("mExpectedCallbacks > 0"
" (" "OnRedirectVerifyCallback called more times than expected"
")", "/var/lib/jenkins/workspace/firefox-scan-build/netwerk/base/nsAsyncRedirectVerifyHelper.cpp"
, 107); AnnotateMozCrashReason("MOZ_DIAGNOSTIC_ASSERT" "(" "mExpectedCallbacks > 0"
") (" "OnRedirectVerifyCallback called more times than expected"
")"); do { *((volatile int*)__null) = 107; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
108 if (mExpectedCallbacks <= 0) {
109 return NS_ERROR_UNEXPECTED;
110 }
111
112 --mExpectedCallbacks;
113
114 // If response indicates failure we may call back immediately
115 if (NS_FAILED(result)((bool)(__builtin_expect(!!(NS_FAILED_impl(result)), 0)))) {
116 // We chose to store the first failure-value (as opposed to the last)
117 if (NS_SUCCEEDED(mResult)((bool)(__builtin_expect(!!(!NS_FAILED_impl(mResult)), 1)))) mResult = result;
118
119 // If InitCallback() has been called, just invoke the callback and
120 // return. Otherwise it will be invoked from InitCallback()
121 if (mCallbackInitiated) {
122 ExplicitCallback(mResult);
123 return NS_OK;
124 }
125 }
126
127 // If the expected-counter is in balance and InitCallback() was called, all
128 // sinks have agreed that the redirect is ok and we can invoke our callback
129 if (mCallbackInitiated && mExpectedCallbacks == 0) {
130 ExplicitCallback(mResult);
131 }
132
133 return NS_OK;
134}
135
136nsresult nsAsyncRedirectVerifyHelper::DelegateOnChannelRedirect(
137 nsIChannelEventSink* sink, nsIChannel* oldChannel, nsIChannel* newChannel,
138 uint32_t flags) {
139 LOG(do { const ::mozilla::LogModule* moz_real_module = gStreamCopierLog
; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module
, mozilla::LogLevel::Debug)), 0))) { mozilla::detail::log_print
(moz_real_module, mozilla::LogLevel::Debug, "nsAsyncRedirectVerifyHelper::DelegateOnChannelRedirect() "
"sink=%p expectedCBs=%u mResult=%" "x", sink, mExpectedCallbacks
, static_cast<uint32_t>(mResult)); } } while (0)
140 ("nsAsyncRedirectVerifyHelper::DelegateOnChannelRedirect() "do { const ::mozilla::LogModule* moz_real_module = gStreamCopierLog
; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module
, mozilla::LogLevel::Debug)), 0))) { mozilla::detail::log_print
(moz_real_module, mozilla::LogLevel::Debug, "nsAsyncRedirectVerifyHelper::DelegateOnChannelRedirect() "
"sink=%p expectedCBs=%u mResult=%" "x", sink, mExpectedCallbacks
, static_cast<uint32_t>(mResult)); } } while (0)
141 "sink=%p expectedCBs=%u mResult=%" PRIx32,do { const ::mozilla::LogModule* moz_real_module = gStreamCopierLog
; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module
, mozilla::LogLevel::Debug)), 0))) { mozilla::detail::log_print
(moz_real_module, mozilla::LogLevel::Debug, "nsAsyncRedirectVerifyHelper::DelegateOnChannelRedirect() "
"sink=%p expectedCBs=%u mResult=%" "x", sink, mExpectedCallbacks
, static_cast<uint32_t>(mResult)); } } while (0)
142 sink, mExpectedCallbacks, static_cast<uint32_t>(mResult)))do { const ::mozilla::LogModule* moz_real_module = gStreamCopierLog
; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module
, mozilla::LogLevel::Debug)), 0))) { mozilla::detail::log_print
(moz_real_module, mozilla::LogLevel::Debug, "nsAsyncRedirectVerifyHelper::DelegateOnChannelRedirect() "
"sink=%p expectedCBs=%u mResult=%" "x", sink, mExpectedCallbacks
, static_cast<uint32_t>(mResult)); } } while (0)
;
143
144 ++mExpectedCallbacks;
145
146 if (IsOldChannelCanceled()) {
147 LOG(do { const ::mozilla::LogModule* moz_real_module = gStreamCopierLog
; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module
, mozilla::LogLevel::Debug)), 0))) { mozilla::detail::log_print
(moz_real_module, mozilla::LogLevel::Debug, " old channel has been canceled, cancel the redirect by "
"emulating OnRedirectVerifyCallback..."); } } while (0)
148 (" old channel has been canceled, cancel the redirect by "do { const ::mozilla::LogModule* moz_real_module = gStreamCopierLog
; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module
, mozilla::LogLevel::Debug)), 0))) { mozilla::detail::log_print
(moz_real_module, mozilla::LogLevel::Debug, " old channel has been canceled, cancel the redirect by "
"emulating OnRedirectVerifyCallback..."); } } while (0)
149 "emulating OnRedirectVerifyCallback..."))do { const ::mozilla::LogModule* moz_real_module = gStreamCopierLog
; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module
, mozilla::LogLevel::Debug)), 0))) { mozilla::detail::log_print
(moz_real_module, mozilla::LogLevel::Debug, " old channel has been canceled, cancel the redirect by "
"emulating OnRedirectVerifyCallback..."); } } while (0)
;
150 (void)OnRedirectVerifyCallback(NS_BINDING_ABORTED);
151 return NS_BINDING_ABORTED;
152 }
153
154 nsresult rv =
155 sink->AsyncOnChannelRedirect(oldChannel, newChannel, flags, this);
156
157 LOG((" result=%" PRIx32 " expectedCBs=%u", static_cast<uint32_t>(rv),do { const ::mozilla::LogModule* moz_real_module = gStreamCopierLog
; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module
, mozilla::LogLevel::Debug)), 0))) { mozilla::detail::log_print
(moz_real_module, mozilla::LogLevel::Debug, " result=%" "x" " expectedCBs=%u"
, static_cast<uint32_t>(rv), mExpectedCallbacks); } } while
(0)
158 mExpectedCallbacks))do { const ::mozilla::LogModule* moz_real_module = gStreamCopierLog
; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module
, mozilla::LogLevel::Debug)), 0))) { mozilla::detail::log_print
(moz_real_module, mozilla::LogLevel::Debug, " result=%" "x" " expectedCBs=%u"
, static_cast<uint32_t>(rv), mExpectedCallbacks); } } while
(0)
;
159
160 // If the sink returns failure from this call the redirect is vetoed. We
161 // emulate a callback from the sink in this case in order to perform all
162 // the necessary logic.
163 if (NS_FAILED(rv)((bool)(__builtin_expect(!!(NS_FAILED_impl(rv)), 0)))) {
164 LOG((" emulating OnRedirectVerifyCallback..."))do { const ::mozilla::LogModule* moz_real_module = gStreamCopierLog
; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module
, mozilla::LogLevel::Debug)), 0))) { mozilla::detail::log_print
(moz_real_module, mozilla::LogLevel::Debug, " emulating OnRedirectVerifyCallback..."
); } } while (0)
;
165 (void)OnRedirectVerifyCallback(rv);
166 }
167
168 return rv; // Return the actual status since our caller may need it
169}
170
171void nsAsyncRedirectVerifyHelper::ExplicitCallback(nsresult result) {
172 LOG(do { const ::mozilla::LogModule* moz_real_module = gStreamCopierLog
; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module
, mozilla::LogLevel::Debug)), 0))) { mozilla::detail::log_print
(moz_real_module, mozilla::LogLevel::Debug, "nsAsyncRedirectVerifyHelper::ExplicitCallback() "
"result=%" "x" " expectedCBs=%u mCallbackInitiated=%u mResult=%"
"x", static_cast<uint32_t>(result), mExpectedCallbacks
, mCallbackInitiated, static_cast<uint32_t>(mResult)); }
} while (0)
173 ("nsAsyncRedirectVerifyHelper::ExplicitCallback() "do { const ::mozilla::LogModule* moz_real_module = gStreamCopierLog
; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module
, mozilla::LogLevel::Debug)), 0))) { mozilla::detail::log_print
(moz_real_module, mozilla::LogLevel::Debug, "nsAsyncRedirectVerifyHelper::ExplicitCallback() "
"result=%" "x" " expectedCBs=%u mCallbackInitiated=%u mResult=%"
"x", static_cast<uint32_t>(result), mExpectedCallbacks
, mCallbackInitiated, static_cast<uint32_t>(mResult)); }
} while (0)
174 "result=%" PRIx32do { const ::mozilla::LogModule* moz_real_module = gStreamCopierLog
; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module
, mozilla::LogLevel::Debug)), 0))) { mozilla::detail::log_print
(moz_real_module, mozilla::LogLevel::Debug, "nsAsyncRedirectVerifyHelper::ExplicitCallback() "
"result=%" "x" " expectedCBs=%u mCallbackInitiated=%u mResult=%"
"x", static_cast<uint32_t>(result), mExpectedCallbacks
, mCallbackInitiated, static_cast<uint32_t>(mResult)); }
} while (0)
175 " expectedCBs=%u mCallbackInitiated=%u mResult=%" PRIx32,do { const ::mozilla::LogModule* moz_real_module = gStreamCopierLog
; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module
, mozilla::LogLevel::Debug)), 0))) { mozilla::detail::log_print
(moz_real_module, mozilla::LogLevel::Debug, "nsAsyncRedirectVerifyHelper::ExplicitCallback() "
"result=%" "x" " expectedCBs=%u mCallbackInitiated=%u mResult=%"
"x", static_cast<uint32_t>(result), mExpectedCallbacks
, mCallbackInitiated, static_cast<uint32_t>(mResult)); }
} while (0)
176 static_cast<uint32_t>(result), mExpectedCallbacks, mCallbackInitiated,do { const ::mozilla::LogModule* moz_real_module = gStreamCopierLog
; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module
, mozilla::LogLevel::Debug)), 0))) { mozilla::detail::log_print
(moz_real_module, mozilla::LogLevel::Debug, "nsAsyncRedirectVerifyHelper::ExplicitCallback() "
"result=%" "x" " expectedCBs=%u mCallbackInitiated=%u mResult=%"
"x", static_cast<uint32_t>(result), mExpectedCallbacks
, mCallbackInitiated, static_cast<uint32_t>(mResult)); }
} while (0)
177 static_cast<uint32_t>(mResult)))do { const ::mozilla::LogModule* moz_real_module = gStreamCopierLog
; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module
, mozilla::LogLevel::Debug)), 0))) { mozilla::detail::log_print
(moz_real_module, mozilla::LogLevel::Debug, "nsAsyncRedirectVerifyHelper::ExplicitCallback() "
"result=%" "x" " expectedCBs=%u mCallbackInitiated=%u mResult=%"
"x", static_cast<uint32_t>(result), mExpectedCallbacks
, mCallbackInitiated, static_cast<uint32_t>(mResult)); }
} while (0)
;
178
179 nsCOMPtr<nsIAsyncVerifyRedirectCallback> callback(
180 do_QueryInterface(mOldChan));
181
182 if (!callback || !mCallbackEventTarget) {
183 LOG(do { const ::mozilla::LogModule* moz_real_module = gStreamCopierLog
; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module
, mozilla::LogLevel::Debug)), 0))) { mozilla::detail::log_print
(moz_real_module, mozilla::LogLevel::Debug, "nsAsyncRedirectVerifyHelper::ExplicitCallback() "
"callback=%p mCallbackEventTarget=%p", callback.get(), mCallbackEventTarget
.get()); } } while (0)
184 ("nsAsyncRedirectVerifyHelper::ExplicitCallback() "do { const ::mozilla::LogModule* moz_real_module = gStreamCopierLog
; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module
, mozilla::LogLevel::Debug)), 0))) { mozilla::detail::log_print
(moz_real_module, mozilla::LogLevel::Debug, "nsAsyncRedirectVerifyHelper::ExplicitCallback() "
"callback=%p mCallbackEventTarget=%p", callback.get(), mCallbackEventTarget
.get()); } } while (0)
185 "callback=%p mCallbackEventTarget=%p",do { const ::mozilla::LogModule* moz_real_module = gStreamCopierLog
; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module
, mozilla::LogLevel::Debug)), 0))) { mozilla::detail::log_print
(moz_real_module, mozilla::LogLevel::Debug, "nsAsyncRedirectVerifyHelper::ExplicitCallback() "
"callback=%p mCallbackEventTarget=%p", callback.get(), mCallbackEventTarget
.get()); } } while (0)
186 callback.get(), mCallbackEventTarget.get()))do { const ::mozilla::LogModule* moz_real_module = gStreamCopierLog
; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module
, mozilla::LogLevel::Debug)), 0))) { mozilla::detail::log_print
(moz_real_module, mozilla::LogLevel::Debug, "nsAsyncRedirectVerifyHelper::ExplicitCallback() "
"callback=%p mCallbackEventTarget=%p", callback.get(), mCallbackEventTarget
.get()); } } while (0)
;
187 return;
188 }
189
190 mCallbackInitiated = false; // reset to ensure only one callback
191 mWaitingForRedirectCallback = false;
192
193 // Now, dispatch the callback on the event-target which called Init()
194 nsCOMPtr<nsIRunnable> event =
195 new nsAsyncVerifyRedirectCallbackEvent(callback, result);
196 if (!event) {
197 NS_WARNING(NS_DebugBreak(NS_DEBUG_WARNING, "nsAsyncRedirectVerifyHelper::ExplicitCallback() "
"failed creating callback event!", nullptr, "/var/lib/jenkins/workspace/firefox-scan-build/netwerk/base/nsAsyncRedirectVerifyHelper.cpp"
, 199)
198 "nsAsyncRedirectVerifyHelper::ExplicitCallback() "NS_DebugBreak(NS_DEBUG_WARNING, "nsAsyncRedirectVerifyHelper::ExplicitCallback() "
"failed creating callback event!", nullptr, "/var/lib/jenkins/workspace/firefox-scan-build/netwerk/base/nsAsyncRedirectVerifyHelper.cpp"
, 199)
199 "failed creating callback event!")NS_DebugBreak(NS_DEBUG_WARNING, "nsAsyncRedirectVerifyHelper::ExplicitCallback() "
"failed creating callback event!", nullptr, "/var/lib/jenkins/workspace/firefox-scan-build/netwerk/base/nsAsyncRedirectVerifyHelper.cpp"
, 199)
;
200 return;
201 }
202 nsresult rv = mCallbackEventTarget->Dispatch(event, NS_DISPATCH_NORMALnsIEventTarget::DISPATCH_NORMAL);
203 if (NS_FAILED(rv)((bool)(__builtin_expect(!!(NS_FAILED_impl(rv)), 0)))) {
204 NS_WARNING(NS_DebugBreak(NS_DEBUG_WARNING, "nsAsyncRedirectVerifyHelper::ExplicitCallback() "
"failed dispatching callback event!", nullptr, "/var/lib/jenkins/workspace/firefox-scan-build/netwerk/base/nsAsyncRedirectVerifyHelper.cpp"
, 206)
205 "nsAsyncRedirectVerifyHelper::ExplicitCallback() "NS_DebugBreak(NS_DEBUG_WARNING, "nsAsyncRedirectVerifyHelper::ExplicitCallback() "
"failed dispatching callback event!", nullptr, "/var/lib/jenkins/workspace/firefox-scan-build/netwerk/base/nsAsyncRedirectVerifyHelper.cpp"
, 206)
206 "failed dispatching callback event!")NS_DebugBreak(NS_DEBUG_WARNING, "nsAsyncRedirectVerifyHelper::ExplicitCallback() "
"failed dispatching callback event!", nullptr, "/var/lib/jenkins/workspace/firefox-scan-build/netwerk/base/nsAsyncRedirectVerifyHelper.cpp"
, 206)
;
207 } else {
208 LOG(do { const ::mozilla::LogModule* moz_real_module = gStreamCopierLog
; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module
, mozilla::LogLevel::Debug)), 0))) { mozilla::detail::log_print
(moz_real_module, mozilla::LogLevel::Debug, "nsAsyncRedirectVerifyHelper::ExplicitCallback() "
"dispatched callback event=%p", event.get()); } } while (0)
209 ("nsAsyncRedirectVerifyHelper::ExplicitCallback() "do { const ::mozilla::LogModule* moz_real_module = gStreamCopierLog
; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module
, mozilla::LogLevel::Debug)), 0))) { mozilla::detail::log_print
(moz_real_module, mozilla::LogLevel::Debug, "nsAsyncRedirectVerifyHelper::ExplicitCallback() "
"dispatched callback event=%p", event.get()); } } while (0)
210 "dispatched callback event=%p",do { const ::mozilla::LogModule* moz_real_module = gStreamCopierLog
; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module
, mozilla::LogLevel::Debug)), 0))) { mozilla::detail::log_print
(moz_real_module, mozilla::LogLevel::Debug, "nsAsyncRedirectVerifyHelper::ExplicitCallback() "
"dispatched callback event=%p", event.get()); } } while (0)
211 event.get()))do { const ::mozilla::LogModule* moz_real_module = gStreamCopierLog
; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module
, mozilla::LogLevel::Debug)), 0))) { mozilla::detail::log_print
(moz_real_module, mozilla::LogLevel::Debug, "nsAsyncRedirectVerifyHelper::ExplicitCallback() "
"dispatched callback event=%p", event.get()); } } while (0)
;
212 }
213}
214
215void nsAsyncRedirectVerifyHelper::InitCallback() {
216 LOG(do { const ::mozilla::LogModule* moz_real_module = gStreamCopierLog
; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module
, mozilla::LogLevel::Debug)), 0))) { mozilla::detail::log_print
(moz_real_module, mozilla::LogLevel::Debug, "nsAsyncRedirectVerifyHelper::InitCallback() "
"expectedCBs=%d mResult=%" "x", mExpectedCallbacks, static_cast
<uint32_t>(mResult)); } } while (0)
217 ("nsAsyncRedirectVerifyHelper::InitCallback() "do { const ::mozilla::LogModule* moz_real_module = gStreamCopierLog
; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module
, mozilla::LogLevel::Debug)), 0))) { mozilla::detail::log_print
(moz_real_module, mozilla::LogLevel::Debug, "nsAsyncRedirectVerifyHelper::InitCallback() "
"expectedCBs=%d mResult=%" "x", mExpectedCallbacks, static_cast
<uint32_t>(mResult)); } } while (0)
218 "expectedCBs=%d mResult=%" PRIx32,do { const ::mozilla::LogModule* moz_real_module = gStreamCopierLog
; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module
, mozilla::LogLevel::Debug)), 0))) { mozilla::detail::log_print
(moz_real_module, mozilla::LogLevel::Debug, "nsAsyncRedirectVerifyHelper::InitCallback() "
"expectedCBs=%d mResult=%" "x", mExpectedCallbacks, static_cast
<uint32_t>(mResult)); } } while (0)
219 mExpectedCallbacks, static_cast<uint32_t>(mResult)))do { const ::mozilla::LogModule* moz_real_module = gStreamCopierLog
; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module
, mozilla::LogLevel::Debug)), 0))) { mozilla::detail::log_print
(moz_real_module, mozilla::LogLevel::Debug, "nsAsyncRedirectVerifyHelper::InitCallback() "
"expectedCBs=%d mResult=%" "x", mExpectedCallbacks, static_cast
<uint32_t>(mResult)); } } while (0)
;
220
221 mCallbackInitiated = true;
222
223 // Invoke the callback if we are done
224 if (mExpectedCallbacks == 0) ExplicitCallback(mResult);
225}
226
227NS_IMETHODIMPnsresult
228nsAsyncRedirectVerifyHelper::GetName(nsACString& aName) {
229 aName.AssignLiteral("nsAsyncRedirectVerifyHelper");
230 return NS_OK;
231}
232
233NS_IMETHODIMPnsresult
234nsAsyncRedirectVerifyHelper::Run() {
235 /* If the channel got canceled after it fired AsyncOnChannelRedirect
236 * and before we got here, mostly because docloader load has been canceled,
237 * we must completely ignore this notification and prevent any further
238 * notification.
239 */
240 if (IsOldChannelCanceled()) {
241 ExplicitCallback(NS_BINDING_ABORTED);
242 return NS_OK;
243 }
244
245 // First, the global observer
246 NS_ASSERTION(gIOService, "Must have an IO service at this point")do { if (!(gIOService)) { NS_DebugBreak(NS_DEBUG_ASSERTION, "Must have an IO service at this point"
, "gIOService", "/var/lib/jenkins/workspace/firefox-scan-build/netwerk/base/nsAsyncRedirectVerifyHelper.cpp"
, 246); MOZ_PretendNoReturn(); } } while (0)
;
247 LOG(("nsAsyncRedirectVerifyHelper::Run() calling gIOService..."))do { const ::mozilla::LogModule* moz_real_module = gStreamCopierLog
; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module
, mozilla::LogLevel::Debug)), 0))) { mozilla::detail::log_print
(moz_real_module, mozilla::LogLevel::Debug, "nsAsyncRedirectVerifyHelper::Run() calling gIOService..."
); } } while (0)
;
248 nsresult rv =
249 gIOService->AsyncOnChannelRedirect(mOldChan, mNewChan, mFlags, this);
250 if (NS_FAILED(rv)((bool)(__builtin_expect(!!(NS_FAILED_impl(rv)), 0)))) {
251 ExplicitCallback(rv);
252 return NS_OK;
253 }
254
255 // Now, the per-channel observers
256 nsCOMPtr<nsIChannelEventSink> sink;
257 NS_QueryNotificationCallbacks(mOldChan, sink);
258 if (sink) {
259 LOG(("nsAsyncRedirectVerifyHelper::Run() calling sink..."))do { const ::mozilla::LogModule* moz_real_module = gStreamCopierLog
; if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module
, mozilla::LogLevel::Debug)), 0))) { mozilla::detail::log_print
(moz_real_module, mozilla::LogLevel::Debug, "nsAsyncRedirectVerifyHelper::Run() calling sink..."
); } } while (0)
;
260 rv = DelegateOnChannelRedirect(sink, mOldChan, mNewChan, mFlags);
Value stored to 'rv' is never read
261 }
262
263 // All invocations to AsyncOnChannelRedirect has been done - call
264 // InitCallback() to flag this
265 InitCallback();
266 return NS_OK;
267}
268
269bool nsAsyncRedirectVerifyHelper::IsOldChannelCanceled() {
270 if (!mOldChan) {
271 return false;
272 }
273 bool canceled;
274 nsresult rv = mOldChan->GetCanceled(&canceled);
275 return NS_SUCCEEDED(rv)((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1))) && canceled;
276}
277
278} // namespace net
279} // namespace mozilla