Bug 1329568 - Media...Type::SizeOf... methods - r=jya,njn

When replacing strings with MediaContentType objects, some classes will want to
know about their size.

MozReview-Commit-ID: LNdaaUdJac3

--HG--
extra : rebase_source : 334bdca4a9b7a5db455bb731c495fa7a96b5b03c
This commit is contained in:
Gerald Squelart 2016-12-22 11:54:56 +11:00
Родитель 3a78522186
Коммит 8f52cbdabb
4 изменённых файлов: 34 добавлений и 0 удалений

Просмотреть файл

@ -10,6 +10,12 @@
namespace mozilla { namespace mozilla {
size_t
MediaContentType::SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const
{
return mExtendedMIMEType.SizeOfExcludingThis(aMallocSizeOf);
}
Maybe<MediaContentType> Maybe<MediaContentType>
MakeMediaContentType(const nsAString& aType) MakeMediaContentType(const nsAString& aType)
{ {

Просмотреть файл

@ -35,6 +35,8 @@ public:
const MediaMIMEType& Type() const { return mExtendedMIMEType.Type(); } const MediaMIMEType& Type() const { return mExtendedMIMEType.Type(); }
const MediaExtendedMIMEType& ExtendedType() const { return mExtendedMIMEType; } const MediaExtendedMIMEType& ExtendedType() const { return mExtendedMIMEType; }
size_t SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
private: private:
MediaExtendedMIMEType mExtendedMIMEType; MediaExtendedMIMEType mExtendedMIMEType;
}; };

Просмотреть файл

@ -38,6 +38,12 @@ MediaMIMEType::HasVideoMajorType() const
return StartsWith(mMIMEType, "video/"); return StartsWith(mMIMEType, "video/");
} }
size_t
MediaMIMEType::SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const
{
return mMIMEType.SizeOfExcludingThisIfUnshared(aMallocSizeOf);
}
MediaMIMEType::MediaMIMEType(const nsACString& aType) MediaMIMEType::MediaMIMEType(const nsACString& aType)
: mMIMEType(aType) : mMIMEType(aType)
{ {
@ -101,6 +107,13 @@ MediaCodecs::ContainsAll(const MediaCodecs& aCodecs) const
return true; return true;
} }
size_t
MediaCodecs::SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const
{
return mCodecs.SizeOfExcludingThisIfUnshared(aMallocSizeOf);
}
static int32_t static int32_t
GetParameterAsNumber(const nsContentTypeParser& aParser, GetParameterAsNumber(const nsContentTypeParser& aParser,
const char* aParameter, const char* aParameter,
@ -175,6 +188,13 @@ MakeMediaExtendedMIMEType(const nsAString& aType)
framerate, bitrate)); framerate, bitrate));
} }
size_t
MediaExtendedMIMEType::SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const
{
return mMIMEType.SizeOfExcludingThis(aMallocSizeOf)
+ mCodecs.SizeOfExcludingThis(aMallocSizeOf);
}
Maybe<MediaExtendedMIMEType> Maybe<MediaExtendedMIMEType>
MakeMediaExtendedMIMEType(const nsACString& aType) MakeMediaExtendedMIMEType(const nsACString& aType)
{ {

Просмотреть файл

@ -87,6 +87,8 @@ public:
// (e.g., "video/webm" could contain a vorbis audio track.) // (e.g., "video/webm" could contain a vorbis audio track.)
bool HasVideoMajorType() const; bool HasVideoMajorType() const;
size_t SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
private: private:
friend Maybe<MediaMIMEType> MakeMediaMIMEType(const nsAString& aType); friend Maybe<MediaMIMEType> MakeMediaMIMEType(const nsAString& aType);
friend class MediaExtendedMIMEType; friend class MediaExtendedMIMEType;
@ -133,6 +135,8 @@ public:
bool Contains(const nsAString& aCodec) const; bool Contains(const nsAString& aCodec) const;
bool ContainsAll(const MediaCodecs& aCodecs) const; bool ContainsAll(const MediaCodecs& aCodecs) const;
size_t SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
private: private:
// UTF16 comma-separated list of codecs. // UTF16 comma-separated list of codecs.
// See http://www.rfc-editor.org/rfc/rfc4281.txt for the description // See http://www.rfc-editor.org/rfc/rfc4281.txt for the description
@ -163,6 +167,8 @@ public:
Maybe<int32_t> GetFramerate() const { return GetMaybeNumber(mFramerate); } Maybe<int32_t> GetFramerate() const { return GetMaybeNumber(mFramerate); }
Maybe<int32_t> GetBitrate() const { return GetMaybeNumber(mBitrate); } Maybe<int32_t> GetBitrate() const { return GetMaybeNumber(mBitrate); }
size_t SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
private: private:
friend Maybe<MediaExtendedMIMEType> MakeMediaExtendedMIMEType(const nsAString& aType); friend Maybe<MediaExtendedMIMEType> MakeMediaExtendedMIMEType(const nsAString& aType);
MediaExtendedMIMEType(const nsACString& aMIMEType, MediaExtendedMIMEType(const nsACString& aMIMEType,