Bug 1394313 - replace use of nsAutoPtr with UniquePtr in MediaDecoderOwner.h.
MozReview-Commit-ID: 49lyvMzg7oY
--- a/dom/html/HTMLMediaElement.cpp
+++ b/dom/html/HTMLMediaElement.cpp
@@ -5310,25 +5310,26 @@ void HTMLMediaElement::ProcessMediaFragm
}
if (parser.HasStartTime()) {
SetCurrentTime(parser.GetStartTime());
mFragmentStart = parser.GetStartTime();
}
}
-void HTMLMediaElement::MetadataLoaded(const MediaInfo* aInfo,
- nsAutoPtr<const MetadataTags> aTags)
+void
+HTMLMediaElement::MetadataLoaded(const MediaInfo* aInfo,
+ UniquePtr<const MetadataTags> aTags)
{
MOZ_ASSERT(NS_IsMainThread());
SetMediaInfo(*aInfo);
mIsEncrypted = aInfo->IsEncrypted() || mPendingEncryptedInitData.IsEncrypted();
- mTags = aTags.forget();
+ mTags = Move(aTags);
mLoadedDataFired = false;
ChangeReadyState(nsIDOMHTMLMediaElement::HAVE_METADATA);
DispatchAsyncEvent(NS_LITERAL_STRING("durationchange"));
if (IsVideo() && HasVideo()) {
DispatchAsyncEvent(NS_LITERAL_STRING("resize"));
}
NS_ASSERTION(!HasVideo() ||
@@ -5731,17 +5732,17 @@ HTMLMediaElement::UpdateReadyStateIntern
// This means we have all metadata needed to change ready state.
MediaInfo mediaInfo = mMediaInfo;
if (hasAudioTracks) {
mediaInfo.EnableAudio();
}
if (hasVideoTracks) {
mediaInfo.EnableVideo();
}
- MetadataLoaded(&mediaInfo, nsAutoPtr<const MetadataTags>(nullptr));
+ MetadataLoaded(&mediaInfo, nullptr);
}
if (mMediaSource) {
// readyState has changed, assuming it's following the pending mediasource
// operations. Notify the Mediasource that the operations have completed.
mMediaSource->CompletePendingTransactions();
}
--- a/dom/html/HTMLMediaElement.h
+++ b/dom/html/HTMLMediaElement.h
@@ -164,18 +164,19 @@ public:
* Call this to reevaluate whether we should start/stop due to our owner
* document being active, inactive, visible or hidden.
*/
virtual void NotifyOwnerDocumentActivityChanged();
// Called by the video decoder object, on the main thread,
// when it has read the metadata containing video dimensions,
// etc.
- virtual void MetadataLoaded(const MediaInfo* aInfo,
- nsAutoPtr<const MetadataTags> aTags) final override;
+ virtual void MetadataLoaded(
+ const MediaInfo* aInfo,
+ UniquePtr<const MetadataTags> aTags) final override;
// Called by the decoder object, on the main thread,
// when it has read the first frame of the video or audio.
virtual void FirstFrameLoaded() final override;
// Called by the video decoder object, on the main thread,
// when the resource has a network error during loading.
virtual void NetworkError() final override;
@@ -1447,17 +1448,17 @@ protected:
// Denotes the waiting state of a load algorithm instance. When the load
// algorithm is waiting for a source element child to be added, this is set
// to WAITING_FOR_SOURCE, otherwise it's NOT_WAITING.
LoadAlgorithmState mLoadWaitStatus;
// Current audio volume
double mVolume;
- nsAutoPtr<const MetadataTags> mTags;
+ UniquePtr<const MetadataTags> mTags;
// URI of the resource we're attempting to load. This stores the value we
// return in the currentSrc attribute. Use GetCurrentSrc() to access the
// currentSrc attribute.
// This is always the original URL we're trying to load --- before
// redirects etc.
nsCOMPtr<nsIURI> mLoadingSrc;
--- a/dom/media/MediaDecoder.cpp
+++ b/dom/media/MediaDecoder.cpp
@@ -729,18 +729,17 @@ MediaDecoder::MetadataLoaded(UniquePtr<M
mMediaSeekableOnlyInBufferedRanges = aInfo->mMediaSeekableOnlyInBufferedRanges;
mInfo = aInfo.release();
GetOwner()->ConstructMediaTracks(mInfo);
// Make sure the element and the frame (if any) are told about
// our new size.
if (aEventVisibility != MediaDecoderEventVisibility::Suppressed) {
mFiredMetadataLoaded = true;
- GetOwner()->MetadataLoaded(
- mInfo, nsAutoPtr<const MetadataTags>(aTags.release()));
+ GetOwner()->MetadataLoaded(mInfo, Move(aTags));
}
// Invalidate() will end up calling GetOwner()->UpdateMediaSize with the last
// dimensions retrieved from the video frame container. The video frame
// container contains more up to date dimensions than aInfo.
// So we call Invalidate() after calling GetOwner()->MetadataLoaded to ensure
// the media element has the latest dimensions.
Invalidate();
--- a/dom/media/MediaDecoderOwner.h
+++ b/dom/media/MediaDecoderOwner.h
@@ -1,18 +1,18 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:set ts=2 sw=2 sts=2 et cindent: */
/* 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/. */
#ifndef MediaDecoderOwner_h_
#define MediaDecoderOwner_h_
+#include "mozilla/UniquePtr.h"
#include "MediaInfo.h"
-#include "nsAutoPtr.h"
namespace mozilla {
class AbstractThread;
class GMPCrashHelper;
class VideoFrameContainer;
class MediaInfo;
class MediaResult;
@@ -54,17 +54,17 @@ public:
// Return true if decoding should be paused
virtual bool GetPaused() = 0;
// Called by the video decoder object, on the main thread,
// when it has read the metadata containing video dimensions,
// etc.
// Must take ownership of MetadataTags aTags argument.
virtual void MetadataLoaded(const MediaInfo* aInfo,
- nsAutoPtr<const MetadataTags> aTags) = 0;
+ UniquePtr<const MetadataTags> aTags) = 0;
// Called by the decoder object, on the main thread,
// when it has read the first frame of the video or audio.
virtual void FirstFrameLoaded() = 0;
// Called by the decoder object, on the main thread,
// when the resource has a network error during loading.
// The decoder owner should call Shutdown() on the decoder and drop the
--- a/dom/media/gtest/MockMediaDecoderOwner.h
+++ b/dom/media/gtest/MockMediaDecoderOwner.h
@@ -2,32 +2,31 @@
* 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/. */
#ifndef MOCK_MEDIA_DECODER_OWNER_H_
#define MOCK_MEDIA_DECODER_OWNER_H_
#include "MediaDecoderOwner.h"
#include "mozilla/AbstractThread.h"
-#include "nsAutoPtr.h"
namespace mozilla
{
class MockMediaDecoderOwner : public MediaDecoderOwner
{
public:
nsresult DispatchAsyncEvent(const nsAString& aName) override
{
return NS_OK;
}
void FireTimeUpdate(bool aPeriodic) override {}
bool GetPaused() override { return false; }
void MetadataLoaded(const MediaInfo* aInfo,
- nsAutoPtr<const MetadataTags> aTags) override
+ UniquePtr<const MetadataTags> aTags) override
{
}
void NetworkError() override {}
void DecodeError(const MediaResult& aError) override {}
bool HasError() const override { return false; }
void LoadAborted() override {}
void PlaybackEnded() override {}
void SeekStarted() override {}