dom/media/MediaContentType.cpp
author Gerald Squelart <gsquelart@mozilla.com>
Thu, 01 Dec 2016 13:05:45 +1100
changeset 329181 644f206d06d6d2c01bac8c87a6e275817a3651b3
parent 329173 c01ee23545a0e616583a5ca7d068d5ad8f6eaa6c
child 329190 c316c8d24d32836a198286faa93e5a5c8990d0e6
permissions -rw-r--r--
Bug 1329568 - MediaExtendedMIMEType - r=jya This patch factors out all data handling of MIME strings from MediaContentType to MediaExtendedMIMEType. MediaExtendedMIMEType is pretty much a copy of the old MediaContentType, as the functionality was fine (but will be modified in upcoming patches). MediaContentType then just delegates the work to its embedded MediaExtendedMIMEType field. The main difference is that the default constructor and Populate() method have been replaced with a single constructor that takes all the arguments at once. MozReview-Commit-ID: GBAgPDT2DUW

/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* 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/. */

#include "MediaContentType.h"

#include "nsContentTypeParser.h"

namespace mozilla {

Maybe<MediaContentType>
MakeMediaContentType(const nsAString& aType)
{
  Maybe<MediaExtendedMIMEType> mime = MakeMediaExtendedMIMEType(aType);
  if (mime) {
    return Some(MediaContentType(Move(*mime)));
  }
  return Nothing();
}

Maybe<MediaContentType>
MakeMediaContentType(const nsACString& aType)
{
  return MakeMediaContentType(NS_ConvertUTF8toUTF16(aType));
}

Maybe<MediaContentType>
MakeMediaContentType(const char* aType)
{
  if (!aType) {
    return Nothing();
  }
  return MakeMediaContentType(nsDependentCString(aType));
}

} // namespace mozilla