import changes from `dev' branch of rmottola/Arctic-Fox:

- Bug 1255818. Switch from JS_ClearPendingException to AutoJSAPI::ClearException for cases when we have an AutoJSAPI around. r=bholley (e1e0413493)
- Bug 1253591. HTMLAllCollection should be rooted at the document, not the root element, so it can find the root element. r=peterv (c5f2f253a9)
- Bug 1257270 - Use std::nullptr_t instead of nullptr_t in WMFUtils.h. r=cpearce (539e705876)
- Bug 1251881 - use UniquePtr instead of ScopedDeletePtr in mozglue/linker/; r=glandium (2fe329e32c)
- Bug 1219068 - Compute size correctly when a character consists entirely of glue. r=karlt (80f2e23268)
- Bug 1246132 - Improve register allocation speed on large functions, r=sunfish. (6e023c252b)
- Bug 1150354: Make nsPluginDirServiceProvider build with MSVC 2015 CTP 6, r=jmathies (0113760730)
- Bug 1197311 - Remove PR_snprintf calls in dom/ r=froydnj (6268400ef0)
- Bug 1255099 - XHR CTOR doesn't need to use implicitJSContext, r=bz (72f08fbc36)
- Bug 1255597 - Part 1: Remove redundent trailing spaces. r=khuey (7f2240cb05)
- Bug 1255597 - Part 2: Follow spec to modify the content-type check conditions which determine parsing XHR body or not. r=khuey (ba6f7fc536)
- Bug 1255597 - Part 3: Synchronize content-type hint of HttpChannelChild to HttpChannelParent. r=jduell (bb97478b01)
- Bug 1255597 - Part 4: Remove 'expected fail' settings and expect test cases in responsexml-media-type.htm should be passed. r=khuey (772884b4fb)
- Bug 1201170 - During message diversion must be possible to suspend them. r=jduell (abb2361b7f)
- Bug 1201174 - For FTP - in case of divertToParent, it myst be possible to delay delivering of OnDataAv./OnStopR. r=jduell (9299ef81be)
- Bug 1247393 - use arrays of UniquePtr in ChannelEventQueue; r=mcmanus (7621205b53)
- Bug 1254730 - ChannelEventQueue must be thread-safe, r=michal (b8e01204e9)
- Bug 1254859 part 2. Switch the AutoEntryScript in nsXULTemplateBuilder::InitHTMLTemplateRoot to take ownership of error reporting. r=bholley (f183ec692c)
- Bug 1254859 part 1. Switch the AutoEntryScript in nsGlobalWindow::FireOnNewGlobalObject to take ownership of error reporting. r=bholley (b0cd891917)
- Bug 1254860. Switch the AutoEntryScript TestShellCommandParent::RunCallback to taking ownership of error reporting. r=bholley (0c9697e60f)
- Bug 1254857. Switch the AutoEntryScript in xpc::EvalInSandbox to take ownership of error reporting. r=bholley (93b6bfc87c)
- Bug 1254847 part 3. Make AutoEntryScript always take ownership of error reporting. r=bholley (3c2929462f)
- Bug 1256688 - Continue using getPropertyDescriptor for has in Sandbox창. r=peterv (be7e50b715)
- Bug 1254730 - patch 2 - Better comments and a better management of lifetime of ChannelEvents, r=michal (8348911e35)
- Bug 1163198 - Remove instances of #ifdef PR_LOGGING in dom/plugins. r=froydnj (ba13039dfa)
- Bug 1253216 - clean up the atomic ops ifdef nest. r=jorendorff (6ca747d3cf)
- Bug 1257055 - Use jit/arm64/Architecture-arm64.h on non-JIT aarch64. r=lth (4f3949cd19)
- Bug 1253379 - Cache timings not send to HttpChannelChild r=mayhemer (395172278f)
- align SetAllowStaleCacheContent to FF52, possible misspatch (9d29d27011)
This commit is contained in:
2024-03-19 22:08:44 +08:00
parent 904e3bdf3a
commit 5c3e1ed7ef
90 changed files with 1177 additions and 710 deletions
+8 -8
View File
@@ -112,7 +112,7 @@
#include "mozAutoDocUpdate.h"
#include "prprf.h"
#include "mozilla/Snprintf.h"
#include "nsDOMMutationObserver.h"
#include "nsWrapperCacheInlines.h"
#include "nsCycleCollector.h"
@@ -1878,13 +1878,13 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INTERNAL(FragmentOrElement)
}
const char* nsuri = nsid < ArrayLength(kNSURIs) ? kNSURIs[nsid] : "";
PR_snprintf(name, sizeof(name), "FragmentOrElement%s %s%s%s%s %s",
nsuri,
localName.get(),
NS_ConvertUTF16toUTF8(id).get(),
NS_ConvertUTF16toUTF8(classes).get(),
orphan.get(),
uri.get());
snprintf_literal(name, "FragmentOrElement%s %s%s%s%s %s",
nsuri,
localName.get(),
NS_ConvertUTF16toUTF8(id).get(),
NS_ConvertUTF16toUTF8(classes).get(),
orphan.get(),
uri.get());
cb.DescribeRefCountedNode(tmp->mRefCnt.get(), name);
}
else {
+4 -4
View File
@@ -25,7 +25,7 @@
#include "nsContentUtils.h"
#include "nsReadableUtils.h"
#include "nsAutoPtr.h"
#include "prprf.h"
#include "mozilla/Snprintf.h"
#include "nsIDocument.h"
#include "nsGkAtoms.h"
#include "nsCCUncollectableMarker.h"
@@ -130,11 +130,11 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INTERNAL(NodeInfo)
uint32_t nsid = tmp->NamespaceID();
nsAtomCString localName(tmp->NameAtom());
if (nsid < ArrayLength(kNodeInfoNSURIs)) {
PR_snprintf(name, sizeof(name), "NodeInfo%s %s", kNodeInfoNSURIs[nsid],
localName.get());
snprintf_literal(name, "NodeInfo%s %s", kNodeInfoNSURIs[nsid],
localName.get());
}
else {
PR_snprintf(name, sizeof(name), "NodeInfo %s", localName.get());
snprintf_literal(name, "NodeInfo %s", localName.get());
}
cb.DescribeRefCountedNode(tmp->mRefCnt.get(), name);
+2
View File
@@ -657,6 +657,8 @@ AutoEntryScript::AutoEntryScript(nsIGlobalObject* aGlobalObject,
if (aIsMainThread && gRunToCompletionListeners > 0) {
mDocShellEntryMonitor.emplace(cx(), aReason);
}
TakeOwnershipOfErrorReporting();
}
AutoEntryScript::AutoEntryScript(JSObject* aObject,
+8 -9
View File
@@ -23,7 +23,7 @@
#include "mozilla/Logging.h"
#include "plstr.h"
#include "prprf.h"
#include "mozilla/Snprintf.h"
#include "mozilla/Telemetry.h"
#include "nsIInterfaceRequestor.h"
@@ -1767,12 +1767,12 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INTERNAL(nsDocument)
if (tmp->mDocumentURI)
tmp->mDocumentURI->GetSpec(uri);
if (nsid < ArrayLength(kNSURIs)) {
PR_snprintf(name, sizeof(name), "nsDocument %s %s %s",
loadedAsData.get(), kNSURIs[nsid], uri.get());
snprintf_literal(name, "nsDocument %s %s %s",
loadedAsData.get(), kNSURIs[nsid], uri.get());
}
else {
PR_snprintf(name, sizeof(name), "nsDocument %s %s",
loadedAsData.get(), uri.get());
snprintf_literal(name, "nsDocument %s %s",
loadedAsData.get(), uri.get());
}
cb.DescribeRefCountedNode(tmp->mRefCnt.get(), name);
}
@@ -2962,10 +2962,9 @@ GetFormattedTimeString(PRTime aTime, nsAString& aFormattedTimeString)
PR_ExplodeTime(aTime, PR_LocalTimeParameters, &prtime);
// "MM/DD/YYYY hh:mm:ss"
char formatedTime[24];
if (PR_snprintf(formatedTime, sizeof(formatedTime),
"%02ld/%02ld/%04hd %02ld:%02ld:%02ld",
prtime.tm_month + 1, prtime.tm_mday, prtime.tm_year,
prtime.tm_hour , prtime.tm_min, prtime.tm_sec)) {
if (snprintf_literal(formatedTime, "%02d/%02d/%04d %02d:%02d:%02d",
prtime.tm_month + 1, prtime.tm_mday, int(prtime.tm_year),
prtime.tm_hour , prtime.tm_min, prtime.tm_sec)) {
CopyASCIItoUTF16(nsDependentCString(formatedTime), aFormattedTimeString);
} else {
// If we for whatever reason failed to find the last modified time
-2
View File
@@ -1104,7 +1104,6 @@ nsFrameMessageManager::ReceiveMessage(nsISupports* aTarget,
}
AutoEntryScript aes(wrappedJS->GetJSObject(), "message manager handler");
aes.TakeOwnershipOfErrorReporting();
JSContext* cx = aes.cx();
JS::Rooted<JSObject*> object(cx, wrappedJS->GetJSObject());
@@ -1686,7 +1685,6 @@ nsMessageManagerScriptExecutor::LoadScriptInternal(const nsAString& aURL,
JS::Rooted<JSObject*> global(rt, mGlobal->GetJSObject());
if (global) {
AutoEntryScript aes(global, "message manager script load");
aes.TakeOwnershipOfErrorReporting();
JSContext* cx = aes.cx();
if (script) {
if (aRunInGlobalScope) {
+5 -5
View File
@@ -34,7 +34,7 @@
#include "mozAutoDocUpdate.h"
#include "PLDHashTable.h"
#include "prprf.h"
#include "mozilla/Snprintf.h"
#include "nsWrapperCacheInlines.h"
using namespace mozilla;
@@ -90,8 +90,8 @@ NS_IMPL_CYCLE_COLLECTION_CAN_SKIP_THIS_END
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INTERNAL(nsGenericDOMDataNode)
if (MOZ_UNLIKELY(cb.WantDebugInfo())) {
char name[40];
PR_snprintf(name, sizeof(name), "nsGenericDOMDataNode (len=%d)",
tmp->mText.GetLength());
snprintf_literal(name, "nsGenericDOMDataNode (len=%d)",
tmp->mText.GetLength());
cb.DescribeRefCountedNode(tmp->mRefCnt.get(), name);
} else {
NS_IMPL_CYCLE_COLLECTION_DESCRIBE(nsGenericDOMDataNode, tmp->mRefCnt.get())
@@ -426,7 +426,7 @@ nsGenericDOMDataNode::ToCString(nsAString& aBuf, int32_t aOffset,
aBuf.AppendLiteral("&gt;");
} else if ((ch < ' ') || (ch >= 127)) {
char buf[10];
PR_snprintf(buf, sizeof(buf), "\\u%04x", ch);
snprintf_literal(buf, "\\u%04x", ch);
AppendASCIItoUTF16(buf, aBuf);
} else {
aBuf.Append(ch);
@@ -446,7 +446,7 @@ nsGenericDOMDataNode::ToCString(nsAString& aBuf, int32_t aOffset,
aBuf.AppendLiteral("&gt;");
} else if ((ch < ' ') || (ch >= 127)) {
char buf[10];
PR_snprintf(buf, sizeof(buf), "\\u%04x", ch);
snprintf_literal(buf, "\\u%04x", ch);
AppendASCIItoUTF16(buf, aBuf);
} else {
aBuf.Append(ch);
+7 -8
View File
@@ -20,6 +20,7 @@
#include "mozilla/dom/DOMStorage.h"
#include "mozilla/dom/StorageEvent.h"
#include "mozilla/dom/StorageEventBinding.h"
#include "mozilla/IntegerPrintfMacros.h"
#if defined(MOZ_WIDGET_ANDROID) || defined(MOZ_WIDGET_GONK)
#include "mozilla/dom/WindowOrientationObserver.h"
#endif
@@ -1788,9 +1789,8 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INTERNAL(nsGlobalWindow)
if (tmp->mDoc && tmp->mDoc->GetDocumentURI()) {
tmp->mDoc->GetDocumentURI()->GetSpec(uri);
}
PR_snprintf(name, sizeof(name), "nsGlobalWindow #%llu %s %s",
tmp->mWindowID, tmp->IsInnerWindow() ? "inner" : "outer",
uri.get());
snprintf_literal(name, "nsGlobalWindow # %" PRIu64 " %s %s", tmp->mWindowID,
tmp->IsInnerWindow() ? "inner" : "outer", uri.get());
cb.DescribeRefCountedNode(tmp->mRefCnt.get(), name);
} else {
NS_IMPL_CYCLE_COLLECTION_DESCRIBE(nsGlobalWindow, tmp->mRefCnt.get())
@@ -12534,13 +12534,12 @@ nsGlobalWindow::RunTimeoutHandler(nsTimeout* aTimeout,
// New script entry point required, due to the "Create a script" sub-step of
// http://www.whatwg.org/specs/web-apps/current-work/#timer-initialisation-steps
nsAutoMicroTask mt;
AutoEntryScript entryScript(this, reason, true, aScx->GetNativeContext());
entryScript.TakeOwnershipOfErrorReporting();
JS::CompileOptions options(entryScript.cx());
AutoEntryScript aes(this, reason, true, aScx->GetNativeContext());
JS::CompileOptions options(aes.cx());
options.setFileAndLine(filename, lineNo)
.setVersion(JSVERSION_DEFAULT);
JS::Rooted<JSObject*> global(entryScript.cx(), FastGetGlobalJSObject());
nsJSUtils::EvaluateString(entryScript.cx(), nsDependentString(script),
JS::Rooted<JSObject*> global(aes.cx(), FastGetGlobalJSObject());
nsJSUtils::EvaluateString(aes.cx(), nsDependentString(script),
global, options);
} else {
// Hold strong ref to ourselves while we call the callback.
+6 -7
View File
@@ -1137,10 +1137,9 @@ nsScriptLoader::EvaluateScript(nsScriptLoadRequest* aRequest,
// New script entry point required, due to the "Create a script" sub-step of
// http://www.whatwg.org/specs/web-apps/current-work/#execute-the-script-block
nsAutoMicroTask mt;
AutoEntryScript entryScript(globalObject, "<script> element", true,
context->GetNativeContext());
entryScript.TakeOwnershipOfErrorReporting();
JS::Rooted<JSObject*> global(entryScript.cx(),
AutoEntryScript aes(globalObject, "<script> element", true,
context->GetNativeContext());
JS::Rooted<JSObject*> global(aes.cx(),
globalObject->GetGlobalJSObject());
bool oldProcessingScriptTag = context->GetProcessingScriptTag();
@@ -1161,9 +1160,9 @@ nsScriptLoader::EvaluateScript(nsScriptLoadRequest* aRequest,
aRequest->mElement);
}
JS::CompileOptions options(entryScript.cx());
FillCompileOptionsForRequest(entryScript, aRequest, global, &options);
rv = nsJSUtils::EvaluateString(entryScript.cx(), aSrcBuf, global, options,
JS::CompileOptions options(aes.cx());
FillCompileOptionsForRequest(aes, aRequest, global, &options);
rv = nsJSUtils::EvaluateString(aes.cx(), aSrcBuf, global, options,
aRequest->OffThreadTokenPtr());
}
+2 -2
View File
@@ -23,7 +23,7 @@
#include "nsNameSpaceManager.h"
#include "nsTextFragment.h"
#include "nsString.h"
#include "prprf.h"
#include "mozilla/Snprintf.h"
#include "nsUnicharUtils.h"
#include "nsCRT.h"
#include "nsContentUtils.h"
@@ -606,7 +606,7 @@ nsXMLContentSerializer::GenerateNewPrefix(nsAString& aPrefix)
{
aPrefix.Assign('a');
char buf[128];
PR_snprintf(buf, sizeof(buf), "%d", mPrefixIndex++);
snprintf_literal(buf, "%d", mPrefixIndex++);
AppendASCIItoUTF16(buf, aPrefix);
}
+13 -8
View File
@@ -697,7 +697,7 @@ nsXMLHttpRequest::GetResponseText(nsString& aResponseText, ErrorResult& aRv)
}
mResponseBodyDecodedPos = mResponseBody.Length();
if (mState & XML_HTTP_REQUEST_DONE) {
// Free memory buffer which we no longer need
mResponseBody.Truncate();
@@ -1222,7 +1222,7 @@ nsXMLHttpRequest::IsSafeHeader(const nsACString& header, nsIHttpChannel* httpCha
if (NS_FAILED(status)) {
return false;
}
}
}
const char* kCrossOriginSafeHeaders[] = {
"cache-control", "content-language", "content-type", "expires",
"last-modified", "pragma"
@@ -1382,7 +1382,7 @@ nsXMLHttpRequest::GetResponseHeader(const nsACString& header,
already_AddRefed<nsILoadGroup>
nsXMLHttpRequest::GetLoadGroup() const
{
if (mState & XML_HTTP_REQUEST_BACKGROUND) {
if (mState & XML_HTTP_REQUEST_BACKGROUND) {
return nullptr;
}
@@ -1455,7 +1455,7 @@ nsXMLHttpRequest::DispatchProgressEvent(DOMEventTargetHelper* aTarget,
aLengthComputable, aLoaded, aTotal);
}
}
already_AddRefed<nsIHttpChannel>
nsXMLHttpRequest::GetCurrentHttpChannel()
{
@@ -1562,7 +1562,7 @@ nsXMLHttpRequest::Open(const nsACString& inMethod, const nsACString& url,
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIDocument> doc =
nsContentUtils::GetDocumentFromScriptContext(sc);
nsCOMPtr<nsIURI> baseURI;
if (mBaseURI) {
baseURI = mBaseURI;
@@ -1836,7 +1836,7 @@ nsXMLHttpRequest::OnDataAvailable(nsIRequest *request,
mDataAvailable += totalRead;
ChangeState(XML_HTTP_REQUEST_LOADING);
MaybeDispatchProgressEvents(false);
return NS_OK;
@@ -1996,7 +1996,12 @@ nsXMLHttpRequest::OnStartRequest(nsIRequest *request, nsISupports *ctxt)
} else {
mIsHtml = true;
}
} else if (type.Find("xml") == kNotFound) {
} else if (!(type.EqualsLiteral("text/xml") ||
type.EqualsLiteral("application/xml") ||
type.RFind("+xml", true, -1, 4) != kNotFound)) {
// Follow https://xhr.spec.whatwg.org/
// If final MIME type is not null, text/html, text/xml, application/xml,
// or does not end in +xml, return null.
mState &= ~XML_HTTP_REQUEST_PARSEBODY;
}
} else {
@@ -2726,7 +2731,7 @@ nsXMLHttpRequest::Send(nsIVariant* aVariant, const Nullable<RequestBody>& aBody)
if (!NS_InputStreamIsBuffered(postDataStream)) {
nsCOMPtr<nsIInputStream> bufferedStream;
rv = NS_NewBufferedInputStream(getter_AddRefs(bufferedStream),
postDataStream,
postDataStream,
4096);
NS_ENSURE_SUCCESS(rv, rv);
+2 -4
View File
@@ -207,7 +207,6 @@ public:
// The WebIDL constructors.
static already_AddRefed<nsXMLHttpRequest>
Constructor(const mozilla::dom::GlobalObject& aGlobal,
JSContext* aCx,
const mozilla::dom::MozXMLHttpRequestParameters& aParams,
ErrorResult& aRv)
{
@@ -227,18 +226,17 @@ public:
static already_AddRefed<nsXMLHttpRequest>
Constructor(const mozilla::dom::GlobalObject& aGlobal,
JSContext* aCx,
const nsAString& ignored,
ErrorResult& aRv)
{
// Pretend like someone passed null, so we can pick up the default values
mozilla::dom::MozXMLHttpRequestParameters params;
if (!params.Init(aCx, JS::NullHandleValue)) {
if (!params.Init(aGlobal.Context(), JS::NullHandleValue)) {
aRv.Throw(NS_ERROR_UNEXPECTED);
return nullptr;
}
return Constructor(aGlobal, aCx, params, aRv);
return Constructor(aGlobal, params, aRv);
}
void Construct(nsIPrincipal* aPrincipal,
+3 -3
View File
@@ -30,7 +30,7 @@
#include "xpcprivate.h"
#include "XrayWrapper.h"
#include "nsPrintfCString.h"
#include "prprf.h"
#include "mozilla/Snprintf.h"
#include "nsGlobalWindow.h"
#include "mozilla/dom/ScriptSettings.h"
@@ -2429,13 +2429,13 @@ ConvertJSValueToByteString(JSContext* cx, JS::Handle<JS::Value> v,
// 20 digits, plus one more for the null terminator.
char index[21];
static_assert(sizeof(size_t) <= 8, "index array too small");
PR_snprintf(index, sizeof(index), "%d", badCharIndex);
snprintf_literal(index, "%d", badCharIndex);
// A char16_t is 16 bits long. The biggest unsigned 16 bit
// number (65,535) has 5 digits, plus one more for the null
// terminator.
char badCharArray[6];
static_assert(sizeof(char16_t) <= 2, "badCharArray too small");
PR_snprintf(badCharArray, sizeof(badCharArray), "%d", badChar);
snprintf_literal(badCharArray, "%d", badChar);
ThrowErrorMessage(cx, MSG_INVALID_BYTESTRING, index, badCharArray);
return false;
}
-1
View File
@@ -3220,7 +3220,6 @@ WrappedJSToDictionary(nsISupports* aObject, T& aDictionary)
// we need this AutoEntryScript here because the spec requires us to execute
// getters when parsing a dictionary
AutoEntryScript aes(global, "WebIDL dictionary creation");
aes.TakeOwnershipOfErrorReporting();
JS::Rooted<JS::Value> v(aes.cx(), JS::ObjectValue(*obj));
return aDictionary.Init(aes.cx(), v);
+1 -1
View File
@@ -1630,7 +1630,7 @@ DOMInterfaces = {
'XMLHttpRequest': [
{
'nativeType': 'nsXMLHttpRequest',
'implicitJSContext': [ 'constructor', 'send'],
'implicitJSContext': [ 'send'],
},
{
'workers': True,
-3
View File
@@ -189,9 +189,6 @@ CallbackObject::CallSetup::CallSetup(CallbackObject* aCallback,
// And now we're ready to go.
mCx = cx;
// Make sure the JS engine doesn't report exceptions we want to re-throw.
mAutoEntryScript->TakeOwnershipOfErrorReporting();
}
bool
@@ -107,7 +107,7 @@ public:
RefPtr<BluetoothDiscoveryHandle> discoveryHandle =
BluetoothDiscoveryHandle::Create(mAdapter->GetParentObject());
if (!ToJSValue(cx, discoveryHandle, aValue)) {
JS_ClearPendingException(cx);
jsapi.ClearException();
return false;
}
@@ -161,7 +161,7 @@ public:
mServiceUuids, v.get_BluetoothUuid());
if (!ToJSValue(cx, discoveryHandle, aValue)) {
JS_ClearPendingException(cx);
jsapi.ClearException();
return false;
}
@@ -76,7 +76,7 @@ public:
JSContext* cx = jsapi.cx();
if (!ToJSValue(cx, uuids, aValue)) {
BT_WARNING("Cannot create JS array!");
JS_ClearPendingException(cx);
jsapi.ClearException();
return false;
}
@@ -332,7 +332,7 @@ public:
JSContext* cx = jsapi.cx();
if (!ToJSValue(cx, v.get_ArrayOfuint8_t(), aValue)) {
JS_ClearPendingException(cx);
jsapi.ClearException();
return false;
}
@@ -202,7 +202,7 @@ public:
JSContext* cx = jsapi.cx();
if (!ToJSValue(cx, v.get_ArrayOfuint8_t(), aValue)) {
JS_ClearPendingException(cx);
jsapi.ClearException();
return false;
}
+3 -3
View File
@@ -6,7 +6,7 @@
#include "nsContentUtils.h"
#include "nsIDocument.h"
#include "prprf.h"
#include "mozilla/Snprintf.h"
#include "nsGlobalWindow.h"
#include "ScriptSettings.h"
#include "mozilla/DOMEventTargetHelper.h"
@@ -31,8 +31,8 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INTERNAL(DOMEventTargetHelper)
if (tmp->mOwnerWindow && tmp->mOwnerWindow->GetExtantDoc()) {
tmp->mOwnerWindow->GetExtantDoc()->GetDocumentURI(uri);
}
PR_snprintf(name, sizeof(name), "DOMEventTargetHelper %s",
NS_ConvertUTF16toUTF8(uri).get());
snprintf_literal(name, "DOMEventTargetHelper %s",
NS_ConvertUTF16toUTF8(uri).get());
cb.DescribeRefCountedNode(tmp->mRefCnt.get(), name);
} else {
NS_IMPL_CYCLE_COLLECTION_DESCRIBE(DOMEventTargetHelper, tmp->mRefCnt.get())
@@ -243,7 +243,6 @@ nsGeolocationSettings::HandleGeolocationPerOriginSettingsChange(const JS::Value&
// because the spec requires calling getters when enumerating the key of a
// dictionary
AutoEntryScript aes(global, "geolocation.app_settings enumeration");
aes.TakeOwnershipOfErrorReporting();
JSContext *cx = aes.cx();
JS::Rooted<JS::IdVector> ids(cx, JS::IdVector(cx));
@@ -319,7 +318,6 @@ nsGeolocationSettings::HandleGeolocationAlwaysPreciseChange(const JS::Value& aVa
// the spec requires calling getters when accessing array by index
AutoEntryScript aes(global, "geolocation.always_precise indexing");
aes.TakeOwnershipOfErrorReporting();
JSContext *cx = aes.cx();
bool isArray;
+1 -6
View File
@@ -114,14 +114,9 @@ HTMLAllCollection::GetDocumentAllList(const nsAString& aID)
return docAllList;
}
Element* root = mDocument->GetRootElement();
if (!root) {
return nullptr;
}
nsCOMPtr<nsIAtom> id = do_GetAtom(aID);
RefPtr<nsContentList> docAllList =
new nsContentList(root, DocAllResultMatch, nullptr, nullptr, true, id);
new nsContentList(mDocument, DocAllResultMatch, nullptr, nullptr, true, id);
mNamedMap.Put(aID, docAllList);
return docAllList;
}
+2 -2
View File
@@ -159,7 +159,7 @@ IccCallback::NotifyGetCardLockEnabled(bool aResult)
JSContext* cx = jsapi.cx();
JS::Rooted<JS::Value> jsResult(cx);
if (!ToJSValue(cx, result, &jsResult)) {
JS_ClearPendingException(cx);
jsapi.ClearException();
return NS_ERROR_TYPE_ERR;
}
@@ -201,7 +201,7 @@ IccCallback::NotifyGetCardLockRetryCount(int32_t aCount)
JSContext* cx = jsapi.cx();
JS::Rooted<JS::Value> jsResult(cx);
if (!ToJSValue(cx, result, &jsResult)) {
JS_ClearPendingException(cx);
jsapi.ClearException();
return NS_ERROR_TYPE_ERR;
}
+3 -7
View File
@@ -240,13 +240,9 @@ nsresult nsJSThunk::EvaluateScript(nsIChannel *aChannel,
// New script entry point required, due to the "Create a script" step of
// http://www.whatwg.org/specs/web-apps/current-work/#javascript-protocol
nsAutoMicroTask mt;
AutoEntryScript entryScript(innerGlobal, "javascript: URI", true,
scriptContext->GetNativeContext());
// We want to make sure we report any exceptions that happen before we
// return, since whatever happens inside our execution shouldn't affect any
// other scripts that might happen to be running.
entryScript.TakeOwnershipOfErrorReporting();
JSContext* cx = entryScript.cx();
AutoEntryScript aes(innerGlobal, "javascript: URI", true,
scriptContext->GetNativeContext());
JSContext* cx = aes.cx();
JS::Rooted<JSObject*> globalJSObject(cx, innerGlobal->GetGlobalJSObject());
NS_ENSURE_TRUE(globalJSObject, NS_ERROR_UNEXPECTED);
+3 -3
View File
@@ -54,8 +54,8 @@
#include "nsNullPrincipal.h"
#include "nsVariant.h"
// For PR_snprintf
#include "prprf.h"
// For snprintf
#include "mozilla/Snprintf.h"
#include "nsJSUtils.h"
#include "nsGlobalWindow.h"
@@ -2479,7 +2479,7 @@ MediaManager::RemoveWindowID(uint64_t aWindowId)
// Notify the UI that this window no longer has gUM active
char windowBuffer[32];
PR_snprintf(windowBuffer, sizeof(windowBuffer), "%llu", outerID);
snprintf_literal(windowBuffer, "%" PRIu64, outerID);
nsString data = NS_ConvertUTF8toUTF16(windowBuffer);
nsCOMPtr<nsIObserverService> obs = services::GetObserverService();
+1
View File
@@ -28,6 +28,7 @@
#include "mozilla/Logging.h"
#include "nsServiceManagerUtils.h"
#include "gfxPlatform.h"
#include "mozilla/Snprintf.h"
#ifdef MOZ_WIDGET_ANDROID
#include "AndroidBridge.h"
+2 -1
View File
@@ -9,6 +9,7 @@
#include "MediaData.h"
#include "mozilla/ErrorResult.h"
#include "mozilla/Logging.h"
#include "mozilla/Snprintf.h"
extern mozilla::LogModule* GetSourceBufferResourceLog();
@@ -164,7 +165,7 @@ ResourceQueue::Dump(const char* aPath)
ResourceItem* item = ResourceAt(i);
char buf[255];
PR_snprintf(buf, sizeof(buf), "%s/%08u.bin", aPath, i);
snprintf_literal(buf, "%s/%08u.bin", aPath, i);
FILE* fp = fopen(buf, "wb");
if (!fp) {
return;
+3 -2
View File
@@ -18,7 +18,8 @@
#include "nsAutoRef.h"
#include "NesteggPacketHolder.h"
#include "XiphExtradata.h"
#include "prprf.h"
#include "prprf.h" // leaving it for PR_vsnprintf()
#include "mozilla/Snprintf.h"
#include <algorithm>
#include <stdint.h>
@@ -117,7 +118,7 @@ static void webmdemux_log(nestegg* aContext,
va_start(args, aFormat);
PR_snprintf(msg, sizeof(msg), "%p [Nestegg-%s] ", aContext, sevStr);
snprintf_literal(msg, "%p [Nestegg-%s] ", aContext, sevStr);
PR_vsnprintf(msg+strlen(msg), sizeof(msg)-strlen(msg), aFormat, args);
MOZ_LOG(gNesteggLog, LogLevel::Debug, (msg));
+2 -1
View File
@@ -13,6 +13,7 @@
#include "mozilla/dom/RTCCertificateBinding.h"
#include "mozilla/dom/WebCryptoCommon.h"
#include "mozilla/dom/WebCryptoTask.h"
#include "mozilla/Snprintf.h"
#include <cstdio>
@@ -95,7 +96,7 @@ private:
char buf[sizeof(randomName) * 2 + 4];
PL_strncpy(buf, "CN=", 3);
for (size_t i = 0; i < sizeof(randomName); ++i) {
PR_snprintf(&buf[i * 2 + 3], 2, "%.2x", randomName[i]);
snprintf(&buf[i * 2 + 3], 2, "%.2x", randomName[i]);
}
buf[sizeof(buf) - 1] = '\0';
@@ -59,7 +59,7 @@ MobileConnectionCallback::NotifySuccessWithString(const nsAString& aResult)
JS::Rooted<JS::Value> jsResult(cx);
if (!ToJSValue(cx, aResult, &jsResult)) {
JS_ClearPendingException(cx);
jsapi.ClearException();
return NS_ERROR_TYPE_ERR;
}
@@ -102,7 +102,7 @@ MobileConnectionCallback::NotifyGetNetworksSuccess(uint32_t aCount,
JS::Rooted<JS::Value> jsResult(cx);
if (!ToJSValue(cx, results, &jsResult)) {
JS_ClearPendingException(cx);
jsapi.ClearException();
return NS_ERROR_TYPE_ERR;
}
@@ -159,7 +159,7 @@ MobileConnectionCallback::NotifyGetCallForwardingSuccess(uint32_t aCount,
JS::Rooted<JS::Value> jsResult(cx);
if (!ToJSValue(cx, results, &jsResult)) {
JS_ClearPendingException(cx);
jsapi.ClearException();
return NS_ERROR_TYPE_ERR;
}
@@ -184,7 +184,7 @@ MobileConnectionCallback::NotifyGetCallBarringSuccess(uint16_t aProgram,
JSContext* cx = jsapi.cx();
JS::Rooted<JS::Value> jsResult(cx);
if (!ToJSValue(cx, result, &jsResult)) {
JS_ClearPendingException(cx);
jsapi.ClearException();
return NS_ERROR_TYPE_ERR;
}
@@ -214,7 +214,7 @@ MobileConnectionCallback::NotifyGetClirStatusSuccess(uint16_t aN, uint16_t aM)
JSContext* cx = jsapi.cx();
JS::Rooted<JS::Value> jsResult(cx);
if (!ToJSValue(cx, result, &jsResult)) {
JS_ClearPendingException(cx);
jsapi.ClearException();
return NS_ERROR_TYPE_ERR;
}
+1 -1
View File
@@ -307,7 +307,7 @@ MobileMessageCallback::NotifySegmentInfoForTextGot(int32_t aSegments,
JSContext* cx = jsapi.cx();
JS::Rooted<JS::Value> val(cx);
if (!ToJSValue(cx, info, &val)) {
JS_ClearPendingException(cx);
jsapi.ClearException();
return NotifyError(nsIMobileMessageCallback::INTERNAL_ERROR);
}
-8
View File
@@ -738,7 +738,6 @@ nsJSObjWrapper::NP_HasMethod(NPObject *npobj, NPIdentifier id)
}
dom::AutoEntryScript aes(globalObject, "NPAPI HasMethod");
aes.TakeOwnershipOfErrorReporting();
JSContext *cx = aes.cx();
if (!npobj) {
@@ -775,7 +774,6 @@ doInvoke(NPObject *npobj, NPIdentifier method, const NPVariant *args,
// We're about to run script via JS_CallFunctionValue, so we need an
// AutoEntryScript. NPAPI plugins are Gecko-specific and not in any spec.
dom::AutoEntryScript aes(globalObject, "NPAPI doInvoke");
aes.TakeOwnershipOfErrorReporting();
JSContext *cx = aes.cx();
if (!npobj || !result) {
@@ -868,7 +866,6 @@ nsJSObjWrapper::NP_HasProperty(NPObject *npobj, NPIdentifier npid)
}
dom::AutoEntryScript aes(globalObject, "NPAPI HasProperty");
aes.TakeOwnershipOfErrorReporting();
JSContext *cx = aes.cx();
if (!npobj) {
@@ -907,7 +904,6 @@ nsJSObjWrapper::NP_GetProperty(NPObject *npobj, NPIdentifier id,
// We're about to run script via JS_CallFunctionValue, so we need an
// AutoEntryScript. NPAPI plugins are Gecko-specific and not in any spec.
dom::AutoEntryScript aes(globalObject, "NPAPI get");
aes.TakeOwnershipOfErrorReporting();
JSContext *cx = aes.cx();
if (!npobj) {
@@ -942,7 +938,6 @@ nsJSObjWrapper::NP_SetProperty(NPObject *npobj, NPIdentifier npid,
// We're about to run script via JS_CallFunctionValue, so we need an
// AutoEntryScript. NPAPI plugins are Gecko-specific and not in any spec.
dom::AutoEntryScript aes(globalObject, "NPAPI set");
aes.TakeOwnershipOfErrorReporting();
JSContext *cx = aes.cx();
if (!npobj) {
@@ -980,7 +975,6 @@ nsJSObjWrapper::NP_RemoveProperty(NPObject *npobj, NPIdentifier npid)
}
dom::AutoEntryScript aes(globalObject, "NPAPI RemoveProperty");
aes.TakeOwnershipOfErrorReporting();
JSContext *cx = aes.cx();
if (!npobj) {
@@ -1032,7 +1026,6 @@ nsJSObjWrapper::NP_Enumerate(NPObject *npobj, NPIdentifier **idarray,
}
dom::AutoEntryScript aes(globalObject, "NPAPI Enumerate");
aes.TakeOwnershipOfErrorReporting();
JSContext *cx = aes.cx();
*idarray = 0;
@@ -2311,7 +2304,6 @@ nsJSObjWrapper::HasOwnProperty(NPObject *npobj, NPIdentifier npid)
}
dom::AutoEntryScript aes(globalObject, "NPAPI HasOwnProperty");
aes.TakeOwnershipOfErrorReporting();
JSContext *cx = aes.cx();
if (!npobj) {
-1
View File
@@ -1496,7 +1496,6 @@ _evaluate(NPP npp, NPObject* npobj, NPString *script, NPVariant *result)
nsAutoMicroTask mt;
dom::AutoEntryScript aes(win, "NPAPI NPN_evaluate");
aes.TakeOwnershipOfErrorReporting();
JSContext* cx = aes.cx();
JS::Rooted<JSObject*> obj(cx, nsNPObjWrapper::GetNewOrUsed(npp, cx, npobj));
@@ -116,10 +116,20 @@ TranslateVersionStr(const WCHAR* szVersion, verBlock *vbVersion)
szJavaBuild[0] = '.';
}
szNum1 = wcstok(strVer, L".");
szNum2 = wcstok(nullptr, L".");
szNum3 = wcstok(nullptr, L".");
szNum4 = wcstok(nullptr, L".");
#if defined(_MSC_VER) && _MSC_VER < 1900
// MSVC 2013 and earlier provided only a non-standard two-argument variant of
// wcstok that is generally not thread-safe. For our purposes here, it works
// fine, though.
auto wcstok = [](wchar_t* strToken, const wchar_t* strDelimit,
wchar_t** /*ctx*/) {
return ::std::wcstok(strToken, strDelimit);
};
#endif
wchar_t* ctx = nullptr;
szNum1 = wcstok(strVer, L".", &ctx);
szNum2 = wcstok(nullptr, L".", &ctx);
szNum3 = wcstok(nullptr, L".", &ctx);
szNum4 = wcstok(nullptr, L".", &ctx);
vbVersion->wMajor = szNum1 ? (WORD) _wtoi(szNum1) : 0;
vbVersion->wMinor = szNum2 ? (WORD) _wtoi(szNum2) : 0;
+3 -3
View File
@@ -73,7 +73,7 @@
#include "nsIDOMWindow.h"
#include "nsNetCID.h"
#include "prprf.h"
#include "mozilla/Snprintf.h"
#include "nsThreadUtils.h"
#include "nsIInputStreamTee.h"
#include "nsQueryObject.h"
@@ -3691,8 +3691,8 @@ nsPluginHost::ParsePostBufferToFixHeaders(const char *inPostData, uint32_t inPos
newBufferLen = dataLen + l;
if (!(*outPostData = p = (char*)moz_xmalloc(newBufferLen)))
return NS_ERROR_OUT_OF_MEMORY;
headersLen = PR_snprintf(p, l,"%s: %ld%s", ContentLenHeader, dataLen, CRLFCRLF);
if (headersLen == l) { // if PR_snprintf has ate all extra space consider this as an error
headersLen = snprintf(p, l,"%s: %u%s", ContentLenHeader, dataLen, CRLFCRLF);
if (headersLen == l) { // if snprintf has ate all extra space consider this as an error
free(p);
*outPostData = 0;
return NS_ERROR_FAILURE;
-4
View File
@@ -10,8 +10,6 @@
#include "mozilla/Logging.h"
#ifdef PR_LOGGING
#ifndef PLUGIN_LOGGING // allow external override
#define PLUGIN_LOGGING 1 // master compile-time switch for pluging logging
#endif
@@ -57,8 +55,6 @@ public:
#endif // PLUGIN_LOGGING
#endif // PR_LOGGING
// Quick-use macros
#ifdef PLUGIN_LOGGING
#define NPN_PLUGIN_LOG(a, b) \
+133 -132
View File
@@ -15,7 +15,7 @@
#include "NetworkUtils.h"
#include "prprf.h"
#include "mozilla/Snprintf.h"
#include "SystemProperty.h"
#include <android/log.h>
@@ -399,11 +399,11 @@ static void convertUTF8toUTF16(nsTArray<nsCString>& narrow,
static void getIFProperties(const char* ifname, IFProperties& prop)
{
char key[Property::KEY_MAX_LENGTH];
PR_snprintf(key, Property::KEY_MAX_LENGTH - 1, "net.%s.gw", ifname);
snprintf(key, Property::KEY_MAX_LENGTH - 1, "net.%s.gw", ifname);
Property::Get(key, prop.gateway, "");
PR_snprintf(key, Property::KEY_MAX_LENGTH - 1, "net.%s.dns1", ifname);
snprintf(key, Property::KEY_MAX_LENGTH - 1, "net.%s.dns1", ifname);
Property::Get(key, prop.dns1, "");
PR_snprintf(key, Property::KEY_MAX_LENGTH - 1, "net.%s.dns2", ifname);
snprintf(key, Property::KEY_MAX_LENGTH - 1, "net.%s.dns2", ifname);
Property::Get(key, prop.dns2, "");
}
@@ -524,7 +524,7 @@ void NetworkUtils::nextNetdCommand()
gCurrentCommand.chain = GET_CURRENT_CHAIN;
gCurrentCommand.callback = GET_CURRENT_CALLBACK;
PR_snprintf(gCurrentCommand.command, MAX_COMMAND_SIZE - 1, "%s", GET_CURRENT_COMMAND);
snprintf(gCurrentCommand.command, MAX_COMMAND_SIZE - 1, "%s", GET_CURRENT_COMMAND);
NU_DBG("Sending \'%s\' command to netd.", gCurrentCommand.command);
SendNetdCommand(GET_CURRENT_NETD_COMMAND);
@@ -549,9 +549,9 @@ void NetworkUtils::doCommand(const char* aCommand, CommandChain* aChain, Command
// Android JB version adds sequence number to netd command.
if (SDK_VERSION >= 16) {
PR_snprintf((char*)netdCommand->mData, MAX_COMMAND_SIZE - 1, "0 %s", aCommand);
snprintf((char*)netdCommand->mData, MAX_COMMAND_SIZE - 1, "0 %s", aCommand);
} else {
PR_snprintf((char*)netdCommand->mData, MAX_COMMAND_SIZE - 1, "%s", aCommand);
snprintf((char*)netdCommand->mData, MAX_COMMAND_SIZE - 1, "%s", aCommand);
}
netdCommand->mSize = strlen((char*)netdCommand->mData) + 1;
@@ -571,7 +571,7 @@ void NetworkUtils::wifiFirmwareReload(CommandChain* aChain,
NetworkResultOptions& aResult)
{
char command[MAX_COMMAND_SIZE];
PR_snprintf(command, MAX_COMMAND_SIZE - 1, "softap fwreload %s %s", GET_CHAR(mIfname), GET_CHAR(mMode));
snprintf(command, MAX_COMMAND_SIZE - 1, "softap fwreload %s %s", GET_CHAR(mIfname), GET_CHAR(mMode));
doCommand(command, aChain, aCallback);
}
@@ -589,7 +589,7 @@ void NetworkUtils::startAccessPointDriver(CommandChain* aChain,
}
char command[MAX_COMMAND_SIZE];
PR_snprintf(command, MAX_COMMAND_SIZE - 1, "softap start %s", GET_CHAR(mIfname));
snprintf(command, MAX_COMMAND_SIZE - 1, "softap start %s", GET_CHAR(mIfname));
doCommand(command, aChain, aCallback);
}
@@ -607,7 +607,7 @@ void NetworkUtils::stopAccessPointDriver(CommandChain* aChain,
}
char command[MAX_COMMAND_SIZE];
PR_snprintf(command, MAX_COMMAND_SIZE - 1, "softap stop %s", GET_CHAR(mIfname));
snprintf(command, MAX_COMMAND_SIZE - 1, "softap stop %s", GET_CHAR(mIfname));
doCommand(command, aChain, aCallback);
}
@@ -651,24 +651,24 @@ void NetworkUtils::setAccessPoint(CommandChain* aChain,
escapeQuote(key);
if (SDK_VERSION >= 19) {
PR_snprintf(command, MAX_COMMAND_SIZE - 1, "softap set %s \"%s\" broadcast 6 %s \"%s\"",
GET_CHAR(mIfname),
ssid.get(),
GET_CHAR(mSecurity),
key.get());
snprintf(command, MAX_COMMAND_SIZE - 1, "softap set %s \"%s\" broadcast 6 %s \"%s\"",
GET_CHAR(mIfname),
ssid.get(),
GET_CHAR(mSecurity),
key.get());
} else if (SDK_VERSION >= 16) {
PR_snprintf(command, MAX_COMMAND_SIZE - 1, "softap set %s \"%s\" %s \"%s\"",
GET_CHAR(mIfname),
ssid.get(),
GET_CHAR(mSecurity),
key.get());
snprintf(command, MAX_COMMAND_SIZE - 1, "softap set %s \"%s\" %s \"%s\"",
GET_CHAR(mIfname),
ssid.get(),
GET_CHAR(mSecurity),
key.get());
} else {
PR_snprintf(command, MAX_COMMAND_SIZE - 1, "softap set %s %s \"%s\" %s \"%s\" 6 0 8",
GET_CHAR(mIfname),
GET_CHAR(mWifictrlinterfacename),
ssid.get(),
GET_CHAR(mSecurity),
key.get());
snprintf(command, MAX_COMMAND_SIZE - 1, "softap set %s %s \"%s\" %s \"%s\" 6 0 8",
GET_CHAR(mIfname),
GET_CHAR(mWifictrlinterfacename),
ssid.get(),
GET_CHAR(mSecurity),
key.get());
}
doCommand(command, aChain, aCallback);
@@ -679,7 +679,7 @@ void NetworkUtils::cleanUpStream(CommandChain* aChain,
NetworkResultOptions& aResult)
{
char command[MAX_COMMAND_SIZE];
PR_snprintf(command, MAX_COMMAND_SIZE - 1, "nat disable %s %s 0", GET_CHAR(mPreInternalIfname), GET_CHAR(mPreExternalIfname));
snprintf(command, MAX_COMMAND_SIZE - 1, "nat disable %s %s 0", GET_CHAR(mPreInternalIfname), GET_CHAR(mPreExternalIfname));
doCommand(command, aChain, aCallback);
}
@@ -689,7 +689,7 @@ void NetworkUtils::createUpStream(CommandChain* aChain,
NetworkResultOptions& aResult)
{
char command[MAX_COMMAND_SIZE];
PR_snprintf(command, MAX_COMMAND_SIZE - 1, "nat enable %s %s 0", GET_CHAR(mCurInternalIfname), GET_CHAR(mCurExternalIfname));
snprintf(command, MAX_COMMAND_SIZE - 1, "nat enable %s %s 0", GET_CHAR(mCurInternalIfname), GET_CHAR(mCurExternalIfname));
doCommand(command, aChain, aCallback);
}
@@ -740,7 +740,7 @@ void NetworkUtils::setQuota(CommandChain* aChain,
NetworkResultOptions& aResult)
{
char command[MAX_COMMAND_SIZE];
PR_snprintf(command, MAX_COMMAND_SIZE - 1, "bandwidth setiquota %s %lld", GET_CHAR(mIfname), LLONG_MAX);
snprintf(command, MAX_COMMAND_SIZE - 1, "bandwidth setiquota %s % " PRId64, GET_CHAR(mIfname), INT64_MAX);
doCommand(command, aChain, aCallback);
}
@@ -750,7 +750,7 @@ void NetworkUtils::removeQuota(CommandChain* aChain,
NetworkResultOptions& aResult)
{
char command[MAX_COMMAND_SIZE];
PR_snprintf(command, MAX_COMMAND_SIZE - 1, "bandwidth removeiquota %s", GET_CHAR(mIfname));
snprintf(command, MAX_COMMAND_SIZE - 1, "bandwidth removeiquota %s", GET_CHAR(mIfname));
doCommand(command, aChain, aCallback);
}
@@ -760,7 +760,8 @@ void NetworkUtils::setAlarm(CommandChain* aChain,
NetworkResultOptions& aResult)
{
char command[MAX_COMMAND_SIZE];
PR_snprintf(command, MAX_COMMAND_SIZE - 1, "bandwidth setinterfacealert %s %lld", GET_CHAR(mIfname), GET_FIELD(mThreshold));
snprintf(command, MAX_COMMAND_SIZE - 1, "bandwidth setinterfacealert %s %lld",
GET_CHAR(mIfname), GET_FIELD(mThreshold));
doCommand(command, aChain, aCallback);
}
@@ -770,7 +771,7 @@ void NetworkUtils::removeAlarm(CommandChain* aChain,
NetworkResultOptions& aResult)
{
char command[MAX_COMMAND_SIZE];
PR_snprintf(command, MAX_COMMAND_SIZE - 1, "bandwidth removeinterfacealert %s", GET_CHAR(mIfname));
snprintf(command, MAX_COMMAND_SIZE - 1, "bandwidth removeinterfacealert %s", GET_CHAR(mIfname));
doCommand(command, aChain, aCallback);
}
@@ -781,7 +782,7 @@ void NetworkUtils::setGlobalAlarm(CommandChain* aChain,
{
char command[MAX_COMMAND_SIZE];
PR_snprintf(command, MAX_COMMAND_SIZE - 1, "bandwidth setglobalalert %ld", GET_FIELD(mThreshold));
snprintf(command, MAX_COMMAND_SIZE - 1, "bandwidth setglobalalert %lld", GET_FIELD(mThreshold));
doCommand(command, aChain, aCallback);
}
@@ -791,7 +792,7 @@ void NetworkUtils::removeGlobalAlarm(CommandChain* aChain,
{
char command[MAX_COMMAND_SIZE];
PR_snprintf(command, MAX_COMMAND_SIZE - 1, "bandwidth removeglobalalert");
snprintf(command, MAX_COMMAND_SIZE - 1, "bandwidth removeglobalalert");
doCommand(command, aChain, aCallback);
}
@@ -800,7 +801,7 @@ void NetworkUtils::tetherInterface(CommandChain* aChain,
NetworkResultOptions& aResult)
{
char command[MAX_COMMAND_SIZE];
PR_snprintf(command, MAX_COMMAND_SIZE - 1, "tether interface add %s", GET_CHAR(mIfname));
snprintf(command, MAX_COMMAND_SIZE - 1, "tether interface add %s", GET_CHAR(mIfname));
doCommand(command, aChain, aCallback);
}
@@ -818,8 +819,8 @@ void NetworkUtils::addInterfaceToLocalNetwork(CommandChain* aChain,
}
char command[MAX_COMMAND_SIZE];
PR_snprintf(command, MAX_COMMAND_SIZE - 1, "network interface add local %s",
GET_CHAR(mInternalIfname));
snprintf(command, MAX_COMMAND_SIZE - 1, "network interface add local %s",
GET_CHAR(mInternalIfname));
doCommand(command, aChain, aCallback);
}
@@ -841,8 +842,8 @@ void NetworkUtils::addRouteToLocalNetwork(CommandChain* aChain,
uint32_t ip = inet_addr(GET_CHAR(mIp));
char* networkAddr = getNetworkAddr(ip, prefix);
PR_snprintf(command, MAX_COMMAND_SIZE - 1, "network route add local %s %s/%s",
GET_CHAR(mInternalIfname), networkAddr, GET_CHAR(mPrefix));
snprintf(command, MAX_COMMAND_SIZE - 1, "network route add local %s %s/%s",
GET_CHAR(mInternalIfname), networkAddr, GET_CHAR(mPrefix));
doCommand(command, aChain, aCallback);
}
@@ -853,9 +854,9 @@ void NetworkUtils::preTetherInterfaceList(CommandChain* aChain,
{
char command[MAX_COMMAND_SIZE];
if (SDK_VERSION >= 16) {
PR_snprintf(command, MAX_COMMAND_SIZE - 1, "tether interface list");
snprintf(command, MAX_COMMAND_SIZE - 1, "tether interface list");
} else {
PR_snprintf(command, MAX_COMMAND_SIZE - 1, "tether interface list 0");
snprintf(command, MAX_COMMAND_SIZE - 1, "tether interface list 0");
}
doCommand(command, aChain, aCallback);
@@ -867,7 +868,7 @@ void NetworkUtils::postTetherInterfaceList(CommandChain* aChain,
{
// Send the dummy command to continue the function chain.
char command[MAX_COMMAND_SIZE];
PR_snprintf(command, MAX_COMMAND_SIZE - 1, "%s", DUMMY_COMMAND);
snprintf(command, MAX_COMMAND_SIZE - 1, "%s", DUMMY_COMMAND);
char buf[BUF_SIZE];
NS_ConvertUTF16toUTF8 reason(aResult.mResultReason);
@@ -927,8 +928,8 @@ void NetworkUtils::addUpstreamInterface(CommandChain* aChain,
}
char command[MAX_COMMAND_SIZE];
PR_snprintf(command, MAX_COMMAND_SIZE - 1, "tether interface add_upstream %s",
interface.get());
snprintf(command, MAX_COMMAND_SIZE - 1, "tether interface add_upstream %s",
interface.get());
doCommand(command, aChain, aCallback);
}
@@ -947,8 +948,8 @@ void NetworkUtils::removeUpstreamInterface(CommandChain* aChain,
}
char command[MAX_COMMAND_SIZE];
PR_snprintf(command, MAX_COMMAND_SIZE - 1, "tether interface remove_upstream %s",
interface.get());
snprintf(command, MAX_COMMAND_SIZE - 1, "tether interface remove_upstream %s",
interface.get());
doCommand(command, aChain, aCallback);
}
@@ -959,14 +960,14 @@ void NetworkUtils::setIpForwardingEnabled(CommandChain* aChain,
char command[MAX_COMMAND_SIZE];
if (GET_FIELD(mEnable)) {
PR_snprintf(command, MAX_COMMAND_SIZE - 1, "ipfwd enable");
snprintf(command, MAX_COMMAND_SIZE - 1, "ipfwd enable");
} else {
// Don't disable ip forwarding because others interface still need it.
// Send the dummy command to continue the function chain.
if (GET_FIELD(mInterfaceList).Length() > 1) {
PR_snprintf(command, MAX_COMMAND_SIZE - 1, "%s", DUMMY_COMMAND);
snprintf(command, MAX_COMMAND_SIZE - 1, "%s", DUMMY_COMMAND);
} else {
PR_snprintf(command, MAX_COMMAND_SIZE - 1, "ipfwd disable");
snprintf(command, MAX_COMMAND_SIZE - 1, "ipfwd disable");
}
}
@@ -990,9 +991,9 @@ void NetworkUtils::stopTethering(CommandChain* aChain,
// Don't stop tethering because others interface still need it.
// Send the dummy to continue the function chain.
if (GET_FIELD(mInterfaceList).Length() > 1) {
PR_snprintf(command, MAX_COMMAND_SIZE - 1, "%s", DUMMY_COMMAND);
snprintf(command, MAX_COMMAND_SIZE - 1, "%s", DUMMY_COMMAND);
} else {
PR_snprintf(command, MAX_COMMAND_SIZE - 1, "tether stop");
snprintf(command, MAX_COMMAND_SIZE - 1, "tether stop");
}
doCommand(command, aChain, aCallback);
@@ -1007,18 +1008,18 @@ void NetworkUtils::startTethering(CommandChain* aChain,
// We don't need to start tethering again.
// Send the dummy command to continue the function chain.
if (aResult.mResultReason.Find("started") != kNotFound) {
PR_snprintf(command, MAX_COMMAND_SIZE - 1, "%s", DUMMY_COMMAND);
snprintf(command, MAX_COMMAND_SIZE - 1, "%s", DUMMY_COMMAND);
} else {
// If usbStartIp/usbEndIp is not valid, don't append them since
// the trailing white spaces will be parsed to extra empty args
// See: http://androidxref.com/4.3_r2.1/xref/system/core/libsysutils/src/FrameworkListener.cpp#78
if (!GET_FIELD(mUsbStartIp).IsEmpty() && !GET_FIELD(mUsbEndIp).IsEmpty()) {
PR_snprintf(command, MAX_COMMAND_SIZE - 1, "tether start %s %s %s %s",
GET_CHAR(mWifiStartIp), GET_CHAR(mWifiEndIp),
GET_CHAR(mUsbStartIp), GET_CHAR(mUsbEndIp));
snprintf(command, MAX_COMMAND_SIZE - 1, "tether start %s %s %s %s",
GET_CHAR(mWifiStartIp), GET_CHAR(mWifiEndIp),
GET_CHAR(mUsbStartIp), GET_CHAR(mUsbEndIp));
} else {
PR_snprintf(command, MAX_COMMAND_SIZE - 1, "tether start %s %s",
GET_CHAR(mWifiStartIp), GET_CHAR(mWifiEndIp));
snprintf(command, MAX_COMMAND_SIZE - 1, "tether start %s %s",
GET_CHAR(mWifiStartIp), GET_CHAR(mWifiEndIp));
}
}
@@ -1030,7 +1031,7 @@ void NetworkUtils::untetherInterface(CommandChain* aChain,
NetworkResultOptions& aResult)
{
char command[MAX_COMMAND_SIZE];
PR_snprintf(command, MAX_COMMAND_SIZE - 1, "tether interface remove %s", GET_CHAR(mIfname));
snprintf(command, MAX_COMMAND_SIZE - 1, "tether interface remove %s", GET_CHAR(mIfname));
doCommand(command, aChain, aCallback);
}
@@ -1048,8 +1049,8 @@ void NetworkUtils::removeInterfaceFromLocalNetwork(CommandChain* aChain,
}
char command[MAX_COMMAND_SIZE];
PR_snprintf(command, MAX_COMMAND_SIZE - 1, "network interface remove local %s",
GET_CHAR(mIfname));
snprintf(command, MAX_COMMAND_SIZE - 1, "network interface remove local %s",
GET_CHAR(mIfname));
doCommand(command, aChain, aCallback);
}
@@ -1061,11 +1062,11 @@ void NetworkUtils::setDnsForwarders(CommandChain* aChain,
char command[MAX_COMMAND_SIZE];
if (SDK_VERSION >= 20) {
PR_snprintf(command, MAX_COMMAND_SIZE - 1, "tether dns set %d %s %s",
GET_FIELD(mNetId), GET_CHAR(mDns1), GET_CHAR(mDns2));
snprintf(command, MAX_COMMAND_SIZE - 1, "tether dns set %d %s %s",
GET_FIELD(mNetId), GET_CHAR(mDns1), GET_CHAR(mDns2));
} else {
PR_snprintf(command, MAX_COMMAND_SIZE - 1, "tether dns set %s %s",
GET_CHAR(mDns1), GET_CHAR(mDns2));
snprintf(command, MAX_COMMAND_SIZE - 1, "tether dns set %s %s",
GET_CHAR(mDns1), GET_CHAR(mDns2));
}
doCommand(command, aChain, aCallback);
@@ -1083,12 +1084,12 @@ void NetworkUtils::enableNat(CommandChain* aChain,
char* networkAddr = getNetworkAddr(ip, prefix);
// address/prefix will only take effect when secondary routing table exists.
PR_snprintf(command, MAX_COMMAND_SIZE - 1, "nat enable %s %s 1 %s/%s",
GET_CHAR(mInternalIfname), GET_CHAR(mExternalIfname), networkAddr,
GET_CHAR(mPrefix));
snprintf(command, MAX_COMMAND_SIZE - 1, "nat enable %s %s 1 %s/%s",
GET_CHAR(mInternalIfname), GET_CHAR(mExternalIfname), networkAddr,
GET_CHAR(mPrefix));
} else {
PR_snprintf(command, MAX_COMMAND_SIZE - 1, "nat enable %s %s 0",
GET_CHAR(mInternalIfname), GET_CHAR(mExternalIfname));
snprintf(command, MAX_COMMAND_SIZE - 1, "nat enable %s %s 0",
GET_CHAR(mInternalIfname), GET_CHAR(mExternalIfname));
}
doCommand(command, aChain, aCallback);
@@ -1105,12 +1106,12 @@ void NetworkUtils::disableNat(CommandChain* aChain,
uint32_t ip = inet_addr(GET_CHAR(mIp));
char* networkAddr = getNetworkAddr(ip, prefix);
PR_snprintf(command, MAX_COMMAND_SIZE - 1, "nat disable %s %s 1 %s/%s",
GET_CHAR(mInternalIfname), GET_CHAR(mExternalIfname), networkAddr,
GET_CHAR(mPrefix));
snprintf(command, MAX_COMMAND_SIZE - 1, "nat disable %s %s 1 %s/%s",
GET_CHAR(mInternalIfname), GET_CHAR(mExternalIfname), networkAddr,
GET_CHAR(mPrefix));
} else {
PR_snprintf(command, MAX_COMMAND_SIZE - 1, "nat disable %s %s 0",
GET_CHAR(mInternalIfname), GET_CHAR(mExternalIfname));
snprintf(command, MAX_COMMAND_SIZE - 1, "nat disable %s %s 0",
GET_CHAR(mInternalIfname), GET_CHAR(mExternalIfname));
}
doCommand(command, aChain, aCallback);
@@ -1121,7 +1122,7 @@ void NetworkUtils::setDefaultInterface(CommandChain* aChain,
NetworkResultOptions& aResult)
{
char command[MAX_COMMAND_SIZE];
PR_snprintf(command, MAX_COMMAND_SIZE - 1, "resolver setdefaultif %s", GET_CHAR(mIfname));
snprintf(command, MAX_COMMAND_SIZE - 1, "resolver setdefaultif %s", GET_CHAR(mIfname));
doCommand(command, aChain, aCallback);
}
@@ -1140,9 +1141,9 @@ void NetworkUtils::removeDefaultRoute(CommandChain* aChain,
NS_ConvertUTF16toUTF8 autoGateway(gateways[GET_FIELD(mLoopIndex)]);
int type = getIpType(autoGateway.get());
PR_snprintf(command, MAX_COMMAND_SIZE - 1, "network route remove %d %s %s/0 %s",
GET_FIELD(mNetId), GET_CHAR(mIfname),
type == AF_INET6 ? "::" : "0.0.0.0", autoGateway.get());
snprintf(command, MAX_COMMAND_SIZE - 1, "network route remove %d %s %s/0 %s",
GET_FIELD(mNetId), GET_CHAR(mIfname),
type == AF_INET6 ? "::" : "0.0.0.0", autoGateway.get());
struct MyCallback {
static void callback(CommandCallback::CallbackType aOriginalCallback,
@@ -1173,11 +1174,11 @@ void NetworkUtils::setInterfaceDns(CommandChain* aChain,
int written;
if (SDK_VERSION >= 20) {
written = PR_snprintf(command, sizeof command, "resolver setnetdns %d %s",
GET_FIELD(mNetId), GET_CHAR(mDomain));
written = snprintf_literal(command, "resolver setnetdns %d %s",
GET_FIELD(mNetId), GET_CHAR(mDomain));
} else {
written = PR_snprintf(command, sizeof command, "resolver setifdns %s %s",
GET_CHAR(mIfname), GET_CHAR(mDomain));
written = snprintf_literal(command, "resolver setifdns %s %s",
GET_CHAR(mIfname), GET_CHAR(mDomain));
}
nsTArray<nsString>& dnses = GET_FIELD(mDnses);
@@ -1186,7 +1187,7 @@ void NetworkUtils::setInterfaceDns(CommandChain* aChain,
for (uint32_t i = 0; i < length; i++) {
NS_ConvertUTF16toUTF8 autoDns(dnses[i]);
int ret = PR_snprintf(command + written, sizeof(command) - written, " %s", autoDns.get());
int ret = snprintf(command + written, sizeof(command) - written, " %s", autoDns.get());
if (ret <= 1) {
command[written] = '\0';
continue;
@@ -1249,7 +1250,7 @@ void NetworkUtils::clearAddrForInterface(CommandChain* aChain,
NetworkResultOptions& aResult)
{
char command[MAX_COMMAND_SIZE];
PR_snprintf(command, MAX_COMMAND_SIZE - 1, "interface clearaddrs %s", GET_CHAR(mIfname));
snprintf(command, MAX_COMMAND_SIZE - 1, "interface clearaddrs %s", GET_CHAR(mIfname));
doCommand(command, aChain, aCallback);
}
@@ -1259,7 +1260,7 @@ void NetworkUtils::createNetwork(CommandChain* aChain,
NetworkResultOptions& aResult)
{
char command[MAX_COMMAND_SIZE];
PR_snprintf(command, MAX_COMMAND_SIZE - 1, "network create %d", GET_FIELD(mNetId));
snprintf(command, MAX_COMMAND_SIZE - 1, "network create %d", GET_FIELD(mNetId));
doCommand(command, aChain, aCallback);
}
@@ -1269,7 +1270,7 @@ void NetworkUtils::destroyNetwork(CommandChain* aChain,
NetworkResultOptions& aResult)
{
char command[MAX_COMMAND_SIZE];
PR_snprintf(command, MAX_COMMAND_SIZE - 1, "network destroy %d", GET_FIELD(mNetId));
snprintf(command, MAX_COMMAND_SIZE - 1, "network destroy %d", GET_FIELD(mNetId));
doCommand(command, aChain, aCallback);
}
@@ -1279,8 +1280,8 @@ void NetworkUtils::addInterfaceToNetwork(CommandChain* aChain,
NetworkResultOptions& aResult)
{
char command[MAX_COMMAND_SIZE];
PR_snprintf(command, MAX_COMMAND_SIZE - 1, "network interface add %d %s",
GET_FIELD(mNetId), GET_CHAR(mIfname));
snprintf(command, MAX_COMMAND_SIZE - 1, "network interface add %d %s",
GET_FIELD(mNetId), GET_CHAR(mIfname));
doCommand(command, aChain, aCallback);
}
@@ -1339,10 +1340,10 @@ void NetworkUtils::modifyRouteOnInterface(CommandChain* aChain,
const char* action = aDoAdd ? "add" : "remove";
PR_snprintf(command, MAX_COMMAND_SIZE - 1, "network route %s%s %d %s %s/%d%s",
legacyOrEmpty, action,
GET_FIELD(mNetId), GET_CHAR(mIfname), ipOrSubnetIp.get(),
GET_FIELD(mPrefixLength), gatewayOrEmpty.get());
snprintf(command, MAX_COMMAND_SIZE - 1, "network route %s%s %d %s %s/%d%s",
legacyOrEmpty, action,
GET_FIELD(mNetId), GET_CHAR(mIfname), ipOrSubnetIp.get(),
GET_FIELD(mPrefixLength), gatewayOrEmpty.get());
doCommand(command, aChain, aCallback);
}
@@ -1361,9 +1362,9 @@ void NetworkUtils::addDefaultRouteToNetwork(CommandChain* aChain,
NS_ConvertUTF16toUTF8 autoGateway(gateways[GET_FIELD(mLoopIndex)]);
int type = getIpType(autoGateway.get());
PR_snprintf(command, MAX_COMMAND_SIZE - 1, "network route add %d %s %s/0 %s",
GET_FIELD(mNetId), GET_CHAR(mIfname),
type == AF_INET6 ? "::" : "0.0.0.0", autoGateway.get());
snprintf(command, MAX_COMMAND_SIZE - 1, "network route add %d %s %s/0 %s",
GET_FIELD(mNetId), GET_CHAR(mIfname),
type == AF_INET6 ? "::" : "0.0.0.0", autoGateway.get());
struct MyCallback {
static void callback(CommandCallback::CallbackType aOriginalCallback,
@@ -1391,7 +1392,7 @@ void NetworkUtils::setDefaultNetwork(CommandChain* aChain,
NetworkResultOptions& aResult)
{
char command[MAX_COMMAND_SIZE];
PR_snprintf(command, MAX_COMMAND_SIZE - 1, "network default set %d", GET_FIELD(mNetId));
snprintf(command, MAX_COMMAND_SIZE - 1, "network default set %d", GET_FIELD(mNetId));
doCommand(command, aChain, aCallback);
}
@@ -1403,20 +1404,20 @@ void NetworkUtils::addRouteToSecondaryTable(CommandChain* aChain,
char command[MAX_COMMAND_SIZE];
if (SDK_VERSION >= 20) {
PR_snprintf(command, MAX_COMMAND_SIZE - 1,
"network route add %d %s %s/%s %s",
GET_FIELD(mNetId),
GET_CHAR(mIfname),
GET_CHAR(mIp),
GET_CHAR(mPrefix),
GET_CHAR(mGateway));
snprintf(command, MAX_COMMAND_SIZE - 1,
"network route add %d %s %s/%s %s",
GET_FIELD(mNetId),
GET_CHAR(mIfname),
GET_CHAR(mIp),
GET_CHAR(mPrefix),
GET_CHAR(mGateway));
} else {
PR_snprintf(command, MAX_COMMAND_SIZE - 1,
"interface route add %s secondary %s %s %s",
GET_CHAR(mIfname),
GET_CHAR(mIp),
GET_CHAR(mPrefix),
GET_CHAR(mGateway));
snprintf(command, MAX_COMMAND_SIZE - 1,
"interface route add %s secondary %s %s %s",
GET_CHAR(mIfname),
GET_CHAR(mIp),
GET_CHAR(mPrefix),
GET_CHAR(mGateway));
}
doCommand(command, aChain, aCallback);
@@ -1428,20 +1429,20 @@ void NetworkUtils::removeRouteFromSecondaryTable(CommandChain* aChain,
char command[MAX_COMMAND_SIZE];
if (SDK_VERSION >= 20) {
PR_snprintf(command, MAX_COMMAND_SIZE - 1,
"network route remove %d %s %s/%s %s",
GET_FIELD(mNetId),
GET_CHAR(mIfname),
GET_CHAR(mIp),
GET_CHAR(mPrefix),
GET_CHAR(mGateway));
snprintf(command, MAX_COMMAND_SIZE - 1,
"network route remove %d %s %s/%s %s",
GET_FIELD(mNetId),
GET_CHAR(mIfname),
GET_CHAR(mIp),
GET_CHAR(mPrefix),
GET_CHAR(mGateway));
} else {
PR_snprintf(command, MAX_COMMAND_SIZE - 1,
"interface route remove %s secondary %s %s %s",
GET_CHAR(mIfname),
GET_CHAR(mIp),
GET_CHAR(mPrefix),
GET_CHAR(mGateway));
snprintf(command, MAX_COMMAND_SIZE - 1,
"interface route remove %s secondary %s %s %s",
GET_CHAR(mIfname),
GET_CHAR(mIp),
GET_CHAR(mPrefix),
GET_CHAR(mGateway));
}
doCommand(command, aChain, aCallback);
@@ -1453,8 +1454,8 @@ void NetworkUtils::setIpv6Enabled(CommandChain* aChain,
bool aEnabled)
{
char command[MAX_COMMAND_SIZE];
PR_snprintf(command, MAX_COMMAND_SIZE - 1, "interface ipv6 %s %s",
GET_CHAR(mIfname), aEnabled ? "enable" : "disable");
snprintf(command, MAX_COMMAND_SIZE - 1, "interface ipv6 %s %s",
GET_CHAR(mIfname), aEnabled ? "enable" : "disable");
struct MyCallback {
static void callback(CommandCallback::CallbackType aOriginalCallback,
@@ -1489,8 +1490,8 @@ void NetworkUtils::setMtu(CommandChain* aChain,
NetworkResultOptions& aResult)
{
char command[MAX_COMMAND_SIZE];
PR_snprintf(command, MAX_COMMAND_SIZE - 1, "interface setmtu %s %d",
GET_CHAR(mIfname), GET_FIELD(mMtu));
snprintf(command, MAX_COMMAND_SIZE - 1, "interface setmtu %s %ld",
GET_CHAR(mIfname), GET_FIELD(mMtu));
doCommand(command, aChain, aCallback);
}
@@ -1876,9 +1877,9 @@ void NetworkUtils::onNetdMessage(NetdCommand* aCommand)
if (code == NETD_COMMAND_INTERFACE_CHANGE) {
if (gWifiTetheringParms) {
char linkdownReason[MAX_COMMAND_SIZE];
PR_snprintf(linkdownReason, MAX_COMMAND_SIZE - 1,
"Iface linkstate %s down",
NS_ConvertUTF16toUTF8(gWifiTetheringParms->mIfname).get());
snprintf(linkdownReason, MAX_COMMAND_SIZE - 1,
"Iface linkstate %s down",
NS_ConvertUTF16toUTF8(gWifiTetheringParms->mIfname).get());
if (!strcmp(reason, linkdownReason)) {
NU_DBG("Wifi link down, restarting tethering.");
@@ -1955,7 +1956,7 @@ CommandResult NetworkUtils::setDNS(NetworkParams& aOptions)
NS_ConvertUTF16toUTF8 autoDns(aOptions.mDnses[i]);
char dns_prop_key[Property::VALUE_MAX_LENGTH];
PR_snprintf(dns_prop_key, sizeof dns_prop_key, "net.dns%d", i+1);
snprintf_literal(dns_prop_key, "net.dns%d", i+1);
Property::Set(dns_prop_key, autoDns.get());
}
} else {
@@ -1972,7 +1973,7 @@ CommandResult NetworkUtils::setDNS(NetworkParams& aOptions)
Property::Get("net.dnschange", dnschange, "0");
char num[Property::VALUE_MAX_LENGTH];
PR_snprintf(num, Property::VALUE_MAX_LENGTH - 1, "%d", atoi(dnschange) + 1);
snprintf(num, Property::VALUE_MAX_LENGTH - 1, "%d", atoi(dnschange) + 1);
Property::Set("net.dnschange", num);
// DNS needs to be set through netd since JellyBean (4.3).
@@ -2164,7 +2165,7 @@ CommandResult NetworkUtils::setDefaultRouteLegacy(NetworkParams& aOptions)
char key[Property::KEY_MAX_LENGTH];
char gateway[Property::KEY_MAX_LENGTH];
PR_snprintf(key, sizeof key - 1, "net.%s.gw", autoIfname.get());
snprintf(key, sizeof key - 1, "net.%s.gw", autoIfname.get());
Property::Get(key, gateway, "");
int type = getIpType(gateway);
+3 -2
View File
@@ -9,6 +9,7 @@
#include <errno.h>
#include <cutils/properties.h>
#include "prinit.h"
#include "mozilla/Snprintf.h"
#include "js/CharacterEncoding.h"
using namespace mozilla::dom;
@@ -368,10 +369,10 @@ public:
char command[COMMAND_SIZE];
if (!strcmp(iface, "p2p0")) {
// Commands for p2p0 interface don't need prefix
PR_snprintf(command, COMMAND_SIZE, "%s", cmd);
snprintf_literal(command, "%s", cmd);
}
else {
PR_snprintf(command, COMMAND_SIZE, "IFNAME=%s %s", iface, cmd);
snprintf_literal(command, "IFNAME=%s %s", iface, cmd);
}
USE_DLFUNC(wifi_command)
return wifi_command(command, buf, len);
+1 -2
View File
@@ -6025,8 +6025,7 @@ WorkerPrivate::RunExpiredTimeouts(JSContext* aCx)
{ // scope for the AutoEntryScript, so it comes off the stack before we do
// Promise::PerformMicroTaskCheckpoint.
AutoEntryScript entryScript(global, reason, false, aCx);
entryScript.TakeOwnershipOfErrorReporting();
AutoEntryScript aes(global, reason, false, aCx);
if (!info->mTimeoutCallable.isUndefined()) {
JS::Rooted<JS::Value> rval(aCx);
JS::HandleValueArray args =
+1 -1
View File
@@ -327,8 +327,8 @@ WorkerRunnable::Run()
maybeJSAPI->Init();
jsapi = maybeJSAPI.ptr();
cx = jsapi->cx();
jsapi->TakeOwnershipOfErrorReporting();
}
jsapi->TakeOwnershipOfErrorReporting();
// Note that we can't assert anything about mWorkerPrivate->GetWrapper()
// existing, since it may in fact have been GCed (and we may be one of the
+3 -4
View File
@@ -405,9 +405,8 @@ nsXBLProtoImplField::InstallField(JS::Handle<JSObject*> aBoundNode,
// We are going to run script via EvaluateString, so we need a script entry
// point, but as this is XBL related it does not appear in the HTML spec.
AutoEntryScript entryScript(globalObject, "XBL <field> initialization", true);
entryScript.TakeOwnershipOfErrorReporting();
JSContext* cx = entryScript.cx();
AutoEntryScript aes(globalObject, "XBL <field> initialization", true);
JSContext* cx = aes.cx();
NS_ASSERTION(!::JS_IsExceptionPending(cx),
"Shouldn't get here when an exception is pending!");
@@ -445,7 +444,7 @@ nsXBLProtoImplField::InstallField(JS::Handle<JSObject*> aBoundNode,
if (rv == NS_SUCCESS_DOM_SCRIPT_EVALUATION_THREW) {
// Report the exception now, before we try using the JSContext for
// the JS_DefineUCProperty call.
entryScript.ReportException();
aes.ReportException();
}
// Now, enter the node's compartment, wrap the eval result, and define it on
-1
View File
@@ -290,7 +290,6 @@ nsXBLProtoImplAnonymousMethod::Execute(nsIContent* aBoundElement, JSAddonId* aAd
// We are going to run script via JS::Call, so we need a script entry point,
// but as this is XBL related it does not appear in the HTML spec.
dom::AutoEntryScript aes(global, "XBL <constructor>/<destructor> invocation");
aes.TakeOwnershipOfErrorReporting();
JSContext* cx = aes.cx();
JS::Rooted<JSObject*> globalObject(cx, global->GetGlobalJSObject());
-1
View File
@@ -3503,7 +3503,6 @@ XULDocument::ExecuteScript(nsXULPrototypeScript *aScript)
// We're about to run script via JS::CloneAndExecuteScript, so we need an
// AutoEntryScript. This is Gecko specific and not in any spec.
AutoEntryScript aes(mScriptGlobalObject, "precompiled XUL <script> element");
aes.TakeOwnershipOfErrorReporting();
JSContext* cx = aes.cx();
JS::Rooted<JSObject*> baseGlobal(cx, JS::CurrentGlobalOrNull(cx));
NS_ENSURE_TRUE(nsContentUtils::GetSecurityManager()->ScriptAllowed(baseGlobal), NS_OK);
+2 -2
View File
@@ -1372,8 +1372,8 @@ nsXULTemplateBuilder::InitHTMLTemplateRoot()
// We are going to run script via JS_SetProperty, so we need a script entry
// point, but as this is XUL related it does not appear in the HTML spec.
AutoEntryScript entryScript(innerWin, "nsXULTemplateBuilder creation", true);
JSContext* jscontext = entryScript.cx();
AutoEntryScript aes(innerWin, "nsXULTemplateBuilder creation", true);
JSContext* jscontext = aes.cx();
JS::Rooted<JS::Value> v(jscontext);
rv = nsContentUtils::WrapNative(jscontext, mRoot, mRoot, &v);
-3
View File
@@ -279,7 +279,6 @@ WrapperAnswer::RecvGet(const ObjectId& objId, const JSVariant& receiverVar,
// We may run scripted getters.
AutoEntryScript aes(scopeForTargetObjects(),
"Cross-Process Object Wrapper 'get'");
aes.TakeOwnershipOfErrorReporting();
JSContext* cx = aes.cx();
// The outparam will be written to the buffer, so it must be set even if
@@ -317,7 +316,6 @@ WrapperAnswer::RecvSet(const ObjectId& objId, const JSIDVariant& idVar, const JS
// We may run scripted setters.
AutoEntryScript aes(scopeForTargetObjects(),
"Cross-Process Object Wrapper 'set'");
aes.TakeOwnershipOfErrorReporting();
JSContext* cx = aes.cx();
RootedObject obj(cx, findObjectById(cx, objId));
@@ -379,7 +377,6 @@ WrapperAnswer::RecvCallOrConstruct(const ObjectId& objId,
{
AutoEntryScript aes(scopeForTargetObjects(),
"Cross-Process Object Wrapper call/construct");
aes.TakeOwnershipOfErrorReporting();
JSContext* cx = aes.cx();
// The outparam will be written to the buffer, so it must be set even if
+14 -4
View File
@@ -323,12 +323,22 @@ AtomicOperations::isLockfree(int32_t size)
# include "jit/arm64/AtomicOperations-arm64.h"
#elif defined(JS_CODEGEN_MIPS32) || defined(JS_CODEGEN_MIPS64)
# include "jit/mips-shared/AtomicOperations-mips-shared.h"
#elif defined(__ppc64__) || defined(__PPC64_) \
|| defined(__ppc64le__) || defined(__PPC64LE__) \
|| defined(__ppc__) || defined(__PPC__)
#elif defined(__ppc__) || defined(__PPC__)
# include "jit/none/AtomicOperations-ppc.h"
#elif defined(JS_CODEGEN_NONE)
# include "jit/none/AtomicOperations-none.h"
// You can disable the JIT with --disable-ion but you must still
// provide the atomic operations that will be used by the JS engine.
// When the JIT is disabled the operations are simply safe-for-races
// C++ realizations of atomics. These operations cannot be written
// in portable C++, hence the default here is to crash. See the
// top of the file for more guidance.
# if defined(__ppc64__) || defined(__PPC64__) || defined(__ppc64le__) || defined(__PPC64LE__)
# include "jit/none/AtomicOperations-ppc.h"
# elif defined(__aarch64__)
# include "jit/arm64/AtomicOperations-arm64.h"
# else
# include "jit/none/AtomicOperations-none.h" // These MOZ_CRASH() always
# endif
#elif defined(JS_CODEGEN_X86) || defined(JS_CODEGEN_X64)
# include "jit/x86-shared/AtomicOperations-x86-shared.h"
#else
+71 -41
View File
@@ -375,10 +375,6 @@ BacktrackingAllocator::init()
if (!liveIn)
return false;
callRanges = LiveBundle::FallibleNew(alloc(), nullptr, nullptr);
if (!callRanges)
return false;
size_t numVregs = graph.numVirtualRegisters();
if (!vregs.init(mir->alloc(), numVregs))
return false;
@@ -431,6 +427,7 @@ BacktrackingAllocator::init()
}
hotcode.setAllocator(lifoAlloc);
callRanges.setAllocator(lifoAlloc);
// Partition the graph into hot and cold sections, for helping to make
// splitting decisions. Since we don't have any profiling data this is a
@@ -493,9 +490,7 @@ IsInputReused(LInstruction* ins, LUse* use)
/*
* This function builds up liveness ranges for all virtual registers
* defined in the function. Additionally, it populates the liveIn array with
* information about which registers are live at the beginning of a block, to
* aid resolution and reification in a later phase.
* defined in the function.
*
* The algorithm is based on the one published in:
*
@@ -579,7 +574,13 @@ BacktrackingAllocator::buildLivenessInfo()
return false;
}
}
if (!callRanges->addRange(alloc(), 0, outputOf(*ins), outputOf(*ins).next()))
CallRange* callRange = new(alloc()) CallRange(outputOf(*ins), outputOf(*ins).next());
if (!callRange)
return false;
callRangesList.pushFront(callRange);
if (!callRanges.insert(callRange))
return false;
}
DebugOnly<bool> hasDoubleDef = false;
@@ -810,9 +811,6 @@ BacktrackingAllocator::go()
if (!buildLivenessInfo())
return false;
if (JitSpewEnabled(JitSpew_RegAlloc))
dumpFixedRanges();
if (!allocationQueue.reserve(graph.numVirtualRegisters() * 3 / 2))
return false;
@@ -1822,32 +1820,39 @@ BacktrackingAllocator::resolveControlFlow()
return false;
}
}
}
// Add moves to resolve graph edges with different allocations at their
// source and target.
BitSet& live = liveIn[mSuccessor->id()];
// Add moves to resolve graph edges with different allocations at their
// source and target.
for (size_t i = 1; i < graph.numVirtualRegisters(); i++) {
VirtualRegister& reg = vregs[i];
for (LiveRange::RegisterLinkIterator iter = reg.rangesBegin(); iter; iter++) {
LiveRange* targetRange = LiveRange::get(*iter);
for (BitSet::Iterator liveRegId(live); liveRegId; ++liveRegId) {
VirtualRegister& reg = vregs[*liveRegId];
size_t firstBlockId = insData[targetRange->from()]->block()->mir()->id();
if (!targetRange->covers(entryOf(graph.getBlock(firstBlockId))))
firstBlockId++;
for (size_t id = firstBlockId; id < graph.numBlocks(); id++) {
LBlock* successor = graph.getBlock(id);
if (!targetRange->covers(entryOf(successor)))
break;
for (size_t j = 0; j < mSuccessor->numPredecessors(); j++) {
LBlock* predecessor = mSuccessor->getPredecessor(j)->lir();
BitSet& live = liveIn[id];
if (!live.contains(i))
continue;
for (LiveRange::RegisterLinkIterator iter = reg.rangesBegin(); iter; iter++) {
LiveRange* to = LiveRange::get(*iter);
if (!to->covers(entryOf(successor)))
continue;
if (to->covers(exitOf(predecessor)))
for (size_t j = 0; j < successor->mir()->numPredecessors(); j++) {
LBlock* predecessor = successor->mir()->getPredecessor(j)->lir();
if (targetRange->covers(exitOf(predecessor)))
continue;
LiveRange* from = reg.rangeFor(exitOf(predecessor), /* preferRegister = */ true);
if (mSuccessor->numPredecessors() > 1) {
LiveRange* from = reg.rangeFor(exitOf(predecessor), true);
if (successor->mir()->numPredecessors() > 1) {
MOZ_ASSERT(predecessor->mir()->numSuccessors() == 1);
if (!moveAtExit(predecessor, from, to, reg.type()))
if (!moveAtExit(predecessor, from, targetRange, reg.type()))
return false;
} else {
if (!moveAtEntry(successor, from, to, reg.type()))
if (!moveAtEntry(successor, from, targetRange, reg.type()))
return false;
}
}
@@ -2309,14 +2314,6 @@ BacktrackingAllocator::dumpVregs()
#endif
}
void
BacktrackingAllocator::dumpFixedRanges()
{
#ifdef JS_JITSPEW
fprintf(stderr, "Live ranges by physical register: %s\n", callRanges->toString().get());
#endif // JS_JITSPEW
}
#ifdef JS_JITSPEW
struct BacktrackingAllocator::PrintLiveRange
{
@@ -2998,11 +2995,44 @@ BacktrackingAllocator::splitAcrossCalls(LiveBundle* bundle)
// Find the locations of all calls in the bundle's range.
SplitPositionVector callPositions;
for (LiveRange::BundleLinkIterator iter = callRanges->rangesBegin(); iter; iter++) {
LiveRange* callRange = LiveRange::get(*iter);
if (bundle->rangeFor(callRange->from()) && bundle->rangeFor(callRange->from().previous())) {
if (!callPositions.append(callRange->from()))
return false;
for (LiveRange::BundleLinkIterator iter = bundle->rangesBegin(); iter; iter++) {
LiveRange* range = LiveRange::get(*iter);
CallRange searchRange(range->from(), range->to());
CallRange* callRange;
if (!callRanges.contains(&searchRange, &callRange)) {
// There are no calls inside this range.
continue;
}
MOZ_ASSERT(range->covers(callRange->range.from));
// The search above returns an arbitrary call within the range. Walk
// backwards to find the first call in the range.
for (CallRangeList::reverse_iterator riter = callRangesList.rbegin(callRange);
riter != callRangesList.rend();
++riter)
{
CodePosition pos = riter->range.from;
if (range->covers(pos))
callRange = *riter;
else
break;
}
// Add all call positions within the range, by walking forwards.
for (CallRangeList::iterator iter = callRangesList.begin(callRange);
iter != callRangesList.end();
++iter)
{
CodePosition pos = iter->range.from;
if (!range->covers(pos))
break;
// Calls at the beginning of the range are ignored; there is no splitting to do.
if (range->covers(pos.previous())) {
MOZ_ASSERT_IF(callPositions.length(), pos > callPositions.back());
if (!callPositions.append(pos))
return false;
}
}
}
MOZ_ASSERT(callPositions.length());
+22 -4
View File
@@ -600,9 +600,6 @@ class BacktrackingAllocator : protected RegisterAllocator
BitSet* liveIn;
FixedList<VirtualRegister> vregs;
// Ranges where all registers must be spilled due to call instructions.
LiveBundle* callRanges;
// Allocation state.
StackSlotAllocator stackSlotAllocator;
@@ -642,6 +639,28 @@ class BacktrackingAllocator : protected RegisterAllocator
// should be prioritized.
LiveRangeSet hotcode;
struct CallRange : public TempObject, public InlineListNode<CallRange> {
LiveRange::Range range;
CallRange(CodePosition from, CodePosition to)
: range(from, to)
{}
// Comparator for use in splay tree.
static int compare(CallRange* v0, CallRange* v1) {
if (v0->range.to <= v1->range.from)
return -1;
if (v0->range.from >= v1->range.to)
return 1;
return 0;
}
};
// Ranges where all registers must be spilled due to call instructions.
typedef InlineList<CallRange> CallRangeList;
CallRangeList callRangesList;
SplayTree<CallRange*, CallRange> callRanges;
// Information about an allocated stack slot.
struct SpillSlot : public TempObject, public InlineForwardListNode<SpillSlot> {
LStackSlot alloc;
@@ -754,7 +773,6 @@ class BacktrackingAllocator : protected RegisterAllocator
}
// Debugging methods.
void dumpFixedRanges();
void dumpAllocations();
struct PrintLiveRange;
+12
View File
@@ -479,6 +479,9 @@ RegisterAllocator::init()
if (!insData.init(mir, graph.numInstructions()))
return false;
if (!entryPositions.reserve(graph.numBlocks()) || !exitPositions.reserve(graph.numBlocks()))
return false;
for (size_t i = 0; i < graph.numBlocks(); i++) {
LBlock* block = graph.getBlock(i);
for (LInstructionIterator ins = block->begin(); ins != block->end(); ins++)
@@ -487,6 +490,15 @@ RegisterAllocator::init()
LPhi* phi = block->getPhi(j);
insData[phi->id()] = phi;
}
CodePosition entry = block->numPhis() != 0
? CodePosition(block->getPhi(0)->id(), CodePosition::INPUT)
: inputOf(block->firstInstructionWithId());
CodePosition exit = outputOf(block->lastInstructionWithId());
MOZ_ASSERT(block->mir()->id() == i);
entryPositions.infallibleAppend(entry);
exitPositions.infallibleAppend(exit);
}
return true;
+4 -4
View File
@@ -271,6 +271,8 @@ class RegisterAllocator
// Computed data
InstructionDataMap insData;
Vector<CodePosition, 12, SystemAllocPolicy> entryPositions;
Vector<CodePosition, 12, SystemAllocPolicy> exitPositions;
RegisterAllocator(MIRGenerator* mir, LIRGenerator* lir, LIRGraph& graph)
: mir(mir),
@@ -331,12 +333,10 @@ class RegisterAllocator
return CodePosition(ins->id(), CodePosition::INPUT);
}
CodePosition entryOf(const LBlock* block) {
return block->numPhis() != 0
? CodePosition(block->getPhi(0)->id(), CodePosition::INPUT)
: inputOf(block->firstInstructionWithId());
return entryPositions[block->mir()->id()];
}
CodePosition exitOf(const LBlock* block) {
return outputOf(block->lastInstructionWithId());
return exitPositions[block->mir()->id()];
}
LMoveGroup* getInputMoveGroup(LInstruction* ins);
@@ -12,8 +12,6 @@
#include "mozilla/Assertions.h"
#include "mozilla/Types.h"
#include "jit/arm64/Architecture-arm64.h"
inline bool
js::jit::AtomicOperations::isLockfree8()
{
@@ -634,7 +634,6 @@ mozJSComponentLoader::PrepareObjectForLocation(JSContext* aCx,
// Gecko-specific concept at present.
dom::AutoEntryScript aes(holder->GetJSObject(),
"component loader report global");
aes.TakeOwnershipOfErrorReporting();
RootedObject global(aes.cx(), holder->GetJSObject());
JS_FireOnNewGlobalObject(aes.cx(), global);
}
@@ -939,7 +938,6 @@ mozJSComponentLoader::ObjectForLocation(ComponentLoaderInfo& aInfo,
// This is Gecko-specific and not in any spec.
dom::AutoEntryScript aes(CurrentGlobalOrNull(cx),
"component loader load module");
aes.TakeOwnershipOfErrorReporting();
JSContext* aescx = aes.cx();
AutoSaveContextOptions asco(aescx);
if (aPropagateExceptions)
@@ -347,7 +347,6 @@ AsyncScriptLoader::OnStreamComplete(nsIIncrementalStreamLoader* aLoader,
nsCOMPtr<nsIGlobalObject> globalObject = xpc::NativeGlobal(mTargetObj);
AutoEntryScript aes(globalObject, "async loadSubScript");
aes.TakeOwnershipOfErrorReporting();
JSContext* cx = aes.cx();
AutoRejectPromise autoPromise(cx, mPromise, globalObject);
+10 -4
View File
@@ -805,7 +805,14 @@ bool
xpc::SandboxProxyHandler::has(JSContext* cx, JS::Handle<JSObject*> proxy,
JS::Handle<jsid> id, bool* bp) const
{
return BaseProxyHandler::has(cx, proxy, id, bp);
// This uses getPropertyDescriptor for backward compatibility with
// the old BaseProxyHandler::has implementation.
Rooted<PropertyDescriptor> desc(cx);
if (!getPropertyDescriptor(cx, proxy, id, &desc))
return false;
*bp = !!desc.object();
return true;
}
bool
xpc::SandboxProxyHandler::hasOwn(JSContext* cx, JS::Handle<JSObject*> proxy,
@@ -1717,9 +1724,8 @@ xpc::EvalInSandbox(JSContext* cx, HandleObject sandboxArg, const nsAString& sour
PromiseFlatString(source).get(), source.Length(), &v);
// If the sandbox threw an exception, grab it off the context.
if (JS_GetPendingException(sandcx, &exn)) {
MOZ_ASSERT(!ok);
JS_ClearPendingException(sandcx);
if (aes.HasException()) {
aes.StealException(&exn);
}
}
+1 -2
View File
@@ -1511,9 +1511,8 @@ XRE_XPCShellMain(int argc, char** argv, char** envp)
AutoEntryScript aes(backstagePass, "xpcshell argument processing");
// If an exception is thrown, we'll set our return code
// appropriately, and then let the AutoJSAPI destructor report
// appropriately, and then let the AutoEntryScript destructor report
// the error to the console.
aes.TakeOwnershipOfErrorReporting();
if (!ProcessArgs(aes, argv, argc, &dirprovider)) {
if (gExitCode) {
result = gExitCode;
-2
View File
@@ -515,7 +515,6 @@ nsXPCWrappedJSClass::DelegatedQueryInterface(nsXPCWrappedJS* self,
NS_ENSURE_TRUE(nativeGlobal->GetGlobalJSObject(), NS_ERROR_FAILURE);
AutoEntryScript aes(nativeGlobal, "XPCWrappedJS QueryInterface",
/* aIsMainThread = */ true);
aes.TakeOwnershipOfErrorReporting();
XPCCallContext ccx(NATIVE_CALLER, aes.cx());
if (!ccx.IsValid()) {
*aInstancePtr = nullptr;
@@ -983,7 +982,6 @@ nsXPCWrappedJSClass::CallMethod(nsXPCWrappedJS* wrapper, uint16_t methodIndex,
NativeGlobal(js::GetGlobalForObjectCrossCompartment(wrapper->GetJSObject()));
AutoEntryScript aes(nativeGlobal, "XPCWrappedJS method call",
/* aIsMainThread = */ true);
aes.TakeOwnershipOfErrorReporting();
XPCCallContext ccx(NATIVE_CALLER, aes.cx());
if (!ccx.IsValid())
return retval;
+1 -3
View File
@@ -942,9 +942,7 @@ ComputeSizeFromParts(nsPresContext* aPresContext,
// Add the parts that cannot be left out.
nscoord sum = 0;
for (int32_t i = first; i <= last; i++) {
if (aGlyphs[i] != aGlyphs[glue]) {
sum += aSizes[i];
}
sum += aSizes[i];
}
// Determine how much is used in joins
@@ -0,0 +1,14 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
</head>
<body>
<!-- Bug 1219068 -->
<div id="hider"
style="position:absolute; top:0; left:0; background-color:green;
height:1em; width:100%; z-index:1; padding-top:5px;
padding-bottom:5px;" />
</body>
</html>
+50
View File
@@ -0,0 +1,50 @@
<!DOCTYPE html>
<html class="reftest-wait">
<head>
<meta charset="UTF-8">
</head>
<body>
<!-- Bug 1219068 -->
<math style="position:absolute; top: 0; font-size:1em; z-index: 0;" display="block">
<mrow>
<mo>|</mo>
<mrow>
<mi>f</mi>
<mrow>
<mn>(</mn>
<mi>x</mi>
<mn>)</mn>
</mrow>
<mn>-</mn>
<mrow>
<mi>f</mi>
<mrow>
<mn>(</mn>
<msub>
<mi>x</mi>
<mn>0</mn>
</msub>
<mn>)</mn>
</mrow>
</mrow>
</mrow>
<mo>|</mo>
</mrow>
</math>
<div id="hider"
style="position:absolute; top:0; left:0; background-color:green;
height:1em; width:100%; z-index:1; padding-top:5px;
padding-bottom:5px; visibility:hidden" />
<script>
function obscureMathML() {
var hider = document.getElementById("hider");
hider.style.visibility="visible";
// The math should now be completely obscured
document.documentElement.removeAttribute("class");
}
window.addEventListener("MozReftestInvalidate", obscureMathML, false);
</script>
</body>
</html>
+1
View File
@@ -190,6 +190,7 @@ skip-if(B2G||Mulet) == maction-dynamic-1.html maction-dynamic-1-ref.html # bug 7
== mo-lspace-rspace-4.html mo-lspace-rspace-4-ref.html
== mo-invisibleoperators.html mo-invisibleoperators-ref.html
== mo-invisibleoperators-2.html mo-invisibleoperators-2-ref.html
== mo-glyph-size.html mo-glyph-size-ref.html
skip-if(B2G||Mulet) == maction-dynamic-3.html maction-dynamic-3-ref.html # bug 773482 # Initial mulet triage: parity with B2G/B2G Desktop
== whitespace-trim-1.html whitespace-trim-1-ref.html
== whitespace-trim-2.html whitespace-trim-2-ref.html
+2 -2
View File
@@ -57,12 +57,12 @@ public:
CComPtr(const CComPtr& aOther) : mPtr(nullptr) { Set(aOther.Get()); }
CComPtr() : mPtr(nullptr) { }
CComPtr(T* const & aPtr) : mPtr(nullptr) { Set(aPtr); }
CComPtr(const nullptr_t& aNullPtr) : mPtr(aNullPtr) { }
CComPtr(const std::nullptr_t& aNullPtr) : mPtr(aNullPtr) { }
T** operator&() { return &mPtr; }
T* operator->(){ return mPtr; }
operator T*() { return mPtr; }
T* operator=(T* const & aPtr) { return Set(aPtr); }
T* operator=(const nullptr_t& aPtr) { return mPtr = aPtr; }
T* operator=(const std::nullptr_t& aPtr) { return mPtr = aPtr; }
T* Get() const { return mPtr; }
+2 -3
View File
@@ -378,8 +378,7 @@ MappableSeekableZStream::Create(const char *name, Zip *zip,
Zip::Stream *stream)
{
MOZ_ASSERT(stream->GetType() == Zip::Stream::STORE);
mozilla::ScopedDeletePtr<MappableSeekableZStream> mappable;
mappable = new MappableSeekableZStream(zip);
UniquePtr<MappableSeekableZStream> mappable(new MappableSeekableZStream(zip));
pthread_mutexattr_t recursiveAttr;
pthread_mutexattr_init(&recursiveAttr);
@@ -398,7 +397,7 @@ MappableSeekableZStream::Create(const char *name, Zip *zip,
mappable->chunkAvail = MakeUnique<unsigned char[]>(mappable->zStream.GetChunksNum());
return mappable.forget();
return mappable.release();
}
MappableSeekableZStream::MappableSeekableZStream(Zip *zip)
+7 -8
View File
@@ -272,21 +272,21 @@ int SzipCompress::run(const char *name, Buffer &origBuf,
scanFilters = false;
}
mozilla::ScopedDeletePtr<Buffer> filteredBuf;
mozilla::UniquePtr<Buffer> filteredBuf;
Buffer *origData;
for (SeekableZStream::FilterId f = firstFilter; f < lastFilter; ++f) {
FilteredBuffer *filteredTmp = nullptr;
mozilla::UniquePtr<FilteredBuffer> filteredTmp;
Buffer tmpBuf;
if (f != SeekableZStream::NONE) {
DEBUG_LOG("Applying filter \"%s\"", filterName[f]);
filteredTmp = new FilteredBuffer();
filteredTmp = mozilla::MakeUnique<FilteredBuffer>();
filteredTmp->Filter(origBuf, f, chunkSize);
origData = filteredTmp;
origData = filteredTmp.get();
} else {
origData = &origBuf;
}
if (dictSize && !scanFilters) {
filteredBuf = filteredTmp;
filteredBuf = mozilla::Move(filteredTmp);
break;
}
DEBUG_LOG("Compressing with no dictionary");
@@ -295,14 +295,13 @@ int SzipCompress::run(const char *name, Buffer &origBuf,
outBuf.Fill(tmpBuf);
compressed = true;
filter = f;
filteredBuf = filteredTmp;
filteredBuf = mozilla::Move(filteredTmp);
continue;
}
}
delete filteredTmp;
}
origData = filteredBuf ? filteredBuf : &origBuf;
origData = filteredBuf ? filteredBuf.get() : &origBuf;
if (dictSize) {
Dictionary<uint64_t> dict(*origData, dictSize ? SzipCompress::winSize : 0);
+7
View File
@@ -30,6 +30,13 @@ public:
// Called to suspend parent channel in ChannelDiverterParent constructor.
virtual nsresult SuspendForDiversion() = 0;
// While messages are diverted back from the child to the parent calls to
// suspend/resume the channel must also suspend/resume the message diversion.
// These two functions will be called by nsHttpChannel and nsFtpChannel
// Suspend()/Resume() functions.
virtual nsresult SuspendMessageDiversion() = 0;
virtual nsresult ResumeMessageDiversion() = 0;
};
} // namespace net
+1
View File
@@ -30,6 +30,7 @@ XPIDL_SOURCES += [
'nsICaptivePortalService.idl',
'nsIChannel.idl',
'nsIChannelEventSink.idl',
'nsIChannelWithDivertableParentListener.idl',
'nsIChildChannel.idl',
'nsIClassOfService.idl',
'nsIContentSniffer.idl',
@@ -0,0 +1,46 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* 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/. */
#include "nsISupports.idl"
%{C++
namespace mozilla {
namespace net {
class ADivertableParentChannel;
}
}
%}
[ptr] native ADivertableParentChannelPtr(mozilla::net::ADivertableParentChannel);
/** When we are diverting messages from the child to the parent. The
* nsHttpChannel and nsFtpChannel must know that there is a ChannelParent to
* be able to suspend message delivery if the channel is suspended.
*/
[uuid(c073d79f-2503-4dff-ba87-d3071f8b433b)]
interface nsIChannelWithDivertableParentListener : nsISupports
{
/**
* Informs nsHttpChannel or nsFtpChannel that a ParentChannel starts
* diverting messages. During this time all suspend/resume calls to the
* channel must also suspend the ParentChannel by calling
* SuspendMessageDiversion/ResumeMessageDiversion.
*/
void MessageDiversionStarted(in ADivertableParentChannelPtr aParentChannel);
/**
* The message diversion has finished the calls to
* SuspendMessageDiversion/ResumeMessageDiversion are not necessary anymore.
*/
void MessageDiversionStop();
/**
* Internal versions of Suspend/Resume that suspend (or resume) the channel
* but do not suspend the ParentChannel's IPDL message queue.
*/
void SuspendInternal();
void ResumeInternal();
};
+30 -15
View File
@@ -12,6 +12,22 @@
namespace mozilla {
namespace net {
ChannelEvent*
ChannelEventQueue::TakeEvent()
{
MutexAutoLock lock(mMutex);
MOZ_ASSERT(mFlushing);
if (mSuspended || mEventQueue.IsEmpty()) {
return nullptr;
}
UniquePtr<ChannelEvent> event(Move(mEventQueue[0]));
mEventQueue.RemoveElementAt(0);
return event.release();
}
void
ChannelEventQueue::FlushQueue()
{
@@ -21,30 +37,29 @@ ChannelEventQueue::FlushQueue()
nsCOMPtr<nsISupports> kungFuDeathGrip(mOwner);
// Prevent flushed events from flushing the queue recursively
mFlushing = true;
uint32_t i;
for (i = 0; i < mEventQueue.Length(); i++) {
mEventQueue[i]->Run();
if (mSuspended)
break;
{
MutexAutoLock lock(mMutex);
mFlushing = true;
}
// We will always want to remove at least one finished callback.
if (i < mEventQueue.Length())
i++;
while (true) {
UniquePtr<ChannelEvent> event(TakeEvent());
if (!event) {
break;
}
// It is possible for new callbacks to be enqueued as we are
// flushing the queue, so the queue must not be cleared until
// all callbacks have run.
mEventQueue.RemoveElementsAt(0, i);
event->Run();
}
MutexAutoLock lock(mMutex);
mFlushing = false;
}
void
ChannelEventQueue::Resume()
{
MutexAutoLock lock(mMutex);
// Resuming w/o suspend: error in debug mode, ignore in build
MOZ_ASSERT(mSuspendCount > 0);
if (mSuspendCount <= 0) {
@@ -58,7 +73,7 @@ ChannelEventQueue::Resume()
mTargetThread->Dispatch(event, NS_DISPATCH_NORMAL);
} else {
MOZ_RELEASE_ASSERT(NS_IsMainThread());
NS_DispatchToCurrentThread(event);
NS_WARN_IF(NS_FAILED(NS_DispatchToCurrentThread(event)));
}
}
}
+90 -45
View File
@@ -8,8 +8,10 @@
#ifndef mozilla_net_ChannelEventQueue_h
#define mozilla_net_ChannelEventQueue_h
#include <nsTArray.h>
#include <nsAutoPtr.h>
#include "nsTArray.h"
#include "nsAutoPtr.h"
#include "mozilla/Mutex.h"
#include "mozilla/UniquePtr.h"
class nsISupports;
class nsIEventTarget;
@@ -42,28 +44,31 @@ class ChannelEventQueue final
, mSuspended(false)
, mForced(false)
, mFlushing(false)
, mOwner(owner) {}
// Checks to determine if an IPDL-generated channel event can be processed
// immediately, or needs to be queued using Enqueue().
inline bool ShouldEnqueue();
, mOwner(owner)
, mMutex("ChannelEventQueue::mMutex")
{}
// Puts IPDL-generated channel event into queue, to be run later
// automatically when EndForcedQueueing and/or Resume is called.
inline void Enqueue(ChannelEvent* callback);
inline nsresult PrependEvents(nsTArray<nsAutoPtr<ChannelEvent> >& aEvents);
//
// @param aCallback - the ChannelEvent
// @param aAssertionWhenNotQueued - this optional param will be used in an
// assertion when the event is executed directly.
inline void RunOrEnqueue(ChannelEvent* aCallback,
bool aAssertionWhenNotQueued = false);
inline nsresult PrependEvents(nsTArray<UniquePtr<ChannelEvent>>& aEvents);
// After StartForcedQueueing is called, ShouldEnqueue() will return true and
// no events will be run/flushed until EndForcedQueueing is called.
// After StartForcedQueueing is called, RunOrEnqueue() will start enqueuing
// events that will be run/flushed when EndForcedQueueing is called.
// - Note: queueing may still be required after EndForcedQueueing() (if the
// queue is suspended, etc): always call ShouldEnqueue() to determine
// whether queueing is needed.
// queue is suspended, etc): always call RunOrEnqueue() to avoid race
// conditions.
inline void StartForcedQueueing();
inline void EndForcedQueueing();
// Suspend/resume event queue. ShouldEnqueue() will return true and no events
// will be run/flushed until resume is called. These should be called when
// the channel owning the event queue is suspended/resumed.
// Suspend/resume event queue. RunOrEnqueue() will start enqueuing
// events and they will be run/flushed when resume is called. These should be
// called when the channel owning the event queue is suspended/resumed.
inline void Suspend();
// Resume flushes the queue asynchronously, i.e. items in queue will be
// dispatched in a new event on the current thread.
@@ -82,7 +87,9 @@ class ChannelEventQueue final
void FlushQueue();
inline void CompleteResume();
nsTArray<nsAutoPtr<ChannelEvent> > mEventQueue;
ChannelEvent* TakeEvent();
nsTArray<UniquePtr<ChannelEvent>> mEventQueue;
uint32_t mSuspendCount;
bool mSuspended;
@@ -92,58 +99,81 @@ class ChannelEventQueue final
// Keep ptr to avoid refcount cycle: only grab ref during flushing.
nsISupports *mOwner;
Mutex mMutex;
// EventTarget for delivery of events to the correct thread.
nsCOMPtr<nsIEventTarget> mTargetThread;
friend class AutoEventEnqueuer;
};
inline bool
ChannelEventQueue::ShouldEnqueue()
{
bool answer = mForced || mSuspended || mFlushing;
MOZ_ASSERT(answer == true || mEventQueue.IsEmpty(),
"Should always enqueue if ChannelEventQueue not empty");
return answer;
}
inline void
ChannelEventQueue::Enqueue(ChannelEvent* callback)
ChannelEventQueue::RunOrEnqueue(ChannelEvent* aCallback,
bool aAssertionWhenNotQueued)
{
mEventQueue.AppendElement(callback);
MOZ_ASSERT(aCallback);
// To avoid leaks.
UniquePtr<ChannelEvent> event(aCallback);
{
MutexAutoLock lock(mMutex);
bool enqueue = mForced || mSuspended || mFlushing;
MOZ_ASSERT(enqueue == true || mEventQueue.IsEmpty(),
"Should always enqueue if ChannelEventQueue not empty");
if (enqueue) {
mEventQueue.AppendElement(Move(event));
return;
}
}
MOZ_RELEASE_ASSERT(!aAssertionWhenNotQueued);
event->Run();
}
inline void
ChannelEventQueue::StartForcedQueueing()
{
MutexAutoLock lock(mMutex);
mForced = true;
}
inline void
ChannelEventQueue::EndForcedQueueing()
{
mForced = false;
{
MutexAutoLock lock(mMutex);
mForced = false;
}
MaybeFlushQueue();
}
inline nsresult
ChannelEventQueue::PrependEvents(nsTArray<nsAutoPtr<ChannelEvent> >& aEvents)
ChannelEventQueue::PrependEvents(nsTArray<UniquePtr<ChannelEvent>>& aEvents)
{
if (!mEventQueue.InsertElementsAt(0, aEvents.Length())) {
MutexAutoLock lock(mMutex);
UniquePtr<ChannelEvent>* newEvents =
mEventQueue.InsertElementsAt(0, aEvents.Length());
if (!newEvents) {
return NS_ERROR_OUT_OF_MEMORY;
}
for (uint32_t i = 0; i < aEvents.Length(); i++) {
mEventQueue.ReplaceElementAt(i, aEvents[i].forget());
newEvents[i] = Move(aEvents[i]);
}
return NS_OK;
}
inline void
ChannelEventQueue::Suspend()
{
MutexAutoLock lock(mMutex);
mSuspended = true;
mSuspendCount++;
}
@@ -151,14 +181,20 @@ ChannelEventQueue::Suspend()
inline void
ChannelEventQueue::CompleteResume()
{
// channel may have been suspended again since Resume fired event to call this.
if (!mSuspendCount) {
// we need to remain logically suspended (for purposes of queuing incoming
// messages) until this point, else new incoming messages could run before
// queued ones.
mSuspended = false;
MaybeFlushQueue();
{
MutexAutoLock lock(mMutex);
// channel may have been suspended again since Resume fired event to call
// this.
if (!mSuspendCount) {
// we need to remain logically suspended (for purposes of queuing incoming
// messages) until this point, else new incoming messages could run before
// queued ones.
mSuspended = false;
}
}
MaybeFlushQueue();
}
inline void
@@ -166,13 +202,22 @@ ChannelEventQueue::MaybeFlushQueue()
{
// Don't flush if forced queuing on, we're already being flushed, or
// suspended, or there's nothing to flush
if (!mForced && !mFlushing && !mSuspended && !mEventQueue.IsEmpty())
bool flushQueue = false;
{
MutexAutoLock lock(mMutex);
flushQueue = !mForced && !mFlushing && !mSuspended &&
!mEventQueue.IsEmpty();
}
if (flushQueue) {
FlushQueue();
}
}
// Ensures that ShouldEnqueue() will be true during its lifetime (letting
// caller know incoming IPDL msgs should be queued). Flushes the queue when it
// goes out of scope.
// Ensures that RunOrEnqueue() will be collecting events during its lifetime
// (letting caller know incoming IPDL msgs should be queued). Flushes the queue
// when it goes out of scope.
class MOZ_STACK_CLASS AutoEventEnqueuer
{
public:
+1
View File
@@ -118,6 +118,7 @@ struct HttpChannelOpenArgs
bool blockAuthPrompt;
bool suspendAfterSynthesizeResponse;
bool allowStaleCacheContent;
nsCString contentTypeHint;
bool isFromProcessingFrameAttributes;
};
+6 -1
View File
@@ -173,6 +173,9 @@ struct ParamTraits<mozilla::net::ResourceTimingStruct>
WriteParam(aMsg, aParam.transferSize);
WriteParam(aMsg, aParam.encodedBodySize);
WriteParam(aMsg, aParam.protocolVersion);
WriteParam(aMsg, aParam.cacheReadStart);
WriteParam(aMsg, aParam.cacheReadEnd);
}
static bool Read(const Message* aMsg, void** aIter, mozilla::net::ResourceTimingStruct* aResult)
@@ -189,7 +192,9 @@ struct ParamTraits<mozilla::net::ResourceTimingStruct>
ReadParam(aMsg, aIter, &aResult->redirectEnd) &&
ReadParam(aMsg, aIter, &aResult->transferSize) &&
ReadParam(aMsg, aIter, &aResult->encodedBodySize) &&
ReadParam(aMsg, aIter, &aResult->protocolVersion);
ReadParam(aMsg, aIter, &aResult->protocolVersion) &&
ReadParam(aMsg, aIter, &aResult->cacheReadStart) &&
ReadParam(aMsg, aIter, &aResult->cacheReadEnd);
}
};
+13 -38
View File
@@ -286,14 +286,10 @@ FTPChannelChild::RecvOnStartRequest(const nsresult& aChannelStatus,
LOG(("FTPChannelChild::RecvOnStartRequest [this=%p]\n", this));
if (mEventQ->ShouldEnqueue()) {
mEventQ->Enqueue(new FTPStartRequestEvent(this, aChannelStatus,
aContentLength, aContentType,
aLastModified, aEntityID, aURI));
} else {
DoOnStartRequest(aChannelStatus, aContentLength, aContentType,
aLastModified, aEntityID, aURI);
}
mEventQ->RunOrEnqueue(new FTPStartRequestEvent(this, aChannelStatus,
aContentLength, aContentType,
aLastModified, aEntityID,
aURI));
return true;
}
@@ -381,15 +377,10 @@ FTPChannelChild::RecvOnDataAvailable(const nsresult& channelStatus,
LOG(("FTPChannelChild::RecvOnDataAvailable [this=%p]\n", this));
if (mEventQ->ShouldEnqueue()) {
mEventQ->Enqueue(
new FTPDataAvailableEvent(this, channelStatus, data, offset, count));
} else {
MOZ_RELEASE_ASSERT(!mDivertingToParent,
"ShouldEnqueue when diverting to parent!");
mEventQ->RunOrEnqueue(new FTPDataAvailableEvent(this, channelStatus, data,
offset, count),
mDivertingToParent);
DoOnDataAvailable(channelStatus, data, offset, count);
}
return true;
}
@@ -452,7 +443,7 @@ FTPChannelChild::DoOnDataAvailable(const nsresult& channelStatus,
if (mUnknownDecoderInvolved) {
mUnknownDecoderEventQ.AppendElement(
new MaybeDivertOnDataFTPEvent(this, data, offset, count));
MakeUnique<MaybeDivertOnDataFTPEvent>(this, data, offset, count));
}
// NOTE: the OnDataAvailable contract requires the client to read all the data
@@ -506,11 +497,7 @@ FTPChannelChild::RecvOnStopRequest(const nsresult& aChannelStatus)
LOG(("FTPChannelChild::RecvOnStopRequest [this=%p status=%x]\n",
this, aChannelStatus));
if (mEventQ->ShouldEnqueue()) {
mEventQ->Enqueue(new FTPStopRequestEvent(this, aChannelStatus));
} else {
DoOnStopRequest(aChannelStatus);
}
mEventQ->RunOrEnqueue(new FTPStopRequestEvent(this, aChannelStatus));
return true;
}
@@ -559,7 +546,7 @@ FTPChannelChild::DoOnStopRequest(const nsresult& aChannelStatus)
if (mUnknownDecoderInvolved) {
mUnknownDecoderEventQ.AppendElement(
new MaybeDivertOnStopFTPEvent(this, aChannelStatus));
MakeUnique<MaybeDivertOnStopFTPEvent>(this, aChannelStatus));
}
{ // Ensure that all queued ipdl events are dispatched before
@@ -595,11 +582,7 @@ FTPChannelChild::RecvFailedAsyncOpen(const nsresult& statusCode)
{
LOG(("FTPChannelChild::RecvFailedAsyncOpen [this=%p status=%x]\n",
this, statusCode));
if (mEventQ->ShouldEnqueue()) {
mEventQ->Enqueue(new FTPFailedAsyncOpenEvent(this, statusCode));
} else {
DoFailedAsyncOpen(statusCode);
}
mEventQ->RunOrEnqueue(new FTPFailedAsyncOpenEvent(this, statusCode));
return true;
}
@@ -651,11 +634,7 @@ FTPChannelChild::RecvFlushedForDiversion()
LOG(("FTPChannelChild::RecvFlushedForDiversion [this=%p]\n", this));
MOZ_ASSERT(mDivertingToParent);
if (mEventQ->ShouldEnqueue()) {
mEventQ->Enqueue(new FTPFlushedForDiversionEvent(this));
} else {
MOZ_CRASH();
}
mEventQ->RunOrEnqueue(new FTPFlushedForDiversionEvent(this), true);
return true;
}
@@ -701,11 +680,7 @@ class FTPDeleteSelfEvent : public ChannelEvent
bool
FTPChannelChild::RecvDeleteSelf()
{
if (mEventQ->ShouldEnqueue()) {
mEventQ->Enqueue(new FTPDeleteSelfEvent(this));
} else {
DoDeleteSelf();
}
mEventQ->RunOrEnqueue(new FTPDeleteSelfEvent(this));
return true;
}
+2 -1
View File
@@ -8,6 +8,7 @@
#ifndef mozilla_net_FTPChannelChild_h
#define mozilla_net_FTPChannelChild_h
#include "mozilla/UniquePtr.h"
#include "mozilla/net/PFTPChannelChild.h"
#include "mozilla/net/ChannelEventQueue.h"
#include "nsBaseChannel.h"
@@ -126,7 +127,7 @@ private:
// If nsUnknownDecoder is involved we queue onDataAvailable (and possibly
// OnStopRequest) so that we can divert them if needed when the listener's
// OnStartRequest is finally called
nsTArray<nsAutoPtr<ChannelEvent>> mUnknownDecoderEventQ;
nsTArray<UniquePtr<ChannelEvent>> mUnknownDecoderEventQ;
bool mUnknownDecoderInvolved;
bool mCanceled;
+194 -20
View File
@@ -57,6 +57,8 @@ FTPChannelParent::FTPChannelParent(const PBrowserOrId& aIframeEmbedding,
}
mObserver = new OfflineObserver(this);
mEventQ = new ChannelEventQueue(static_cast<nsIParentChannel*>(this));
}
FTPChannelParent::~FTPChannelParent()
@@ -232,19 +234,47 @@ FTPChannelParent::RecvCancel(const nsresult& status)
bool
FTPChannelParent::RecvSuspend()
{
if (mChannel)
mChannel->Suspend();
if (mChannel) {
SuspendChannel();
}
return true;
}
bool
FTPChannelParent::RecvResume()
{
if (mChannel)
mChannel->Resume();
if (mChannel) {
ResumeChannel();
}
return true;
}
class FTPDivertDataAvailableEvent : public ChannelEvent
{
public:
FTPDivertDataAvailableEvent(FTPChannelParent* aParent,
const nsCString& data,
const uint64_t& offset,
const uint32_t& count)
: mParent(aParent)
, mData(data)
, mOffset(offset)
, mCount(count)
{
}
void Run()
{
mParent->DivertOnDataAvailable(mData, mOffset, mCount);
}
private:
FTPChannelParent* mParent;
nsCString mData;
uint64_t mOffset;
uint32_t mCount;
};
bool
FTPChannelParent::RecvDivertOnDataAvailable(const nsCString& data,
const uint64_t& offset,
@@ -262,6 +292,30 @@ FTPChannelParent::RecvDivertOnDataAvailable(const nsCString& data,
return true;
}
mEventQ->RunOrEnqueue(new FTPDivertDataAvailableEvent(this, data, offset,
count));
return true;
}
void
FTPChannelParent::DivertOnDataAvailable(const nsCString& data,
const uint64_t& offset,
const uint32_t& count)
{
LOG(("FTPChannelParent::DivertOnDataAvailable [this=%p]\n", this));
if (NS_WARN_IF(!mDivertingFromChild)) {
MOZ_ASSERT(mDivertingFromChild,
"Cannot DivertOnDataAvailable if diverting is not set!");
FailDiversion(NS_ERROR_UNEXPECTED);
return;
}
// Drop OnDataAvailables if the parent was canceled already.
if (NS_FAILED(mStatus)) {
return;
}
nsCOMPtr<nsIInputStream> stringStream;
nsresult rv = NS_NewByteInputStream(getter_AddRefs(stringStream), data.get(),
count, NS_ASSIGNMENT_DEPEND);
@@ -270,9 +324,11 @@ FTPChannelParent::RecvDivertOnDataAvailable(const nsCString& data,
mChannel->Cancel(rv);
}
mStatus = rv;
return true;
return;
}
AutoEventEnqueuer ensureSerialDispatch(mEventQ);
rv = OnDataAvailable(mChannel, nullptr, stringStream, offset, count);
stringStream->Close();
@@ -282,9 +338,27 @@ FTPChannelParent::RecvDivertOnDataAvailable(const nsCString& data,
}
mStatus = rv;
}
return true;
}
class FTPDivertStopRequestEvent : public ChannelEvent
{
public:
FTPDivertStopRequestEvent(FTPChannelParent* aParent,
const nsresult& statusCode)
: mParent(aParent)
, mStatusCode(statusCode)
{
}
void Run() {
mParent->DivertOnStopRequest(mStatusCode);
}
private:
FTPChannelParent* mParent;
nsresult mStatusCode;
};
bool
FTPChannelParent::RecvDivertOnStopRequest(const nsresult& statusCode)
{
@@ -295,6 +369,22 @@ FTPChannelParent::RecvDivertOnStopRequest(const nsresult& statusCode)
return false;
}
mEventQ->RunOrEnqueue(new FTPDivertStopRequestEvent(this, statusCode));
return true;
}
void
FTPChannelParent::DivertOnStopRequest(const nsresult& statusCode)
{
LOG(("FTPChannelParent::DivertOnStopRequest [this=%p]\n", this));
if (NS_WARN_IF(!mDivertingFromChild)) {
MOZ_ASSERT(mDivertingFromChild,
"Cannot DivertOnStopRequest if diverting is not set!");
FailDiversion(NS_ERROR_UNEXPECTED);
return;
}
// Honor the channel's status even if the underlying transaction completed.
nsresult status = NS_FAILED(mStatus) ? mStatus : statusCode;
@@ -306,10 +396,26 @@ FTPChannelParent::RecvDivertOnStopRequest(const nsresult& statusCode)
}
}
AutoEventEnqueuer ensureSerialDispatch(mEventQ);
OnStopRequest(mChannel, nullptr, status);
return true;
}
class FTPDivertCompleteEvent : public ChannelEvent
{
public:
explicit FTPDivertCompleteEvent(FTPChannelParent* aParent)
: mParent(aParent)
{
}
void Run() {
mParent->DivertComplete();
}
private:
FTPChannelParent* mParent;
};
bool
FTPChannelParent::RecvDivertComplete()
{
@@ -320,13 +426,26 @@ FTPChannelParent::RecvDivertComplete()
return false;
}
mEventQ->RunOrEnqueue(new FTPDivertCompleteEvent(this));
return true;
}
void
FTPChannelParent::DivertComplete()
{
LOG(("FTPChannelParent::DivertComplete [this=%p]\n", this));
if (NS_WARN_IF(!mDivertingFromChild)) {
MOZ_ASSERT(mDivertingFromChild,
"Cannot DivertComplete if diverting is not set!");
FailDiversion(NS_ERROR_UNEXPECTED);
return;
}
nsresult rv = ResumeForDiversion();
if (NS_WARN_IF(NS_FAILED(rv))) {
FailDiversion(NS_ERROR_UNEXPECTED);
return false;
}
return true;
}
//-----------------------------------------------------------------------------
@@ -494,6 +613,30 @@ FTPChannelParent::GetInterface(const nsIID& uuid, void** result)
return QueryInterface(uuid, result);
}
nsresult
FTPChannelParent::SuspendChannel()
{
nsCOMPtr<nsIChannelWithDivertableParentListener> chan =
do_QueryInterface(mChannel);
if (chan) {
return chan->SuspendInternal();
} else {
return mChannel->Suspend();
}
}
nsresult
FTPChannelParent::ResumeChannel()
{
nsCOMPtr<nsIChannelWithDivertableParentListener> chan =
do_QueryInterface(mChannel);
if (chan) {
return chan->ResumeInternal();
} else {
return mChannel->Resume();
}
}
//-----------------------------------------------------------------------------
// FTPChannelParent::ADivertableParentChannel
//-----------------------------------------------------------------------------
@@ -508,7 +651,7 @@ FTPChannelParent::SuspendForDiversion()
// Try suspending the channel. Allow it to fail, since OnStopRequest may have
// been called and thus the channel may not be pending.
nsresult rv = mChannel->Suspend();
nsresult rv = SuspendChannel();
MOZ_ASSERT(NS_SUCCEEDED(rv) || rv == NS_ERROR_NOT_AVAILABLE);
mSuspendedForDiversion = NS_SUCCEEDED(rv);
@@ -516,6 +659,12 @@ FTPChannelParent::SuspendForDiversion()
// to the child.
mDivertingFromChild = true;
nsCOMPtr<nsIChannelWithDivertableParentListener> chan =
do_QueryInterface(mChannel);
if (chan) {
chan->MessageDiversionStarted(this);
}
return NS_OK;
}
@@ -531,8 +680,14 @@ FTPChannelParent::ResumeForDiversion()
return NS_ERROR_UNEXPECTED;
}
nsCOMPtr<nsIChannelWithDivertableParentListener> chan =
do_QueryInterface(mChannel);
if (chan) {
chan->MessageDiversionStop();
}
if (mSuspendedForDiversion) {
nsresult rv = mChannel->Resume();
nsresult rv = ResumeChannel();
if (NS_WARN_IF(NS_FAILED(rv))) {
FailDiversion(NS_ERROR_UNEXPECTED, true);
return rv;
@@ -549,6 +704,22 @@ FTPChannelParent::ResumeForDiversion()
return NS_OK;
}
nsresult
FTPChannelParent::SuspendMessageDiversion()
{
// This only need to suspend message queue.
mEventQ->Suspend();
return NS_OK;
}
nsresult
FTPChannelParent::ResumeMessageDiversion()
{
// This only need to resumes message queue.
mEventQ->Resume();
return NS_OK;
}
void
FTPChannelParent::DivertTo(nsIStreamListener *aListener)
{
@@ -590,14 +761,17 @@ FTPChannelParent::StartDiversion()
}
}
// Call OnStartRequest for the "DivertTo" listener.
nsresult rv = OnStartRequest(mChannel, nullptr);
if (NS_FAILED(rv)) {
if (mChannel) {
mChannel->Cancel(rv);
{
AutoEventEnqueuer ensureSerialDispatch(mEventQ);
// Call OnStartRequest for the "DivertTo" listener.
nsresult rv = OnStartRequest(mChannel, nullptr);
if (NS_FAILED(rv)) {
if (mChannel) {
mChannel->Cancel(rv);
}
mStatus = rv;
return;
}
mStatus = rv;
return;
}
// After OnStartRequest has been called, tell FTPChannelChild to divert the
@@ -666,7 +840,7 @@ FTPChannelParent::NotifyDiversionFailed(nsresult aErrorCode,
// Resume only we suspended earlier.
if (mSuspendedForDiversion) {
mChannel->Resume();
ResumeChannel();
}
// Channel has already sent OnStartRequest to the child, so ensure that we
// call it here if it hasn't already been called.
+17
View File
@@ -52,6 +52,8 @@ public:
// ADivertableParentChannel functions.
void DivertTo(nsIStreamListener *aListener) override;
nsresult SuspendForDiversion() override;
nsresult SuspendMessageDiversion() override;
nsresult ResumeMessageDiversion() override;
// Calls OnStartRequest for "DivertTo" listener, then notifies child channel
// that it should divert OnDataAvailable and OnStopRequest calls to this
@@ -80,6 +82,16 @@ protected:
// ChildChannel. Used during HTTP->FTP redirects.
bool ConnectChannel(const uint32_t& channelId);
void DivertOnDataAvailable(const nsCString& data,
const uint64_t& offset,
const uint32_t& count);
void DivertOnStopRequest(const nsresult& statusCode);
void DivertComplete();
friend class FTPDivertDataAvailableEvent;
friend class FTPDivertStopRequestEvent;
friend class FTPDivertCompleteEvent;
virtual bool RecvCancel(const nsresult& status) override;
virtual bool RecvSuspend() override;
virtual bool RecvResume() override;
@@ -89,6 +101,9 @@ protected:
virtual bool RecvDivertOnStopRequest(const nsresult& statusCode) override;
virtual bool RecvDivertComplete() override;
nsresult SuspendChannel();
nsresult ResumeChannel();
virtual void ActorDestroy(ActorDestroyReason why) override;
void OfflineDisconnect() override;
@@ -120,6 +135,8 @@ protected:
bool mSuspendedForDiversion;
RefPtr<OfflineObserver> mObserver;
RefPtr<mozilla::dom::TabParent> mTabParent;
RefPtr<ChannelEventQueue> mEventQ;
};
} // namespace net
+69 -1
View File
@@ -30,7 +30,8 @@ NS_IMPL_ISUPPORTS_INHERITED(nsFtpChannel,
nsIResumableChannel,
nsIFTPChannel,
nsIProxiedChannel,
nsIForcePendingChannel)
nsIForcePendingChannel,
nsIChannelWithDivertableParentListener)
//-----------------------------------------------------------------------------
@@ -224,3 +225,70 @@ nsFtpChannel::Pending() const
{
return nsBaseChannel::Pending() || mForcePending;
}
NS_IMETHODIMP
nsFtpChannel::Suspend()
{
LOG(("nsFtpChannel::Suspend [this=%p]\n", this));
nsresult rv = nsBaseChannel::Suspend();
nsresult rvParentChannel = NS_OK;
if (mParentChannel) {
rvParentChannel = mParentChannel->SuspendMessageDiversion();
}
return NS_FAILED(rv) ? rv : rvParentChannel;
}
NS_IMETHODIMP
nsFtpChannel::Resume()
{
LOG(("nsFtpChannel::Resume [this=%p]\n", this));
nsresult rv = nsBaseChannel::Resume();
nsresult rvParentChannel = NS_OK;
if (mParentChannel) {
rvParentChannel = mParentChannel->ResumeMessageDiversion();
}
return NS_FAILED(rv) ? rv : rvParentChannel;
}
//-----------------------------------------------------------------------------
// AChannelHasDivertableParentChannelAsListener internal functions
//-----------------------------------------------------------------------------
NS_IMETHODIMP
nsFtpChannel::MessageDiversionStarted(ADivertableParentChannel *aParentChannel)
{
MOZ_ASSERT(!mParentChannel);
mParentChannel = aParentChannel;
return NS_OK;
}
NS_IMETHODIMP
nsFtpChannel::MessageDiversionStop()
{
LOG(("nsFtpChannel::MessageDiversionStop [this=%p]", this));
MOZ_ASSERT(mParentChannel);
mParentChannel = nullptr;
return NS_OK;
}
NS_IMETHODIMP
nsFtpChannel::SuspendInternal()
{
LOG(("nsFtpChannel::SuspendInternal [this=%p]\n", this));
return nsBaseChannel::Suspend();
}
NS_IMETHODIMP
nsFtpChannel::ResumeInternal()
{
LOG(("nsFtpChannel::ResumeInternal [this=%p]\n", this));
return nsBaseChannel::Resume();
}
+17 -9
View File
@@ -11,6 +11,7 @@
#include "nsString.h"
#include "nsCOMPtr.h"
#include "nsIChannelWithDivertableParentListener.h"
#include "nsIFTPChannel.h"
#include "nsIForcePendingChannel.h"
#include "nsIUploadChannel.h"
@@ -19,19 +20,22 @@
#include "nsIResumableChannel.h"
class nsIURI;
using mozilla::net::ADivertableParentChannel;
class nsFtpChannel final : public nsBaseChannel,
public nsIFTPChannel,
public nsIUploadChannel,
public nsIResumableChannel,
public nsIProxiedChannel,
public nsIForcePendingChannel
public nsIForcePendingChannel,
public nsIChannelWithDivertableParentListener
{
public:
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_NSIUPLOADCHANNEL
NS_DECL_NSIRESUMABLECHANNEL
NS_DECL_NSIPROXIEDCHANNEL
NS_DECL_NSICHANNELWITHDIVERTABLEPARENTLISTENER
nsFtpChannel(nsIURI *uri, nsIProxyInfo *pi)
: mProxyInfo(pi)
@@ -90,6 +94,9 @@ public:
// Helper function for getting the nsIFTPEventSink.
void GetFTPEventSink(nsCOMPtr<nsIFTPEventSink> &aResult);
NS_IMETHOD Suspend() override;
NS_IMETHOD Resume() override;
public:
NS_IMETHOD ForcePending(bool aForcePending) override;
@@ -101,14 +108,15 @@ protected:
virtual void OnCallbacksChanged() override;
private:
nsCOMPtr<nsIProxyInfo> mProxyInfo;
nsCOMPtr<nsIFTPEventSink> mFTPEventSink;
nsCOMPtr<nsIInputStream> mUploadStream;
uint64_t mStartPos;
nsCString mEntityID;
bool mResumeRequested;
PRTime mLastModifiedTime;
bool mForcePending;
nsCOMPtr<nsIProxyInfo> mProxyInfo;
nsCOMPtr<nsIFTPEventSink> mFTPEventSink;
nsCOMPtr<nsIInputStream> mUploadStream;
uint64_t mStartPos;
nsCString mEntityID;
bool mResumeRequested;
PRTime mLastModifiedTime;
bool mForcePending;
RefPtr<ADivertableParentChannel> mParentChannel;
};
#endif /* nsFTPChannel_h___ */
+32 -74
View File
@@ -280,11 +280,8 @@ HttpChannelChild::RecvAssociateApplicationCache(const nsCString &groupID,
const nsCString &clientID)
{
LOG(("HttpChannelChild::RecvAssociateApplicationCache [this=%p]\n", this));
if (mEventQ->ShouldEnqueue()) {
mEventQ->Enqueue(new AssociateApplicationCacheEvent(this, groupID, clientID));
} else {
AssociateApplicationCache(groupID, clientID);
}
mEventQ->RunOrEnqueue(new AssociateApplicationCacheEvent(this, groupID,
clientID));
return true;
}
@@ -384,19 +381,13 @@ HttpChannelChild::RecvOnStartRequest(const nsresult& channelStatus,
mRedirectCount = redirectCount;
if (mEventQ->ShouldEnqueue()) {
mEventQ->Enqueue(new StartRequestEvent(this, channelStatus, responseHead,
useResponseHead, requestHeaders,
isFromCache, cacheEntryAvailable,
cacheExpirationTime, cachedCharset,
securityInfoSerialization, selfAddr,
peerAddr, cacheKey));
} else {
OnStartRequest(channelStatus, responseHead, useResponseHead, requestHeaders,
isFromCache, cacheEntryAvailable, cacheExpirationTime,
cachedCharset, securityInfoSerialization, selfAddr,
peerAddr, cacheKey);
}
mEventQ->RunOrEnqueue(new StartRequestEvent(this, channelStatus, responseHead,
useResponseHead, requestHeaders,
isFromCache, cacheEntryAvailable,
cacheExpirationTime,
cachedCharset,
securityInfoSerialization,
selfAddr, peerAddr, cacheKey));
return true;
}
@@ -616,18 +607,11 @@ HttpChannelChild::RecvOnTransportAndData(const nsresult& channelStatus,
MOZ_RELEASE_ASSERT(!mFlushedForDiversion,
"Should not be receiving any more callbacks from parent!");
if (mEventQ->ShouldEnqueue()) {
mEventQ->Enqueue(new TransportAndDataEvent(this, channelStatus,
transportStatus, progress,
progressMax, data, offset,
count));
} else {
MOZ_RELEASE_ASSERT(!mDivertingToParent,
"ShouldEnqueue when diverting to parent!");
OnTransportAndData(channelStatus, transportStatus, progress, progressMax,
data, offset, count);
}
mEventQ->RunOrEnqueue(new TransportAndDataEvent(this, channelStatus,
transportStatus, progress,
progressMax, data, offset,
count),
mDivertingToParent);
return true;
}
@@ -698,7 +682,7 @@ HttpChannelChild::OnTransportAndData(const nsresult& channelStatus,
LOG(("UnknownDecoder is involved queue OnDataAvailable call. [this=%p]",
this));
mUnknownDecoderEventQ.AppendElement(
new MaybeDivertOnDataHttpEvent(this, data, offset, count));
MakeUnique<MaybeDivertOnDataHttpEvent>(this, data, offset, count));
}
// Hold queue lock throughout all three calls, else we might process a later
@@ -826,13 +810,8 @@ HttpChannelChild::RecvOnStopRequest(const nsresult& channelStatus,
MOZ_RELEASE_ASSERT(!mFlushedForDiversion,
"Should not be receiving any more callbacks from parent!");
if (mEventQ->ShouldEnqueue()) {
mEventQ->Enqueue(new StopRequestEvent(this, channelStatus, timing));
} else {
MOZ_ASSERT(!mDivertingToParent, "ShouldEnqueue when diverting to parent!");
OnStopRequest(channelStatus, timing);
}
mEventQ->RunOrEnqueue(new StopRequestEvent(this, channelStatus, timing),
mDivertingToParent);
return true;
}
@@ -885,7 +864,7 @@ HttpChannelChild::OnStopRequest(const nsresult& channelStatus,
LOG(("UnknownDecoder is involved queue OnStopRequest call. [this=%p]",
this));
mUnknownDecoderEventQ.AppendElement(
new MaybeDivertOnStopHttpEvent(this, channelStatus));
MakeUnique<MaybeDivertOnStopHttpEvent>(this, channelStatus));
}
nsCOMPtr<nsICompressConvStats> conv = do_QueryInterface(mCompressListener);
@@ -907,6 +886,9 @@ HttpChannelChild::OnStopRequest(const nsresult& channelStatus,
mEncodedBodySize = timing.encodedBodySize;
mProtocolVersion = timing.protocolVersion;
mCacheReadStart = timing.cacheReadStart;
mCacheReadEnd = timing.cacheReadEnd;
nsPerformance* documentPerformance = GetPerformance();
if (documentPerformance) {
documentPerformance->AddEntry(this, this);
@@ -989,11 +971,7 @@ bool
HttpChannelChild::RecvOnProgress(const int64_t& progress,
const int64_t& progressMax)
{
if (mEventQ->ShouldEnqueue()) {
mEventQ->Enqueue(new ProgressEvent(this, progress, progressMax));
} else {
OnProgress(progress, progressMax);
}
mEventQ->RunOrEnqueue(new ProgressEvent(this, progress, progressMax));
return true;
}
@@ -1042,11 +1020,7 @@ class StatusEvent : public ChannelEvent
bool
HttpChannelChild::RecvOnStatus(const nsresult& status)
{
if (mEventQ->ShouldEnqueue()) {
mEventQ->Enqueue(new StatusEvent(this, status));
} else {
OnStatus(status);
}
mEventQ->RunOrEnqueue(new StatusEvent(this, status));
return true;
}
@@ -1093,11 +1067,7 @@ bool
HttpChannelChild::RecvFailedAsyncOpen(const nsresult& status)
{
LOG(("HttpChannelChild::RecvFailedAsyncOpen [this=%p]\n", this));
if (mEventQ->ShouldEnqueue()) {
mEventQ->Enqueue(new FailedAsyncOpenEvent(this, status));
} else {
FailedAsyncOpen(status);
}
mEventQ->RunOrEnqueue(new FailedAsyncOpenEvent(this, status));
return true;
}
@@ -1146,11 +1116,7 @@ bool
HttpChannelChild::RecvDeleteSelf()
{
LOG(("HttpChannelChild::RecvDeleteSelf [this=%p]\n", this));
if (mEventQ->ShouldEnqueue()) {
mEventQ->Enqueue(new DeleteSelfEvent(this));
} else {
DeleteSelf();
}
mEventQ->RunOrEnqueue(new DeleteSelfEvent(this));
return true;
}
@@ -1207,14 +1173,9 @@ HttpChannelChild::RecvRedirect1Begin(const uint32_t& newChannelId,
{
// TODO: handle security info
LOG(("HttpChannelChild::RecvRedirect1Begin [this=%p]\n", this));
if (mEventQ->ShouldEnqueue()) {
mEventQ->Enqueue(new Redirect1Event(this, newChannelId, newUri,
redirectFlags, responseHead,
securityInfoSerialization));
} else {
Redirect1Begin(newChannelId, newUri, redirectFlags, responseHead,
securityInfoSerialization);
}
mEventQ->RunOrEnqueue(new Redirect1Event(this, newChannelId, newUri,
redirectFlags, responseHead,
securityInfoSerialization));
return true;
}
@@ -1351,11 +1312,7 @@ bool
HttpChannelChild::RecvRedirect3Complete()
{
LOG(("HttpChannelChild::RecvRedirect3Complete [this=%p]\n", this));
if (mEventQ->ShouldEnqueue()) {
mEventQ->Enqueue(new Redirect3Event(this));
} else {
Redirect3Complete();
}
mEventQ->RunOrEnqueue(new Redirect3Event(this));
return true;
}
@@ -1381,9 +1338,8 @@ HttpChannelChild::RecvFlushedForDiversion()
{
LOG(("HttpChannelChild::RecvFlushedForDiversion [this=%p]\n", this));
MOZ_RELEASE_ASSERT(mDivertingToParent);
MOZ_RELEASE_ASSERT(mEventQ->ShouldEnqueue());
mEventQ->Enqueue(new HttpFlushedForDiversionEvent(this));
mEventQ->RunOrEnqueue(new HttpFlushedForDiversionEvent(this), true);
return true;
}
@@ -1969,6 +1925,8 @@ HttpChannelChild::ContinueAsyncOpen()
openArgs.blockAuthPrompt() = mBlockAuthPrompt;
openArgs.contentTypeHint() = mContentTypeHint;
nsresult rv = mozilla::ipc::LoadInfoToLoadInfoArgs(mLoadInfo, &openArgs.loadInfo());
NS_ENSURE_SUCCESS(rv, rv);
+2 -1
View File
@@ -8,6 +8,7 @@
#ifndef mozilla_net_HttpChannelChild_h
#define mozilla_net_HttpChannelChild_h
#include "mozilla/UniquePtr.h"
#include "mozilla/net/HttpBaseChannel.h"
#include "mozilla/net/PHttpChannelChild.h"
#include "mozilla/net/ChannelEventQueue.h"
@@ -205,7 +206,7 @@ private:
// If nsUnknownDecoder is involved OnStartRequest call will be delayed and
// this queue keeps OnDataAvailable data until OnStartRequest is finally
// called.
nsTArray<nsAutoPtr<ChannelEvent>> mUnknownDecoderEventQ;
nsTArray<UniquePtr<ChannelEvent>> mUnknownDecoderEventQ;
bool mUnknownDecoderInvolved;
// Once set, OnData and possibly OnStop will be diverted to the parent.
+40 -27
View File
@@ -134,7 +134,7 @@ HttpChannelParent::Init(const HttpChannelCreationArgs& aArgs)
a.cacheKey(), a.schedulingContextID(), a.preflightArgs(),
a.initialRwin(), a.blockAuthPrompt(),
a.suspendAfterSynthesizeResponse(),
a.allowStaleCacheContent());
a.allowStaleCacheContent(), a.contentTypeHint());
}
case HttpChannelCreationArgs::THttpChannelConnectArgs:
{
@@ -269,7 +269,8 @@ HttpChannelParent::DoAsyncOpen( const URIParams& aURI,
const uint32_t& aInitialRwin,
const bool& aBlockAuthPrompt,
const bool& aSuspendAfterSynthesizeResponse,
const bool& aAllowStaleCacheContent)
const bool& aAllowStaleCacheContent,
const nsCString& aContentTypeHint)
{
nsCOMPtr<nsIURI> uri = DeserializeURI(aURI);
if (!uri) {
@@ -387,8 +388,6 @@ HttpChannelParent::DoAsyncOpen( const URIParams& aURI,
mChannel->SetUploadStreamHasHeaders(uploadStreamHasHeaders);
}
mChannel->SetAllowStaleCacheContent(aAllowStaleCacheContent);
if (aSynthesizedResponseHead.type() == OptionalHttpResponseHead::TnsHttpResponseHead) {
mParentListener->SetupInterception(aSynthesizedResponseHead.get_nsHttpResponseHead());
mWillSynthesizeResponse = true;
@@ -420,6 +419,10 @@ HttpChannelParent::DoAsyncOpen( const URIParams& aURI,
mChannel->SetCacheKey(cacheKey);
mChannel->SetAllowStaleCacheContent(aAllowStaleCacheContent);
mChannel->SetContentType(aContentTypeHint);
if (priority != nsISupportsPriority::PRIORITY_NORMAL) {
mChannel->SetPriority(priority);
}
@@ -570,7 +573,7 @@ HttpChannelParent::RecvSuspend()
LOG(("HttpChannelParent::RecvSuspend [this=%p]\n", this));
if (mChannel) {
mChannel->Suspend();
mChannel->SuspendInternal();
}
return true;
}
@@ -581,7 +584,7 @@ HttpChannelParent::RecvResume()
LOG(("HttpChannelParent::RecvResume [this=%p]\n", this));
if (mChannel) {
mChannel->Resume();
mChannel->ResumeInternal();
}
return true;
}
@@ -759,12 +762,8 @@ HttpChannelParent::RecvDivertOnDataAvailable(const nsCString& data,
return true;
}
if (mEventQ->ShouldEnqueue()) {
mEventQ->Enqueue(new DivertDataAvailableEvent(this, data, offset, count));
return true;
}
DivertOnDataAvailable(data, offset, count);
mEventQ->RunOrEnqueue(new DivertDataAvailableEvent(this, data, offset,
count));
return true;
}
@@ -844,12 +843,7 @@ HttpChannelParent::RecvDivertOnStopRequest(const nsresult& statusCode)
return false;
}
if (mEventQ->ShouldEnqueue()) {
mEventQ->Enqueue(new DivertStopRequestEvent(this, statusCode));
return true;
}
DivertOnStopRequest(statusCode);
mEventQ->RunOrEnqueue(new DivertStopRequestEvent(this, statusCode));
return true;
}
@@ -907,12 +901,7 @@ HttpChannelParent::RecvDivertComplete()
return false;
}
if (mEventQ->ShouldEnqueue()) {
mEventQ->Enqueue(new DivertCompleteEvent(this));
return true;
}
DivertComplete();
mEventQ->RunOrEnqueue(new DivertCompleteEvent(this));
return true;
}
@@ -1124,6 +1113,9 @@ HttpChannelParent::OnStopRequest(nsIRequest *aRequest,
// to be passed down.
mChannel->GetProtocolVersion(timing.protocolVersion);
mChannel->GetCacheReadStart(&timing.cacheReadStart);
mChannel->GetCacheReadEnd(&timing.cacheReadEnd);
if (mIPCClosed || !SendOnStopRequest(aStatusCode, timing))
return NS_ERROR_UNEXPECTED;
return NS_OK;
@@ -1339,7 +1331,7 @@ HttpChannelParent::SuspendForDiversion()
// automatically suspended after synthesizing the response, then we don't
// need to suspend again here.
if (!mSuspendAfterSynthesizeResponse) {
rv = mChannel->Suspend();
rv = mChannel->SuspendInternal();
MOZ_ASSERT(NS_SUCCEEDED(rv) || rv == NS_ERROR_NOT_AVAILABLE);
mSuspendedForDiversion = NS_SUCCEEDED(rv);
} else {
@@ -1355,6 +1347,25 @@ HttpChannelParent::SuspendForDiversion()
// to the child.
mDivertingFromChild = true;
mChannel->MessageDiversionStarted(this);
return NS_OK;
}
nsresult
HttpChannelParent::SuspendMessageDiversion()
{
LOG(("HttpChannelParent::SuspendMessageDiversion [this=%p]", this));
// This only needs to suspend message queue.
mEventQ->Suspend();
return NS_OK;
}
nsresult
HttpChannelParent::ResumeMessageDiversion()
{
LOG(("HttpChannelParent::SuspendMessageDiversion [this=%p]", this));
// This only needs to resumes message queue.
mEventQ->Resume();
return NS_OK;
}
@@ -1370,9 +1381,11 @@ HttpChannelParent::ResumeForDiversion()
return NS_ERROR_UNEXPECTED;
}
mChannel->MessageDiversionStop();
if (mSuspendedForDiversion) {
// The nsHttpChannel will deliver remaining OnData/OnStop for the transfer.
nsresult rv = mChannel->Resume();
nsresult rv = mChannel->ResumeInternal();
if (NS_WARN_IF(NS_FAILED(rv))) {
FailDiversion(NS_ERROR_UNEXPECTED, true);
return rv;
@@ -1536,7 +1549,7 @@ HttpChannelParent::NotifyDiversionFailed(nsresult aErrorCode,
// Resume only if we suspended earlier.
if (mSuspendedForDiversion) {
mChannel->Resume();
mChannel->ResumeInternal();
}
// Channel has already sent OnStartRequest to the child, so ensure that we
// call it here if it hasn't already been called.
+4 -1
View File
@@ -82,6 +82,8 @@ public:
// ADivertableParentChannel functions.
void DivertTo(nsIStreamListener *aListener) override;
nsresult SuspendForDiversion() override;
nsresult SuspendMessageDiversion() override;
nsresult ResumeMessageDiversion() override;
// Calls OnStartRequest for "DivertTo" listener, then notifies child channel
// that it should divert OnDataAvailable and OnStopRequest calls to this
@@ -139,7 +141,8 @@ protected:
const uint32_t& aInitialRwin,
const bool& aBlockAuthPrompt,
const bool& aSuspendAfterSynthesizeResponse,
const bool& aAllowStaleCacheContent);
const bool& aAllowStaleCacheContent,
const nsCString& aContentTypeHint);
virtual bool RecvSetPriority(const uint16_t& priority) override;
virtual bool RecvSetClassOfService(const uint32_t& cos) override;
+6
View File
@@ -27,6 +27,12 @@ struct ResourceTimingStruct : TimingStruct {
uint64_t transferSize;
uint64_t encodedBodySize;
nsCString protocolVersion;
// Not actually part of resource timing, but not part of the transaction
// timings either. These need to be passed to HttpChannelChild along with
// the rest of the timings so the timing information in the child is complete.
TimeStamp cacheReadStart;
TimeStamp cacheReadEnd;
};
} // namespace net
+80 -31
View File
@@ -4972,6 +4972,7 @@ NS_INTERFACE_MAP_BEGIN(nsHttpChannel)
NS_INTERFACE_MAP_ENTRY(nsIDNSListener)
NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
NS_INTERFACE_MAP_ENTRY(nsICorsPreflightCallback)
NS_INTERFACE_MAP_ENTRY(nsIChannelWithDivertableParentListener)
// we have no macro that covers this case.
if (aIID.Equals(NS_GET_IID(nsHttpChannel)) ) {
AddRef();
@@ -5020,48 +5021,27 @@ nsHttpChannel::Cancel(nsresult status)
NS_IMETHODIMP
nsHttpChannel::Suspend()
{
NS_ENSURE_TRUE(mIsPending, NS_ERROR_NOT_AVAILABLE);
nsresult rv = SuspendInternal();
LOG(("nsHttpChannel::Suspend [this=%p]\n", this));
++mSuspendCount;
nsresult rvTransaction = NS_OK;
if (mTransactionPump) {
rvTransaction = mTransactionPump->Suspend();
}
nsresult rvCache = NS_OK;
if (mCachePump) {
rvCache = mCachePump->Suspend();
nsresult rvParentChannel = NS_OK;
if (mParentChannel) {
rvParentChannel = mParentChannel->SuspendMessageDiversion();
}
return NS_FAILED(rvTransaction) ? rvTransaction : rvCache;
return NS_FAILED(rv) ? rv : rvParentChannel;
}
NS_IMETHODIMP
nsHttpChannel::Resume()
{
NS_ENSURE_TRUE(mSuspendCount > 0, NS_ERROR_UNEXPECTED);
nsresult rv = ResumeInternal();
LOG(("nsHttpChannel::Resume [this=%p]\n", this));
if (--mSuspendCount == 0 && mCallOnResume) {
nsresult rv = AsyncCall(mCallOnResume);
mCallOnResume = nullptr;
NS_ENSURE_SUCCESS(rv, rv);
nsresult rvParentChannel = NS_OK;
if (mParentChannel) {
rvParentChannel = mParentChannel->ResumeMessageDiversion();
}
nsresult rvTransaction = NS_OK;
if (mTransactionPump) {
rvTransaction = mTransactionPump->Resume();
}
nsresult rvCache = NS_OK;
if (mCachePump) {
rvCache = mCachePump->Resume();
}
return NS_FAILED(rvTransaction) ? rvTransaction : rvCache;
return NS_FAILED(rv) ? rv : rvParentChannel;
}
//-----------------------------------------------------------------------------
@@ -7272,6 +7252,75 @@ nsHttpChannel::OnPreflightFailed(nsresult aError)
return NS_OK;
}
//-----------------------------------------------------------------------------
// AChannelHasDivertableParentChannelAsListener internal functions
//-----------------------------------------------------------------------------
NS_IMETHODIMP
nsHttpChannel::MessageDiversionStarted(ADivertableParentChannel *aParentChannel)
{
LOG(("nsHttpChannel::MessageDiversionStarted [this=%p]", this));
MOZ_ASSERT(!mParentChannel);
mParentChannel = aParentChannel;
return NS_OK;
}
NS_IMETHODIMP
nsHttpChannel::MessageDiversionStop()
{
LOG(("nsHttpChannel::MessageDiversionStop [this=%p]", this));
MOZ_ASSERT(mParentChannel);
mParentChannel = nullptr;
return NS_OK;
}
NS_IMETHODIMP
nsHttpChannel::SuspendInternal()
{
NS_ENSURE_TRUE(mIsPending, NS_ERROR_NOT_AVAILABLE);
LOG(("nsHttpChannel::SuspendInternal [this=%p]\n", this));
++mSuspendCount;
nsresult rvTransaction = NS_OK;
if (mTransactionPump) {
rvTransaction = mTransactionPump->Suspend();
}
nsresult rvCache = NS_OK;
if (mCachePump) {
rvCache = mCachePump->Suspend();
}
return NS_FAILED(rvTransaction) ? rvTransaction : rvCache;
}
NS_IMETHODIMP
nsHttpChannel::ResumeInternal()
{
NS_ENSURE_TRUE(mSuspendCount > 0, NS_ERROR_UNEXPECTED);
LOG(("nsHttpChannel::ResumeInternal [this=%p]\n", this));
if (--mSuspendCount == 0 && mCallOnResume) {
nsresult rv = AsyncCall(mCallOnResume);
mCallOnResume = nullptr;
NS_ENSURE_SUCCESS(rv, rv);
}
nsresult rvTransaction = NS_OK;
if (mTransactionPump) {
rvTransaction = mTransactionPump->Resume();
}
nsresult rvCache = NS_OK;
if (mCachePump) {
rvCache = mCachePump->Resume();
}
return NS_FAILED(rvTransaction) ? rvTransaction : rvCache;
}
void
nsHttpChannel::MaybeWarnAboutAppCache()
{
+6
View File
@@ -15,6 +15,7 @@
#include "nsICacheEntryOpenCallback.h"
#include "nsIDNSListener.h"
#include "nsIApplicationCacheChannel.h"
#include "nsIChannelWithDivertableParentListener.h"
#include "nsIProtocolProxyCallback.h"
#include "nsIHttpAuthenticableChannel.h"
#include "nsIAsyncVerifyRedirectCallback.h"
@@ -22,6 +23,7 @@
#include "nsIThreadRetargetableStreamListener.h"
#include "nsWeakReference.h"
#include "TimingStruct.h"
#include "ADivertableParentChannel.h"
#include "AutoClose.h"
#include "nsIStreamListener.h"
#include "nsISupportsPrimitives.h"
@@ -73,6 +75,7 @@ class nsHttpChannel final : public HttpBaseChannel
, public nsIDNSListener
, public nsSupportsWeakReference
, public nsICorsPreflightCallback
, public nsIChannelWithDivertableParentListener
{
public:
NS_DECL_ISUPPORTS_INHERITED
@@ -91,6 +94,7 @@ public:
NS_DECL_NSIASYNCVERIFYREDIRECTCALLBACK
NS_DECL_NSITHREADRETARGETABLEREQUEST
NS_DECL_NSIDNSLISTENER
NS_DECL_NSICHANNELWITHDIVERTABLEPARENTLISTENER
NS_DECLARE_STATIC_IID_ACCESSOR(NS_HTTPCHANNEL_IID)
// nsIHttpAuthenticableChannel. We can't use
@@ -551,6 +555,8 @@ private:
// If non-null, warnings should be reported to this object.
HttpChannelSecurityWarningReporter* mWarningReporter;
RefPtr<ADivertableParentChannel> mParentChannel;
protected:
virtual void DoNotifyListenerCleanup() override;
@@ -214,17 +214,11 @@ WebSocketChannelChild::RecvOnStart(const nsCString& aProtocol,
const nsString& aEffectiveURL,
const bool& aEncrypted)
{
if (mEventQ->ShouldEnqueue()) {
mEventQ->Enqueue(new EventTargetDispatcher(
new StartEvent(this, aProtocol, aExtensions,
aEffectiveURL, aEncrypted),
mTargetThread));
} else if (mTargetThread) {
DispatchToTargetThread(new StartEvent(this, aProtocol, aExtensions,
aEffectiveURL, aEncrypted));
} else {
OnStart(aProtocol, aExtensions, aEffectiveURL, aEncrypted);
}
mEventQ->RunOrEnqueue(
new EventTargetDispatcher(new StartEvent(this, aProtocol, aExtensions,
aEffectiveURL, aEncrypted),
mTargetThread));
return true;
}
@@ -267,14 +261,10 @@ class StopEvent : public ChannelEvent
bool
WebSocketChannelChild::RecvOnStop(const nsresult& aStatusCode)
{
if (mEventQ->ShouldEnqueue()) {
mEventQ->Enqueue(new EventTargetDispatcher(
new StopEvent(this, aStatusCode), mTargetThread));
} else if (mTargetThread) {
DispatchToTargetThread(new StopEvent(this, aStatusCode));
} else {
OnStop(aStatusCode);
}
mEventQ->RunOrEnqueue(
new EventTargetDispatcher(new StopEvent(this, aStatusCode),
mTargetThread));
return true;
}
@@ -316,14 +306,10 @@ class MessageEvent : public ChannelEvent
bool
WebSocketChannelChild::RecvOnMessageAvailable(const nsCString& aMsg)
{
if (mEventQ->ShouldEnqueue()) {
mEventQ->Enqueue(new EventTargetDispatcher(
new MessageEvent(this, aMsg, false), mTargetThread));
} else if (mTargetThread) {
DispatchToTargetThread(new MessageEvent(this, aMsg, false));
} else {
OnMessageAvailable(aMsg);
}
mEventQ->RunOrEnqueue(
new EventTargetDispatcher(new MessageEvent(this, aMsg, false),
mTargetThread));
return true;
}
@@ -340,14 +326,10 @@ WebSocketChannelChild::OnMessageAvailable(const nsCString& aMsg)
bool
WebSocketChannelChild::RecvOnBinaryMessageAvailable(const nsCString& aMsg)
{
if (mEventQ->ShouldEnqueue()) {
mEventQ->Enqueue(new EventTargetDispatcher(
new MessageEvent(this, aMsg, true), mTargetThread));
} else if (mTargetThread) {
DispatchToTargetThread(new MessageEvent(this, aMsg, true));
} else {
OnBinaryMessageAvailable(aMsg);
}
mEventQ->RunOrEnqueue(
new EventTargetDispatcher(new MessageEvent(this, aMsg, true),
mTargetThread));
return true;
}
@@ -383,14 +365,10 @@ class AcknowledgeEvent : public ChannelEvent
bool
WebSocketChannelChild::RecvOnAcknowledge(const uint32_t& aSize)
{
if (mEventQ->ShouldEnqueue()) {
mEventQ->Enqueue(new EventTargetDispatcher(
new AcknowledgeEvent(this, aSize), mTargetThread));
} else if (mTargetThread) {
DispatchToTargetThread(new AcknowledgeEvent(this, aSize));
} else {
OnAcknowledge(aSize);
}
mEventQ->RunOrEnqueue(
new EventTargetDispatcher(new AcknowledgeEvent(this, aSize),
mTargetThread));
return true;
}
@@ -429,15 +407,10 @@ bool
WebSocketChannelChild::RecvOnServerClose(const uint16_t& aCode,
const nsCString& aReason)
{
if (mEventQ->ShouldEnqueue()) {
mEventQ->Enqueue(new EventTargetDispatcher(
new ServerCloseEvent(this, aCode, aReason),
mTargetThread));
} else if (mTargetThread) {
DispatchToTargetThread(new ServerCloseEvent(this, aCode, aReason));
} else {
OnServerClose(aCode, aReason);
}
mEventQ->RunOrEnqueue(
new EventTargetDispatcher(new ServerCloseEvent(this, aCode, aReason),
mTargetThread));
return true;
}
@@ -153,13 +153,9 @@ WyciwygChannelChild::RecvOnStartRequest(const nsresult& statusCode,
const nsCString& charset,
const nsCString& securityInfo)
{
if (mEventQ->ShouldEnqueue()) {
mEventQ->Enqueue(new WyciwygStartRequestEvent(this, statusCode,
contentLength, source,
charset, securityInfo));
} else {
OnStartRequest(statusCode, contentLength, source, charset, securityInfo);
}
mEventQ->RunOrEnqueue(new WyciwygStartRequestEvent(this, statusCode,
contentLength, source,
charset, securityInfo));
return true;
}
@@ -208,11 +204,7 @@ bool
WyciwygChannelChild::RecvOnDataAvailable(const nsCString& data,
const uint64_t& offset)
{
if (mEventQ->ShouldEnqueue()) {
mEventQ->Enqueue(new WyciwygDataAvailableEvent(this, data, offset));
} else {
OnDataAvailable(data, offset);
}
mEventQ->RunOrEnqueue(new WyciwygDataAvailableEvent(this, data, offset));
return true;
}
@@ -270,11 +262,7 @@ private:
bool
WyciwygChannelChild::RecvOnStopRequest(const nsresult& statusCode)
{
if (mEventQ->ShouldEnqueue()) {
mEventQ->Enqueue(new WyciwygStopRequestEvent(this, statusCode));
} else {
OnStopRequest(statusCode);
}
mEventQ->RunOrEnqueue(new WyciwygStopRequestEvent(this, statusCode));
return true;
}
@@ -327,11 +315,7 @@ class WyciwygCancelEvent : public ChannelEvent
bool
WyciwygChannelChild::RecvCancelEarly(const nsresult& statusCode)
{
if (mEventQ->ShouldEnqueue()) {
mEventQ->Enqueue(new WyciwygCancelEvent(this, statusCode));
} else {
CancelEarly(statusCode);
}
mEventQ->RunOrEnqueue(new WyciwygCancelEvent(this, statusCode));
return true;
}
@@ -1,5 +0,0 @@
[responsexml-media-type.htm]
type: testharness
[XMLHttpRequest: responseXML MIME type tests ('text/plainxml', should not parse)]
expected: FAIL
@@ -1,5 +0,0 @@
[htmlallcollection.html]
type: testharness
[Test for multiple occurence 3 <script> found]
expected: FAIL
@@ -1,5 +1,5 @@
<!DOCTYPE HTML>
<html>
<html id="root">
<head>
<title>HTMLAllCollection Tests</title>
<link rel="author" title="Dan Druta" href="mailto:dan.druta@att.com"/>
@@ -9,17 +9,17 @@
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<body id="tags">
<img src="../../../../images/green.png" name="picture">
<a name="foo"></a>
<a name="foo"></a>
<script>
test(function(){ assert_equals(document.all.length,12)}, "Test for HTMLAllCollection size");
test(function(){ assert_equals(document.all.length,14)}, "Test for HTMLAllCollection size");
test(function(){ assert_equals(document.all.item(0).tagName,"HTML")}, "Test lookup by index using ()");
test(function(){ assert_equals(document.all[0].tagName,"HTML")}, "Test lookup by index using []");
test(function(){ assert_equals(document.all.tags("script").length,3)}, "Test for multiple occurence 3 <script> found");
test(function(){ assert_equals(document.all.item("picture").nodeName,"IMG")}, "Test lookup IMG by name");
test(function(){ assert_equals(document.all.namedItem("picture").nodeName,"IMG")}, "Test lookup IMG by namedItem ");
@@ -27,7 +27,21 @@ test(function(){ assert_equals(document.all.namedItem("picture").nodeName,"IMG")
test(function(){ assert_equals(document.all("picture").nodeName,"IMG")}, "Test lookup IMG in collection using ()");
test(function(){ assert_equals(document.all["picture"].nodeName,"IMG")}, "Test lookup IMG in collection using []");
test(function(){ assert_equals(document.all.picture.nodeName,"IMG")}, "Test lookup IMG in collection using .");
test(function(){ assert_equals(document.all.tags.id,"tags")}, "Test lookup tags in collection using .");
test(function() {
assert_equals(document.all["root"], document.documentElement);
}, "Should find root element too");
test(function() {
assert_equals(document.all["foo"].length, 2);
}, "Should find both anchors and produce a list");
test
</script>
<div id="log"></div>
</body>
</html>
</html>
-1
View File
@@ -1662,7 +1662,6 @@ CycleCollectedJSRuntime::EnvironmentPreparer::invoke(JS::HandleObject scope,
JSContext* cx =
mainThread ? nullptr : nsContentUtils::GetDefaultJSContextForThread();
AutoEntryScript aes(global, "JS-engine-initiated execution", mainThread, cx);
aes.TakeOwnershipOfErrorReporting();
MOZ_ASSERT(!JS_IsExceptionPending(aes.cx()));
@@ -158,7 +158,6 @@ nsHTTPIndex::OnFTPControlLog(bool server, const char *msg)
// AutoEntryScript. This is Gecko specific and not in any spec.
dom::AutoEntryScript aes(globalObject,
"nsHTTPIndex OnFTPControlLog");
aes.TakeOwnershipOfErrorReporting();
JSContext* cx = aes.cx();
JS::Rooted<JSObject*> global(cx, JS::CurrentGlobalOrNull(cx));
@@ -233,7 +232,6 @@ nsHTTPIndex::OnStartRequest(nsIRequest *request, nsISupports* aContext)
// This is Gecko specific and not in any spec.
dom::AutoEntryScript aes(globalObject,
"nsHTTPIndex set HTTPIndex property");
aes.TakeOwnershipOfErrorReporting();
JSContext* cx = aes.cx();
JS::Rooted<JSObject*> global(cx, JS::CurrentGlobalOrNull(cx));