Skip to content

Commit

Permalink
Bug 1143478 - Rename mozilla::Pair to CompactPair. r=froydnj
Browse files Browse the repository at this point in the history
Differential Revision: https://phabricator.services.mozilla.com/D64511

--HG--
rename : mfbt/Pair.h => mfbt/CompactPair.h
extra : moz-landing-system : lando
  • Loading branch information
Chris Fronk committed Mar 11, 2020
1 parent d2ae8db commit a27e438
Show file tree
Hide file tree
Showing 71 changed files with 568 additions and 548 deletions.
1 change: 0 additions & 1 deletion dom/base/Document.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#include "mozilla/EventStates.h" // for EventStates
#include "mozilla/FlushType.h" // for enum
#include "mozilla/MozPromise.h" // for MozPromise
#include "mozilla/Pair.h" // for Pair
#include "mozilla/Saturate.h" // for SaturateUint32
#include "nsAutoPtr.h" // for member
#include "nsCOMArray.h" // for member
Expand Down
1 change: 0 additions & 1 deletion dom/base/PlacesObservers.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
#include "mozilla/dom/PlacesObserversBinding.h"
#include "mozilla/dom/PlacesEvent.h"
#include "mozilla/ErrorResult.h"
#include "mozilla/Pair.h"
#include "mozilla/places/INativePlacesEventCallback.h"
#include "nsIWeakReferenceUtils.h"

Expand Down
1 change: 0 additions & 1 deletion dom/base/PlacesWeakCallbackWrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

#include "mozilla/dom/PlacesObserversBinding.h"
#include "mozilla/ErrorResult.h"
#include "mozilla/Pair.h"
#include "nsWrapperCache.h"

namespace mozilla {
Expand Down
17 changes: 9 additions & 8 deletions dom/canvas/ProducerConsumerQueue.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

#include <atomic>
#include <tuple>
#include <utility>
#include <vector>
#include "mozilla/ipc/SharedMemoryBasic.h"
#include "mozilla/Assertions.h"
Expand Down Expand Up @@ -1984,23 +1985,23 @@ struct PcqParamTraits<Maybe<Variant<T, Ts...>>> {
// ---------------------------------------------------------------

template <typename TypeA, typename TypeB>
struct PcqParamTraits<Pair<TypeA, TypeB>> {
using ParamType = Pair<TypeA, TypeB>;
struct PcqParamTraits<std::pair<TypeA, TypeB>> {
using ParamType = std::pair<TypeA, TypeB>;

static PcqStatus Write(ProducerView& aProducerView, const ParamType& aArg) {
aProducerView.WriteParam(aArg.first());
return aProducerView.WriteParam(aArg.second());
aProducerView.WriteParam(aArg.first);
return aProducerView.WriteParam(aArg.second);
}

static PcqStatus Read(ConsumerView& aConsumerView, ParamType* aArg) {
aConsumerView.ReadParam(aArg ? (&aArg->first()) : nullptr);
return aConsumerView.ReadParam(aArg ? (&aArg->second()) : nullptr);
aConsumerView.ReadParam(aArg ? (&aArg->first) : nullptr);
return aConsumerView.ReadParam(aArg ? (&aArg->second) : nullptr);
}

template <typename View>
static size_t MinSize(View& aView, const ParamType* aArg) {
return aView.MinSizeParam(aArg ? aArg->first() : nullptr) +
aView.MinSizeParam(aArg ? aArg->second() : nullptr);
return aView.MinSizeParam(aArg ? aArg->first : nullptr) +
aView.MinSizeParam(aArg ? aArg->second : nullptr);
}
};

Expand Down
12 changes: 6 additions & 6 deletions dom/html/HTMLMediaElement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4004,7 +4004,7 @@ HTMLMediaElement::HTMLMediaElement(
mTracksCaptured(nullptr, "HTMLMediaElement::mTracksCaptured"),
mErrorSink(new ErrorSink(this)),
mAudioChannelWrapper(new AudioChannelAgentCallback(this)),
mSink(MakePair(nsString(), RefPtr<AudioDeviceInfo>())),
mSink(std::pair(nsString(), RefPtr<AudioDeviceInfo>())),
mShowPoster(IsVideo()) {
MOZ_ASSERT(mMainThreadEventTarget);
MOZ_ASSERT(mAbstractMainThread);
Expand Down Expand Up @@ -4997,9 +4997,9 @@ nsresult HTMLMediaElement::FinishDecoderSetup(MediaDecoder* aDecoder) {
NotifyDecoderPrincipalChanged();

// Set sink device if we have one. Otherwise the default is used.
if (mSink.second()) {
if (mSink.second) {
mDecoder
->SetSink(mSink.second())
->SetSink(mSink.second)
#ifdef DEBUG
->Then(mAbstractMainThread, __func__,
[](const GenericPromise::ResolveOrRejectValue& aValue) {
Expand Down Expand Up @@ -5077,7 +5077,7 @@ void HTMLMediaElement::UpdateSrcMediaStreamPlaying(uint32_t aFlags) {
mMediaStreamRenderer->Start();
}

if (mSink.second()) {
if (mSink.second) {
NS_WARNING(
"setSinkId() when playing a MediaStream is not supported yet and "
"will be ignored");
Expand Down Expand Up @@ -7547,7 +7547,7 @@ already_AddRefed<Promise> HTMLMediaElement::SetSinkId(const nsAString& aSinkId,
return nullptr;
}

if (mSink.first().Equals(aSinkId)) {
if (mSink.first.Equals(aSinkId)) {
promise->MaybeResolveWithUndefined();
return promise.forget();
}
Expand Down Expand Up @@ -7588,7 +7588,7 @@ already_AddRefed<Promise> HTMLMediaElement::SetSinkId(const nsAString& aSinkId,
[promise, self = RefPtr<HTMLMediaElement>(this),
sinkId](const SinkInfoPromise::ResolveOrRejectValue& aValue) {
if (aValue.IsResolve()) {
self->mSink = MakePair(sinkId, aValue.ResolveValue());
self->mSink = std::pair(sinkId, aValue.ResolveValue());
promise->MaybeResolveWithUndefined();
} else {
switch (aValue.RejectValue()) {
Expand Down
6 changes: 4 additions & 2 deletions dom/html/HTMLMediaElement.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
#include "nsStubMutationObserver.h"
#include "MediaSegment.h" // for PrincipalHandle, GraphTime

#include <utility>

// X.h on Linux #defines CurrentTime as 0L, so we have to #undef it here.
#ifdef CurrentTime
# undef CurrentTime
Expand Down Expand Up @@ -735,7 +737,7 @@ class HTMLMediaElement : public nsGenericHTMLElement,
// empty and the default device is being used.
void GetSinkId(nsString& aSinkId) {
MOZ_ASSERT(NS_IsMainThread());
aSinkId = mSink.first();
aSinkId = mSink.first;
}

// This is used to notify MediaElementAudioSourceNode that media element is
Expand Down Expand Up @@ -1902,7 +1904,7 @@ class HTMLMediaElement : public nsGenericHTMLElement,
// unplugged. It can be set to ("", nullptr). It follows the spec attribute:
// https://w3c.github.io/mediacapture-output/#htmlmediaelement-extensions
// Read/Write from the main thread only.
Pair<nsString, RefPtr<AudioDeviceInfo>> mSink;
std::pair<nsString, RefPtr<AudioDeviceInfo>> mSink;

// This flag is used to control when the user agent is to show a poster frame
// for a video element instead of showing the video contents.
Expand Down
4 changes: 2 additions & 2 deletions dom/ipc/ContentParent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5474,11 +5474,11 @@ nsresult ContentParent::AboutToLoadHttpFtpDocumentForChild(
nsresult ContentParent::TransmitPermissionsForPrincipal(
nsIPrincipal* aPrincipal) {
// Create the key, and send it down to the content process.
nsTArray<Pair<nsCString, nsCString>> pairs =
nsTArray<std::pair<nsCString, nsCString>> pairs =
nsPermissionManager::GetAllKeysForPrincipal(aPrincipal);
MOZ_ASSERT(pairs.Length() >= 1);
for (auto& pair : pairs) {
EnsurePermissionsByKey(pair.first(), pair.second());
EnsurePermissionsByKey(pair.first, pair.second);
}

return NS_OK;
Expand Down
15 changes: 8 additions & 7 deletions dom/media/VideoOutput.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class VideoOutput : public DirectMediaTrackListener {
TimeStamp now = TimeStamp::Now();
size_t nrChunksInPast = 0;
for (const auto& idChunkPair : mFrames) {
const VideoChunk& chunk = idChunkPair.second();
const VideoChunk& chunk = idChunkPair.second;
if (chunk.mTimeStamp > now) {
break;
}
Expand Down Expand Up @@ -72,8 +72,8 @@ class VideoOutput : public DirectMediaTrackListener {
PrincipalHandle lastPrincipalHandle = PRINCIPAL_HANDLE_NONE;

for (const auto& idChunkPair : mFrames) {
ImageContainer::FrameID frameId = idChunkPair.first();
const VideoChunk& chunk = idChunkPair.second();
ImageContainer::FrameID frameId = idChunkPair.first;
const VideoChunk& chunk = idChunkPair.second;
const VideoFrame& frame = chunk.mFrame;
Image* image = frame.GetImage();
if (frame.GetForceBlack() || !mEnabled) {
Expand Down Expand Up @@ -119,7 +119,7 @@ class VideoOutput : public DirectMediaTrackListener {
}

mVideoFrameContainer->SetCurrentFrames(
mFrames[0].second().mFrame.GetIntrinsicSize(), images);
mFrames[0].second.mFrame.GetIntrinsicSize(), images);
mMainThread->Dispatch(NewRunnableMethod("VideoFrameContainer::Invalidate",
mVideoFrameContainer,
&VideoFrameContainer::Invalidate));
Expand All @@ -142,7 +142,8 @@ class VideoOutput : public DirectMediaTrackListener {
// future. If this happens, we clear the buffered frames and start over.
mFrames.ClearAndRetainStorage();
}
mFrames.AppendElement(MakePair(mVideoFrameContainer->NewFrameID(), *i));
mFrames.AppendElement(
std::make_pair(mVideoFrameContainer->NewFrameID(), *i));
mLastFrameTime = i->mTimeStamp;
}

Expand Down Expand Up @@ -187,7 +188,7 @@ class VideoOutput : public DirectMediaTrackListener {
// Since mEnabled will affect whether frames are real, or black, we assign
// new FrameIDs whenever this changes.
for (auto& idChunkPair : mFrames) {
idChunkPair.first() = mVideoFrameContainer->NewFrameID();
idChunkPair.first = mVideoFrameContainer->NewFrameID();
}
SendFramesEnsureLocked();
}
Expand All @@ -200,7 +201,7 @@ class VideoOutput : public DirectMediaTrackListener {
bool mEnabled = true;
// This array is accessed from both the direct video thread, and the graph
// thread. Protected by mMutex.
nsTArray<Pair<ImageContainer::FrameID, VideoChunk>> mFrames;
nsTArray<std::pair<ImageContainer::FrameID, VideoChunk>> mFrames;
const RefPtr<VideoFrameContainer> mVideoFrameContainer;
const RefPtr<AbstractThread> mMainThread;
const layers::ImageContainer::ProducerID mProducerID =
Expand Down
8 changes: 4 additions & 4 deletions dom/media/gmp/ChromiumCDMAdapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ static void InitializeHooks();
#endif

ChromiumCDMAdapter::ChromiumCDMAdapter(
nsTArray<Pair<nsCString, nsCString>>&& aHostPathPairs) {
nsTArray<std::pair<nsCString, nsCString>>&& aHostPathPairs) {
#ifdef XP_WIN
InitializeHooks();
#endif
Expand Down Expand Up @@ -282,10 +282,10 @@ cdm::PlatformFile HostFile::TakePlatformFile() {
}

void ChromiumCDMAdapter::PopulateHostFiles(
nsTArray<Pair<nsCString, nsCString>>&& aHostPathPairs) {
nsTArray<std::pair<nsCString, nsCString>>&& aHostPathPairs) {
for (const auto& pair : aHostPathPairs) {
mHostFiles.AppendElement(HostFileData(mozilla::HostFile(pair.first()),
mozilla::HostFile(pair.second())));
mHostFiles.AppendElement(HostFileData(mozilla::HostFile(pair.first),
mozilla::HostFile(pair.second)));
}
}

Expand Down
8 changes: 5 additions & 3 deletions dom/media/gmp/ChromiumCDMAdapter.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
#include "nsTArray.h"
#include "content_decryption_module_ext.h"
#include "nsString.h"
#include "mozilla/Pair.h"

#include <utility>

struct GMPPlatformAPI;

Expand Down Expand Up @@ -54,7 +55,7 @@ struct HostFileData {
class ChromiumCDMAdapter : public gmp::GMPAdapter {
public:
explicit ChromiumCDMAdapter(
nsTArray<Pair<nsCString, nsCString>>&& aHostPathPairs);
nsTArray<std::pair<nsCString, nsCString>>&& aHostPathPairs);

void SetAdaptee(PRLibrary* aLib) override;

Expand All @@ -68,7 +69,8 @@ class ChromiumCDMAdapter : public gmp::GMPAdapter {
int32_t aHostVersion);

private:
void PopulateHostFiles(nsTArray<Pair<nsCString, nsCString>>&& aHostFilePaths);
void PopulateHostFiles(
nsTArray<std::pair<nsCString, nsCString>>&& aHostFilePaths);

PRLibrary* mLib = nullptr;
nsTArray<HostFileData> mHostFiles;
Expand Down
18 changes: 10 additions & 8 deletions dom/media/gmp/GMPChild.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ static bool GetSigPath(const int aRelativeLayers,
#endif

static bool AppendHostPath(nsCOMPtr<nsIFile>& aFile,
nsTArray<Pair<nsCString, nsCString>>& aPaths) {
nsTArray<std::pair<nsCString, nsCString>>& aPaths) {
nsString str;
if (!FileExists(aFile) || !ResolveLinks(aFile) ||
NS_FAILED(aFile->GetPath(str))) {
Expand Down Expand Up @@ -410,19 +410,21 @@ static bool AppendHostPath(nsCOMPtr<nsIFile>& aFile,
sigFilePath =
nsCString(NS_ConvertUTF16toUTF8(str) + NS_LITERAL_CSTRING(".sig"));
#endif
aPaths.AppendElement(MakePair(std::move(filePath), std::move(sigFilePath)));
aPaths.AppendElement(
std::make_pair(std::move(filePath), std::move(sigFilePath)));
return true;
}

nsTArray<Pair<nsCString, nsCString>> GMPChild::MakeCDMHostVerificationPaths() {
nsTArray<std::pair<nsCString, nsCString>>
GMPChild::MakeCDMHostVerificationPaths() {
// Record the file path and its sig file path.
nsTArray<Pair<nsCString, nsCString>> paths;
nsTArray<std::pair<nsCString, nsCString>> paths;
// Plugin binary path.
nsCOMPtr<nsIFile> path;
nsString str;
if (GetPluginFile(mPluginPath, path) && FileExists(path) &&
ResolveLinks(path) && NS_SUCCEEDED(path->GetPath(str))) {
paths.AppendElement(MakePair(
paths.AppendElement(std::make_pair(
nsCString(NS_ConvertUTF16toUTF8(str)),
nsCString(NS_ConvertUTF16toUTF8(str) + NS_LITERAL_CSTRING(".sig"))));
}
Expand Down Expand Up @@ -474,14 +476,14 @@ nsTArray<Pair<nsCString, nsCString>> GMPChild::MakeCDMHostVerificationPaths() {
return paths;
}

static nsCString ToCString(const nsTArray<Pair<nsCString, nsCString>>& aPairs) {
static nsCString ToCString(
const nsTArray<std::pair<nsCString, nsCString>>& aPairs) {
nsCString result;
for (const auto& p : aPairs) {
if (!result.IsEmpty()) {
result.AppendLiteral(",");
}
result.Append(
nsPrintfCString("(%s,%s)", p.first().get(), p.second().get()));
result.Append(nsPrintfCString("(%s,%s)", p.first.get(), p.second.get()));
}
return result;
}
Expand Down
3 changes: 1 addition & 2 deletions dom/media/gmp/GMPChild.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#define GMPChild_h_

#include "mozilla/gmp/PGMPChild.h"
#include "mozilla/Pair.h"
#include "GMPTimerChild.h"
#include "GMPStorageChild.h"
#include "GMPLoader.h"
Expand Down Expand Up @@ -68,7 +67,7 @@ class GMPChild : public PGMPChild {
GMPErr GetAPI(const char* aAPIName, void* aHostAPI, void** aPluginAPI,
uint32_t aDecryptorId = 0);

nsTArray<Pair<nsCString, nsCString>> MakeCDMHostVerificationPaths();
nsTArray<std::pair<nsCString, nsCString>> MakeCDMHostVerificationPaths();

nsTArray<UniquePtr<GMPContentChild>> mGMPContentChildren;

Expand Down
Loading

0 comments on commit a27e438

Please sign in to comment.