Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • tpo/applications/mullvad-browser
  • pierov/mullvad-browser
  • ma1/privacy-browser
  • morgan/mullvad-browser
  • boklm/privacy-browser
  • henry/mullvad-browser
  • NoisyCoil/mullvad-browser
  • jwilde/mullvad-browser
  • dan/mullvad-browser
  • brizental/mullvad-browser
  • securitybrahh/mullvad-browser
  • clairehurst/mullvad-browser
12 results
Show changes
Commits on Source (5)
......@@ -18,7 +18,12 @@ namespace mozilla {
##__VA_ARGS__)
RemoteMediaDataDecoder::RemoteMediaDataDecoder(RemoteDecoderChild* aChild)
: mChild(aChild) {
: mChild(aChild),
mDescription("RemoteMediaDataDecoder"_ns),
mProcessName("unknown"_ns),
mCodecName("unknown"_ns),
mIsHardwareAccelerated(false),
mConversion(ConversionRequired::kNeedNone) {
LOG("%p is created", this);
}
......@@ -48,6 +53,7 @@ RefPtr<MediaDataDecoder::InitPromise> RemoteMediaDataDecoder::Init() {
->Then(
RemoteDecoderManagerChild::GetManagerThread(), __func__,
[self, this](TrackType aTrack) {
MutexAutoLock lock(mMutex);
// If shutdown has started in the meantime shutdown promise may
// be resloved before this task. In this case mChild will be null
// and the init promise has to be canceled.
......@@ -127,6 +133,7 @@ RefPtr<ShutdownPromise> RemoteMediaDataDecoder::Shutdown() {
bool RemoteMediaDataDecoder::IsHardwareAccelerated(
nsACString& aFailureReason) const {
MutexAutoLock lock(mMutex);
aFailureReason = mHardwareAcceleratedReason;
return mIsHardwareAccelerated;
}
......@@ -145,18 +152,24 @@ void RemoteMediaDataDecoder::SetSeekThreshold(const media::TimeUnit& aTime) {
MediaDataDecoder::ConversionRequired RemoteMediaDataDecoder::NeedsConversion()
const {
MutexAutoLock lock(mMutex);
return mConversion;
}
nsCString RemoteMediaDataDecoder::GetDescriptionName() const {
MutexAutoLock lock(mMutex);
return mDescription;
}
nsCString RemoteMediaDataDecoder::GetProcessName() const {
MutexAutoLock lock(mMutex);
return mProcessName;
}
nsCString RemoteMediaDataDecoder::GetCodecName() const { return mCodecName; }
nsCString RemoteMediaDataDecoder::GetCodecName() const {
MutexAutoLock lock(mMutex);
return mCodecName;
}
#undef LOG
......
......@@ -53,14 +53,16 @@ class RemoteMediaDataDecoder final
// destructor when we can guarantee no other threads are accessing it). Only
// read from the manager thread.
RefPtr<RemoteDecoderChild> mChild;
mutable Mutex mMutex{"RemoteMediaDataDecoder"};
// Only ever written/modified during decoder initialisation.
// As such can be accessed from any threads after that.
nsCString mDescription = "RemoteMediaDataDecoder"_ns;
nsCString mProcessName = "unknown"_ns;
nsCString mCodecName = "unknown"_ns;
bool mIsHardwareAccelerated = false;
nsCString mHardwareAcceleratedReason;
ConversionRequired mConversion = ConversionRequired::kNeedNone;
nsCString mDescription MOZ_GUARDED_BY(mMutex);
nsCString mProcessName MOZ_GUARDED_BY(mMutex);
nsCString mCodecName MOZ_GUARDED_BY(mMutex);
bool mIsHardwareAccelerated MOZ_GUARDED_BY(mMutex);
nsCString mHardwareAcceleratedReason MOZ_GUARDED_BY(mMutex);
ConversionRequired mConversion MOZ_GUARDED_BY(mMutex);
};
} // namespace mozilla
......
......@@ -668,6 +668,7 @@ RefPtr<ShutdownPromise> MediaChangeMonitor::ShutdownDecoder() {
AssertOnThread();
mConversionRequired.reset();
if (mDecoder) {
MutexAutoLock lock(mMutex);
RefPtr<MediaDataDecoder> decoder = std::move(mDecoder);
return decoder->Shutdown();
}
......@@ -715,6 +716,7 @@ MediaChangeMonitor::CreateDecoder() {
->Then(
GetCurrentSerialEventTarget(), __func__,
[self = RefPtr{this}, this](RefPtr<MediaDataDecoder>&& aDecoder) {
MutexAutoLock lock(mMutex);
mDecoder = std::move(aDecoder);
DDLINKCHILD("decoder", mDecoder.get());
return CreateDecoderPromise::CreateAndResolve(true, __func__);
......@@ -963,6 +965,11 @@ void MediaChangeMonitor::FlushThenShutdownDecoder(
->Track(mFlushRequest);
}
MediaDataDecoder* MediaChangeMonitor::GetDecoderOnNonOwnerThread() const {
MutexAutoLock lock(mMutex);
return mDecoder;
}
#undef LOG
} // namespace mozilla
......@@ -41,34 +41,34 @@ class MediaChangeMonitor final
RefPtr<ShutdownPromise> Shutdown() override;
bool IsHardwareAccelerated(nsACString& aFailureReason) const override;
nsCString GetDescriptionName() const override {
if (mDecoder) {
return mDecoder->GetDescriptionName();
if (RefPtr<MediaDataDecoder> decoder = GetDecoderOnNonOwnerThread()) {
return decoder->GetDescriptionName();
}
return "MediaChangeMonitor decoder (pending)"_ns;
}
nsCString GetProcessName() const override {
if (mDecoder) {
return mDecoder->GetProcessName();
if (RefPtr<MediaDataDecoder> decoder = GetDecoderOnNonOwnerThread()) {
return decoder->GetProcessName();
}
return "MediaChangeMonitor"_ns;
}
nsCString GetCodecName() const override {
if (mDecoder) {
return mDecoder->GetCodecName();
if (RefPtr<MediaDataDecoder> decoder = GetDecoderOnNonOwnerThread()) {
return decoder->GetCodecName();
}
return "MediaChangeMonitor"_ns;
}
void SetSeekThreshold(const media::TimeUnit& aTime) override;
bool SupportDecoderRecycling() const override {
if (mDecoder) {
return mDecoder->SupportDecoderRecycling();
if (RefPtr<MediaDataDecoder> decoder = GetDecoderOnNonOwnerThread()) {
return decoder->SupportDecoderRecycling();
}
return false;
}
ConversionRequired NeedsConversion() const override {
if (mDecoder) {
return mDecoder->NeedsConversion();
if (RefPtr<MediaDataDecoder> decoder = GetDecoderOnNonOwnerThread()) {
return decoder->NeedsConversion();
}
// Default so no conversion is performed.
return ConversionRequired::kNeedNone;
......@@ -97,6 +97,9 @@ class MediaChangeMonitor final
MOZ_ASSERT(!mThread || mThread->IsOnCurrentThread());
}
// This is used for getting decoder debug info on other threads. Thread-safe.
MediaDataDecoder* GetDecoderOnNonOwnerThread() const;
bool CanRecycleDecoder() const;
typedef MozPromise<bool, MediaResult, true /* exclusive */>
......@@ -137,6 +140,13 @@ class MediaChangeMonitor final
const CreateDecoderParamsForAsync mParams;
// Keep any seek threshold set for after decoder creation and initialization.
Maybe<media::TimeUnit> mPendingSeekThreshold;
// This lock is used for mDecoder specifically, but it doens't need to be used
// for every places accessing mDecoder which is mostly on the owner thread.
// However, when requesting decoder debug info, it can happen on other
// threads, so we need this mutex to avoid the data race of
// creating/destroying decoder and accessing decoder's debug info.
mutable Mutex MOZ_ANNOTATED mMutex{"MediaChangeMonitor"};
};
} // namespace mozilla
......
......@@ -124,7 +124,7 @@ class ShmemCharMapHashEntry final : public PLDHashEntryHdr {
return aCharMap->GetChecksum();
}
enum { ALLOW_MEMMOVE = true };
enum { ALLOW_MEMMOVE = false }; // because of the Pointer member
private:
// charMaps are stored in the shared memory that FontList objects point to,
......
......@@ -12779,6 +12779,18 @@
value: true
mirror: always
# The length of cnonce string used in HTTP digest auth.
- name: network.http.digest_auth_cnonce_length
type: uint32_t
value: 16
mirror: always
# If true, HTTP response content-type headers will be parsed using the standards-compliant MimeType parser
- name: network.standard_content_type_parsing.response_headers
type: RelaxedAtomicBool
value: true
mirror: always
# The maximum count that we allow socket prrocess to crash. If this count is
# reached, we won't use networking over socket process.
- name: network.max_socket_process_failed_count
......
......@@ -9,6 +9,7 @@
#include "mozilla/ClearOnShutdown.h"
#include "mozilla/Sprintf.h"
#include "mozilla/StaticPrefs_network.h"
#include "mozilla/Unused.h"
#include "nsHttp.h"
......@@ -22,6 +23,7 @@
#include "nsCRT.h"
#include "nsICryptoHash.h"
#include "nsComponentManagerUtils.h"
#include "pk11pub.h"
constexpr uint16_t DigestLength(uint16_t aAlgorithm) {
if (aAlgorithm & (ALGO_SHA256 | ALGO_SHA256_SESS)) {
......@@ -321,9 +323,13 @@ nsHttpDigestAuth::GenerateCredentials(
// returned Authentication-Info header). also used for session info.
//
nsAutoCString cnonce;
static const char hexChar[] = "0123456789abcdef";
for (int i = 0; i < 16; ++i) {
cnonce.Append(hexChar[(int)(15.0 * rand() / (RAND_MAX + 1.0))]);
nsTArray<uint8_t> cnonceBuf;
cnonceBuf.SetLength(StaticPrefs::network_http_digest_auth_cnonce_length() /
2);
PK11_GenerateRandom(reinterpret_cast<unsigned char*>(cnonceBuf.Elements()),
cnonceBuf.Length());
for (auto byte : cnonceBuf) {
cnonce.AppendPrintf("%02x", byte);
}
LOG((" cnonce=%s\n", cnonce.get()));
......
......@@ -414,28 +414,28 @@ nsresult nsDocumentOpenInfo::DispatchContent(nsIRequest* request) {
NS_ASSERTION(!m_targetStreamListener,
"If we found a listener, why are we not using it?");
if (mFlags & nsIURILoader::DONT_RETARGET) {
LOG(
(" External handling forced or (listener not interested and no "
"stream converter exists), and retargeting disallowed -> aborting"));
return NS_ERROR_WONT_HANDLE_CONTENT;
}
// Before dispatching to the external helper app service, check for an HTTP
// error page. If we got one, we don't want to handle it with a helper app,
// really.
// The WPT a-download-click-404.html requires us to silently handle this
// without displaying an error page, so we just return early here.
// See bug 1604308 for discussion around what the ideal behaviour is.
nsCOMPtr<nsIHttpChannel> httpChannel(do_QueryInterface(request));
if (httpChannel) {
bool requestSucceeded;
rv = httpChannel->GetRequestSucceeded(&requestSucceeded);
if (NS_FAILED(rv) || !requestSucceeded) {
return NS_OK;
LOG(
(" Returning NS_ERROR_FILE_NOT_FOUND from "
"nsDocumentOpenInfo::DispatchContent due to failed HTTP response"));
return NS_ERROR_FILE_NOT_FOUND;
}
}
if (mFlags & nsIURILoader::DONT_RETARGET) {
LOG(
(" External handling forced or (listener not interested and no "
"stream converter exists), and retargeting disallowed -> aborting"));
return NS_ERROR_WONT_HANDLE_CONTENT;
}
// Fifth step:
//
// All attempts to dispatch this content have failed. Just pass it off to
......