/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
MOZ_DIAGNOSTIC_ASSERT(
mExpectedCallbacks > 0, "OnRedirectVerifyCallback called more times than expected"); if (mExpectedCallbacks <= 0) { return NS_ERROR_UNEXPECTED;
}
--mExpectedCallbacks;
// If response indicates failure we may call back immediately if (NS_FAILED(result)) { // We chose to store the first failure-value (as opposed to the last) if (NS_SUCCEEDED(mResult)) mResult = result;
// If InitCallback() has been called, just invoke the callback and // return. Otherwise it will be invoked from InitCallback() if (mCallbackInitiated) {
ExplicitCallback(mResult); return NS_OK;
}
}
// If the expected-counter is in balance and InitCallback() was called, all // sinks have agreed that the redirect is ok and we can invoke our callback if (mCallbackInitiated && mExpectedCallbacks == 0) {
ExplicitCallback(mResult);
}
if (IsOldChannelCanceled()) {
LOG(
(" old channel has been canceled, cancel the redirect by " "emulating OnRedirectVerifyCallback..."));
(void)OnRedirectVerifyCallback(NS_BINDING_ABORTED); return NS_BINDING_ABORTED;
}
// If the sink returns failure from this call the redirect is vetoed. We // emulate a callback from the sink in this case in order to perform all // the necessary logic. if (NS_FAILED(rv)) {
LOG((" emulating OnRedirectVerifyCallback..."));
(void)OnRedirectVerifyCallback(rv);
}
return rv; // Return the actual status since our caller may need it
}
NS_IMETHODIMP
nsAsyncRedirectVerifyHelper::Run() { /* If the channel got canceled after it fired AsyncOnChannelRedirect * and before we got here, mostly because docloader load has been canceled, * we must completely ignore this notification and prevent any further * notification.
*/ if (IsOldChannelCanceled()) {
ExplicitCallback(NS_BINDING_ABORTED); return NS_OK;
}
// If transparent, avoid notifying the observers. if (mFlags & nsIChannelEventSink::REDIRECT_TRANSPARENT) {
ExplicitCallback(NS_OK); return NS_OK;
}
// First, the global observer
NS_ASSERTION(gIOService, "Must have an IO service at this point");
LOG(("nsAsyncRedirectVerifyHelper::Run() calling gIOService..."));
nsresult rv =
gIOService->AsyncOnChannelRedirect(mOldChan, mNewChan, mFlags, this); if (NS_FAILED(rv)) {
ExplicitCallback(rv); return NS_OK;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.