Merge remote-tracking branch 'origin/tracking' into custom

This commit is contained in:
roytam1 2023-03-14 22:12:29 +08:00
commit 60e7987621
15 changed files with 79 additions and 47 deletions

View file

@ -10,16 +10,6 @@
#include "jsapi.h"
CPOWTimer::CPOWTimer(JSContext* cx MOZ_GUARD_OBJECT_NOTIFIER_PARAM_IN_IMPL)
: cx_(nullptr)
, startInterval_(0)
{
MOZ_GUARD_OBJECT_NOTIFIER_INIT;
if (!js::GetStopwatchIsMonitoringCPOW(cx))
return;
cx_ = cx;
startInterval_ = JS_Now();
}
CPOWTimer::~CPOWTimer()
{
if (!cx_) {

View file

@ -21,7 +21,16 @@
*/
class MOZ_RAII CPOWTimer final {
public:
explicit inline CPOWTimer(JSContext* cx MOZ_GUARD_OBJECT_NOTIFIER_PARAM);
explicit inline
CPOWTimer(JSContext* cx MOZ_GUARD_OBJECT_NOTIFIER_PARAM) : cx_(nullptr)
, startInterval_(0)
{
MOZ_GUARD_OBJECT_NOTIFIER_INIT;
if (!js::GetStopwatchIsMonitoringCPOW(cx))
return;
cx_ = cx;
startInterval_ = JS_Now();
}
~CPOWTimer();
private:

View file

@ -5,6 +5,8 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "JavaScriptShared.h"
#include "JavaScriptChild.h"
#include "JavaScriptParent.h"
#include "mozilla/dom/BindingUtils.h"
#include "mozilla/dom/CPOWManagerGetter.h"
#include "mozilla/dom/TabChild.h"
@ -16,6 +18,7 @@
using namespace js;
using namespace JS;
using namespace mozilla;
using namespace mozilla::dom;
using namespace mozilla::jsipc;
IdToObjectMap::IdToObjectMap()

View file

@ -8,6 +8,7 @@
#include "JavaScriptLogging.h"
#include "mozilla/Unused.h"
#include "mozilla/dom/BindingUtils.h"
#include "GeckoProfiler.h"
#include "jsfriendapi.h"
#include "js/CharacterEncoding.h"
#include "xpcprivate.h"
@ -20,6 +21,7 @@
using namespace js;
using namespace JS;
using namespace mozilla;
using namespace mozilla::dom;
using namespace mozilla::jsipc;
struct AuxCPOWData

View file

@ -29,6 +29,7 @@ using mozilla::RangedPtr;
using js::intl::CallICU;
using js::intl::GetAvailableLocales;
using js::intl::IcuLocale;
using js::intl::INITIAL_CHAR_BUFFER_SIZE;
using js::intl::StringsAreEqual;
/**************** RelativeTimeFormat *****************/

View file

@ -15,6 +15,7 @@
#endif
#include "js/Id.h"
#include "xpc_make_class.h"
/**************************************************************/

View file

@ -54,8 +54,12 @@ using namespace mozilla;
using namespace JS;
using namespace xpc;
using mozilla::dom::ConvertExceptionToPromise;
using mozilla::dom::DestroyProtoAndIfaceCache;
using mozilla::dom::IndexedDatabaseManager;
using mozilla::dom::RequestOrUSVString;
using mozilla::dom::RequestOrUSVStringArgument;
using mozilla::dom::RootedDictionary;
NS_IMPL_CYCLE_COLLECTION_CLASS(SandboxPrivate)

View file

@ -22,6 +22,7 @@
#include "nsIObserverService.h"
#include "nsIDebug2.h"
#include "nsIDocShell.h"
#include "nsIInputStream.h"
#include "nsIRunnable.h"
#include "amIAddonManager.h"
#include "nsPIDOMWindow.h"
@ -40,6 +41,7 @@
#include "mozilla/dom/GeneratedAtomList.h"
#include "mozilla/dom/BindingUtils.h"
#include "mozilla/dom/Element.h"
#include "mozilla/dom/Promise.h"
#include "mozilla/dom/ScriptLoader.h"
#include "mozilla/dom/WindowBinding.h"
#include "mozilla/jsipc/CrossProcessObjectWrappers.h"
@ -71,6 +73,7 @@
#endif
using namespace mozilla;
using namespace mozilla::dom;
using namespace xpc;
using namespace JS;
using mozilla::dom::PerThreadAtomCache;

View file

@ -11,6 +11,7 @@
#include "mozilla/Attributes.h"
#include "mozilla/jsipc/CrossProcessObjectWrappers.h"
#include "mozilla/StaticPtr.h"
#include "nsContentUtils.h"
using namespace mozilla::dom;
using namespace JS;

View file

@ -4,6 +4,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "mozilla/Assertions.h"
#include "mozilla/Preferences.h"
#include "jsapi.h"
@ -23,6 +24,7 @@
using namespace JS;
using mozilla::dom::EncodingUtils;
using mozilla::Preferences;
/**
* JS locale callbacks implemented by XPCOM modules. These are theoretically

View file

@ -10,7 +10,9 @@
#include "mozilla/MemoryReporting.h"
#include "mozilla/XPTInterfaceInfoManager.h"
#include "nsAppRunner.h"
#include "nsIScriptError.h"
#include "nsJSUtils.h"
#include "nsPrintfCString.h"
using namespace JS;

View file

@ -10,6 +10,7 @@
#include "jsprf.h"
#include "mozilla/dom/BindingUtils.h"
#include "mozilla/Preferences.h"
#include "nsContentUtils.h"
#include "nsIAddonInterposition.h"
#include "AddonWrapper.h"
#include "js/Class.h"

View file

@ -7,6 +7,7 @@
#include "xpcprivate.h"
#include "XPCWrapper.h"
#include "AccessCheck.h"
#include "nsContentUtils.h"
#include "nsCycleCollectionNoteRootCallback.h"
#include "nsPrincipal.h"

View file

@ -596,48 +596,47 @@ nsJARChannel::GetSecurityInfo(nsISupports **aSecurityInfo)
return NS_OK;
}
bool nsJARChannel::GetContentTypeGuess(nsACString& aResult) const {
const char *ext = nullptr, *fileName = mJarEntry.get();
int32_t len = mJarEntry.Length();
// check if we're displaying a directory
// mJarEntry will be empty if we're trying to display
// the topmost directory in a zip, e.g. jar:foo.zip!/
if (ENTRY_IS_DIRECTORY(mJarEntry)) {
aResult.AssignLiteral(APPLICATION_HTTP_INDEX_FORMAT);
return true;
}
// Not a directory, take a guess by its extension
for (int32_t i = len - 1; i >= 0; i--) {
if (fileName[i] == '.') {
ext = &fileName[i + 1];
break;
}
}
if (!ext) {
return false;
}
nsIMIMEService* mimeServ = gJarHandler->MimeService();
if (!mimeServ) {
return false;
}
mimeServ->GetTypeFromExtension(nsDependentCString(ext), aResult);
return !aResult.IsEmpty();
}
NS_IMETHODIMP
nsJARChannel::GetContentType(nsACString &result)
nsJARChannel::GetContentType(nsACString &aResult)
{
// If the Jar file has not been open yet,
// We return application/x-unknown-content-type
if (!mOpened) {
result.Assign(UNKNOWN_CONTENT_TYPE);
aResult.Assign(UNKNOWN_CONTENT_TYPE);
return NS_OK;
}
if (mContentType.IsEmpty()) {
//
// generate content type and set it
//
const char *ext = nullptr, *fileName = mJarEntry.get();
int32_t len = mJarEntry.Length();
// check if we're displaying a directory
// mJarEntry will be empty if we're trying to display
// the topmost directory in a zip, e.g. jar:foo.zip!/
if (ENTRY_IS_DIRECTORY(mJarEntry)) {
mContentType.AssignLiteral(APPLICATION_HTTP_INDEX_FORMAT);
}
else {
// not a directory, take a guess by its extension
for (int32_t i = len-1; i >= 0; i--) {
if (fileName[i] == '.') {
ext = &fileName[i + 1];
break;
}
}
if (ext) {
nsIMIMEService *mimeServ = gJarHandler->MimeService();
if (mimeServ)
mimeServ->GetTypeFromExtension(nsDependentCString(ext), mContentType);
}
if (mContentType.IsEmpty())
mContentType.AssignLiteral(UNKNOWN_CONTENT_TYPE);
}
}
result = mContentType;
aResult = mContentType;
return NS_OK;
}
@ -655,8 +654,8 @@ nsJARChannel::SetContentType(const nsACString &aContentType)
NS_IMETHODIMP
nsJARChannel::GetContentCharset(nsACString &aContentCharset)
{
// If someone gives us a charset hint we should just use that charset.
// So we don't care when this is being called.
// We behave like HTTP channels (treat this as a hint if called before open,
// and override the charset if called after open).
aContentCharset = mContentCharset;
return NS_OK;
}
@ -749,6 +748,10 @@ nsJARChannel::Open(nsIInputStream **stream)
input.forget(stream);
mOpened = true;
// Compute the content type now.
if (!GetContentTypeGuess(mContentType)) {
mContentType.Assign(UNKNOWN_CONTENT_TYPE);
}
// local files are always considered safe
mIsUnsafe = false;
return NS_OK;
@ -846,6 +849,10 @@ nsJARChannel::AsyncOpen(nsIStreamListener *listener, nsISupports *ctx)
mLoadGroup->AddRequest(this, nullptr);
mOpened = true;
// Compute the content type now.
if (!GetContentTypeGuess(mContentType)) {
mContentType.Assign(UNKNOWN_CONTENT_TYPE);
}
return NS_OK;
}

View file

@ -59,6 +59,11 @@ private:
nsresult OpenLocalFile();
void NotifyError(nsresult aError);
void FireOnProgress(uint64_t aProgress);
// Returns false if we don't know the content type of this channel, in which
// case we should use the content-type hint.
bool GetContentTypeGuess(nsACString&) const;
virtual void OnDownloadComplete(mozilla::net::MemoryDownloader* aDownloader,
nsIRequest* aRequest,
nsISupports* aCtxt,