Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(167)

Unified Diff: net/base/mime_util.cc

Issue 647883002: git cl format the final third of the net/base directory (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: net/base/mime_util.cc
diff --git a/net/base/mime_util.cc b/net/base/mime_util.cc
index 27f3c7049ad2d8a6db333606a550ed28e2b17a03..5a99383bfbfd496756f1e3236a1b3d57c03d671a 100644
--- a/net/base/mime_util.cc
+++ b/net/base/mime_util.cc
@@ -33,15 +33,15 @@ struct MediaType {
};
static const MediaType kIanaMediaTypes[] = {
- { "application", "application/" },
- { "audio", "audio/" },
- { "example", "example/" },
- { "image", "image/" },
- { "message", "message/" },
- { "model", "model/" },
- { "multipart", "multipart/" },
- { "text", "text/" },
- { "video", "video/" },
+ {"application", "application/"},
+ {"audio", "audio/"},
+ {"example", "example/"},
+ {"image", "image/"},
+ {"message", "message/"},
+ {"model", "model/"},
+ {"multipart", "multipart/"},
+ {"text", "text/"},
+ {"video", "video/"},
};
} // namespace
@@ -87,8 +87,8 @@ class MimeUtil : public PlatformMimeUtil {
bool IsSupportedMimeType(const std::string& mime_type) const;
- bool MatchesMimeType(const std::string &mime_type_pattern,
- const std::string &mime_type) const;
+ bool MatchesMimeType(const std::string& mime_type_pattern,
+ const std::string& mime_type) const;
bool ParseMimeTypeWithoutParameter(const std::string& type_string,
std::string* top_level_type,
@@ -131,9 +131,8 @@ class MimeUtil : public PlatformMimeUtil {
// at least one codec ID in |codecs| is ambiguous but all the codecs
// are supported by the platform. IsNotSupported is returned if at
// least one codec ID is not supported by the platform.
- SupportsType AreSupportedCodecs(
- const CodecSet& supported_codecs,
- const std::vector<std::string>& codecs) const;
+ SupportsType AreSupportedCodecs(const CodecSet& supported_codecs,
+ const std::vector<std::string>& codecs) const;
// For faster lookup, keep hash sets.
void InitializeMimeTypeMaps();
@@ -199,52 +198,51 @@ struct MimeInfo {
};
static const MimeInfo primary_mappings[] = {
- { "text/html", "html,htm,shtml,shtm" },
- { "text/css", "css" },
- { "text/xml", "xml" },
- { "image/gif", "gif" },
- { "image/jpeg", "jpeg,jpg" },
- { "image/webp", "webp" },
- { "image/png", "png" },
- { "video/mp4", "mp4,m4v" },
- { "audio/x-m4a", "m4a" },
- { "audio/mp3", "mp3" },
- { "video/ogg", "ogv,ogm" },
- { "audio/ogg", "ogg,oga,opus" },
- { "video/webm", "webm" },
- { "audio/webm", "webm" },
- { "audio/wav", "wav" },
- { "application/xhtml+xml", "xhtml,xht,xhtm" },
- { "application/x-chrome-extension", "crx" },
- { "multipart/related", "mhtml,mht" }
-};
+ {"text/html", "html,htm,shtml,shtm"},
+ {"text/css", "css"},
+ {"text/xml", "xml"},
+ {"image/gif", "gif"},
+ {"image/jpeg", "jpeg,jpg"},
+ {"image/webp", "webp"},
+ {"image/png", "png"},
+ {"video/mp4", "mp4,m4v"},
+ {"audio/x-m4a", "m4a"},
+ {"audio/mp3", "mp3"},
+ {"video/ogg", "ogv,ogm"},
+ {"audio/ogg", "ogg,oga,opus"},
+ {"video/webm", "webm"},
+ {"audio/webm", "webm"},
+ {"audio/wav", "wav"},
+ {"application/xhtml+xml", "xhtml,xht,xhtm"},
+ {"application/x-chrome-extension", "crx"},
+ {"multipart/related", "mhtml,mht"}};
static const MimeInfo secondary_mappings[] = {
- { "application/octet-stream", "exe,com,bin" },
- { "application/gzip", "gz" },
- { "application/pdf", "pdf" },
- { "application/postscript", "ps,eps,ai" },
- { "application/javascript", "js" },
- { "application/font-woff", "woff" },
- { "image/bmp", "bmp" },
- { "image/x-icon", "ico" },
- { "image/vnd.microsoft.icon", "ico" },
- { "image/jpeg", "jfif,pjpeg,pjp" },
- { "image/tiff", "tiff,tif" },
- { "image/x-xbitmap", "xbm" },
- { "image/svg+xml", "svg,svgz" },
- { "image/x-png", "png"},
- { "message/rfc822", "eml" },
- { "text/plain", "txt,text" },
- { "text/html", "ehtml" },
- { "application/rss+xml", "rss" },
- { "application/rdf+xml", "rdf" },
- { "text/xml", "xsl,xbl,xslt" },
- { "application/vnd.mozilla.xul+xml", "xul" },
- { "application/x-shockwave-flash", "swf,swl" },
- { "application/pkcs7-mime", "p7m,p7c,p7z" },
- { "application/pkcs7-signature", "p7s" },
- { "application/x-mpegurl", "m3u8" },
+ {"application/octet-stream", "exe,com,bin"},
+ {"application/gzip", "gz"},
+ {"application/pdf", "pdf"},
+ {"application/postscript", "ps,eps,ai"},
+ {"application/javascript", "js"},
+ {"application/font-woff", "woff"},
+ {"image/bmp", "bmp"},
+ {"image/x-icon", "ico"},
+ {"image/vnd.microsoft.icon", "ico"},
+ {"image/jpeg", "jfif,pjpeg,pjp"},
+ {"image/tiff", "tiff,tif"},
+ {"image/x-xbitmap", "xbm"},
+ {"image/svg+xml", "svg,svgz"},
+ {"image/x-png", "png"},
+ {"message/rfc822", "eml"},
+ {"text/plain", "txt,text"},
+ {"text/html", "ehtml"},
+ {"application/rss+xml", "rss"},
+ {"application/rdf+xml", "rdf"},
+ {"text/xml", "xsl,xbl,xslt"},
+ {"application/vnd.mozilla.xul+xml", "xul"},
+ {"application/x-shockwave-flash", "swf,swl"},
+ {"application/pkcs7-mime", "p7m,p7c,p7z"},
+ {"application/pkcs7-signature", "p7s"},
+ {"application/x-mpegurl", "m3u8"},
};
static const char* FindMimeType(const MimeInfo* mappings,
@@ -304,9 +302,8 @@ bool MimeUtil::GetMimeTypeFromExtensionHelper(
base::FilePath path_ext(ext);
const string ext_narrow_str = path_ext.AsUTF8Unsafe();
- const char* mime_type = FindMimeType(primary_mappings,
- arraysize(primary_mappings),
- ext_narrow_str.c_str());
+ const char* mime_type = FindMimeType(
+ primary_mappings, arraysize(primary_mappings), ext_narrow_str.c_str());
if (mime_type) {
*result = mime_type;
return true;
@@ -315,7 +312,8 @@ bool MimeUtil::GetMimeTypeFromExtensionHelper(
if (include_platform_types && GetPlatformMimeTypeFromExtension(ext, result))
return true;
- mime_type = FindMimeType(secondary_mappings, arraysize(secondary_mappings),
+ mime_type = FindMimeType(secondary_mappings,
+ arraysize(secondary_mappings),
ext_narrow_str.c_str());
if (mime_type) {
*result = mime_type;
@@ -328,61 +326,60 @@ bool MimeUtil::GetMimeTypeFromExtensionHelper(
// From WebKit's WebCore/platform/MIMETypeRegistry.cpp:
static const char* const supported_image_types[] = {
- "image/jpeg",
- "image/pjpeg",
- "image/jpg",
- "image/webp",
- "image/png",
- "image/gif",
- "image/bmp",
- "image/vnd.microsoft.icon", // ico
- "image/x-icon", // ico
- "image/x-xbitmap", // xbm
- "image/x-png"
-};
+ "image/jpeg",
+ "image/pjpeg",
+ "image/jpg",
+ "image/webp",
+ "image/png",
+ "image/gif",
+ "image/bmp",
+ "image/vnd.microsoft.icon", // ico
+ "image/x-icon", // ico
+ "image/x-xbitmap", // xbm
+ "image/x-png"};
// A list of media types: http://en.wikipedia.org/wiki/Internet_media_type
// A comprehensive mime type list: http://plugindoc.mozdev.org/winmime.php
// This set of codecs is supported by all variations of Chromium.
static const char* const common_media_types[] = {
- // Ogg.
- "audio/ogg",
- "application/ogg",
+ // Ogg.
+ "audio/ogg",
+ "application/ogg",
#if !defined(OS_ANDROID) // Android doesn't support Ogg Theora.
- "video/ogg",
+ "video/ogg",
#endif
- // WebM.
- "video/webm",
- "audio/webm",
+ // WebM.
+ "video/webm",
+ "audio/webm",
- // Wav.
- "audio/wav",
- "audio/x-wav",
+ // Wav.
+ "audio/wav",
+ "audio/x-wav",
#if defined(OS_ANDROID)
- // HLS. Supported by Android ICS and above.
- "application/vnd.apple.mpegurl",
- "application/x-mpegurl",
+ // HLS. Supported by Android ICS and above.
+ "application/vnd.apple.mpegurl",
+ "application/x-mpegurl",
#endif
};
// List of proprietary types only supported by Google Chrome.
static const char* const proprietary_media_types[] = {
- // MPEG-4.
- "video/mp4",
- "video/x-m4v",
- "audio/mp4",
- "audio/x-m4a",
+ // MPEG-4.
+ "video/mp4",
+ "video/x-m4v",
+ "audio/mp4",
+ "audio/x-m4a",
- // MP3.
- "audio/mp3",
- "audio/x-mp3",
- "audio/mpeg",
+ // MP3.
+ "audio/mp3",
+ "audio/x-mp3",
+ "audio/mpeg",
#if defined(ENABLE_MPEG2TS_STREAM_PARSER)
- // MPEG-2 TS.
- "video/mp2t",
+ // MPEG-2 TS.
+ "video/mp2t",
#endif
};
@@ -391,16 +388,17 @@ static const char* const proprietary_media_types[] = {
// - does not include types starting with "text/" (see
// IsSupportedNonImageMimeType())
static const char* const supported_non_image_types[] = {
- "image/svg+xml", // SVG is text-based XML, even though it has an image/ type
- "application/xml",
- "application/atom+xml",
- "application/rss+xml",
- "application/xhtml+xml",
- "application/json",
- "multipart/related", // For MHTML support.
- "multipart/x-mixed-replace"
- // Note: ADDING a new type here will probably render it AS HTML. This can
- // result in cross site scripting.
+ "image/svg+xml", // SVG is text-based XML, even though it has an image/
+ // type
+ "application/xml",
+ "application/atom+xml",
+ "application/rss+xml",
+ "application/xhtml+xml",
+ "application/json",
+ "multipart/related", // For MHTML support.
+ "multipart/x-mixed-replace"
+ // Note: ADDING a new type here will probably render it AS HTML. This can
+ // result in cross site scripting.
};
// Dictionary of cryptographic file mime types.
@@ -410,11 +408,10 @@ struct CertificateMimeTypeInfo {
};
static const CertificateMimeTypeInfo supported_certificate_types[] = {
- { "application/x-x509-user-cert",
- CERTIFICATE_MIME_TYPE_X509_USER_CERT },
+ {"application/x-x509-user-cert", CERTIFICATE_MIME_TYPE_X509_USER_CERT},
#if defined(OS_ANDROID)
- { "application/x-x509-ca-cert", CERTIFICATE_MIME_TYPE_X509_CA_CERT },
- { "application/x-pkcs12", CERTIFICATE_MIME_TYPE_PKCS12_ARCHIVE },
+ {"application/x-x509-ca-cert", CERTIFICATE_MIME_TYPE_X509_CA_CERT},
+ {"application/x-pkcs12", CERTIFICATE_MIME_TYPE_PKCS12_ARCHIVE},
#endif
};
@@ -422,25 +419,25 @@ static const CertificateMimeTypeInfo supported_certificate_types[] = {
// while they are technically text, it's very unlikely that a user expects to
// see them rendered in text form.
static const char* const unsupported_text_types[] = {
- "text/calendar",
- "text/x-calendar",
- "text/x-vcalendar",
- "text/vcalendar",
- "text/vcard",
- "text/x-vcard",
- "text/directory",
- "text/ldif",
- "text/qif",
- "text/x-qif",
- "text/x-csv",
- "text/x-vcf",
- "text/rtf",
- "text/comma-separated-values",
- "text/csv",
- "text/tab-separated-values",
- "text/tsv",
- "text/ofx", // http://crbug.com/162238
- "text/vnd.sun.j2me.app-descriptor" // http://crbug.com/176450
+ "text/calendar",
+ "text/x-calendar",
+ "text/x-vcalendar",
+ "text/vcalendar",
+ "text/vcard",
+ "text/x-vcard",
+ "text/directory",
+ "text/ldif",
+ "text/qif",
+ "text/x-qif",
+ "text/x-csv",
+ "text/x-vcf",
+ "text/rtf",
+ "text/comma-separated-values",
+ "text/csv",
+ "text/tab-separated-values",
+ "text/tsv",
+ "text/ofx", // http://crbug.com/162238
+ "text/vnd.sun.j2me.app-descriptor" // http://crbug.com/176450
};
// Mozilla 1.8 and WinIE 7 both accept text/javascript and text/ecmascript.
@@ -454,17 +451,16 @@ static const char* const unsupported_text_types[] = {
// We want to accept all the values that either of these browsers accept, but
// not other values.
static const char* const supported_javascript_types[] = {
- "text/javascript",
- "text/ecmascript",
- "application/javascript",
- "application/ecmascript",
- "application/x-javascript",
- "text/javascript1.1",
- "text/javascript1.2",
- "text/javascript1.3",
- "text/jscript",
- "text/livescript"
-};
+ "text/javascript",
+ "text/ecmascript",
+ "application/javascript",
+ "application/ecmascript",
+ "application/x-javascript",
+ "text/javascript1.1",
+ "text/javascript1.2",
+ "text/javascript1.3",
+ "text/jscript",
+ "text/livescript"};
#if defined(OS_ANDROID)
static bool IsCodecSupportedOnAndroid(MimeUtil::Codec codec) {
@@ -508,7 +504,7 @@ static bool IsCodecSupportedOnAndroid(MimeUtil::Codec codec) {
static bool IsMimeTypeSupportedOnAndroid(const std::string& mimeType) {
// HLS codecs are supported in ICS and above (API level 14)
if ((!mimeType.compare("application/vnd.apple.mpegurl") ||
- !mimeType.compare("application/x-mpegurl")) &&
+ !mimeType.compare("application/x-mpegurl")) &&
base::android::BuildInfo::GetInstance()->sdk_int() < 14) {
return false;
}
@@ -536,27 +532,26 @@ struct MediaFormatStrict {
static const char kMP4AudioCodecsExpression[] =
"mp4a.66,mp4a.67,mp4a.68,mp4a.69,mp4a.6B,mp4a.40.2,mp4a.40.5";
static const char kMP4VideoCodecsExpression[] =
- "avc1.42E00A,avc1.4D400A,avc1.64000A," \
+ "avc1.42E00A,avc1.4D400A,avc1.64000A,"
"mp4a.66,mp4a.67,mp4a.68,mp4a.69,mp4a.6B,mp4a.40.2,mp4a.40.5";
static const MediaFormatStrict format_codec_mappings[] = {
- { "video/webm", "opus,vorbis,vp8,vp8.0,vp9,vp9.0" },
- { "audio/webm", "opus,vorbis" },
- { "audio/wav", "1" },
- { "audio/x-wav", "1" },
- { "video/ogg", "opus,theora,vorbis" },
- { "audio/ogg", "opus,vorbis" },
- { "application/ogg", "opus,theora,vorbis" },
- { "audio/mpeg", "mp3" },
- { "audio/mp3", "" },
- { "audio/x-mp3", "" },
- { "audio/mp4", kMP4AudioCodecsExpression },
- { "audio/x-m4a", kMP4AudioCodecsExpression },
- { "video/mp4", kMP4VideoCodecsExpression },
- { "video/x-m4v", kMP4VideoCodecsExpression },
- { "application/x-mpegurl", kMP4VideoCodecsExpression },
- { "application/vnd.apple.mpegurl", kMP4VideoCodecsExpression }
-};
+ {"video/webm", "opus,vorbis,vp8,vp8.0,vp9,vp9.0"},
+ {"audio/webm", "opus,vorbis"},
+ {"audio/wav", "1"},
+ {"audio/x-wav", "1"},
+ {"video/ogg", "opus,theora,vorbis"},
+ {"audio/ogg", "opus,vorbis"},
+ {"application/ogg", "opus,theora,vorbis"},
+ {"audio/mpeg", "mp3"},
+ {"audio/mp3", ""},
+ {"audio/x-mp3", ""},
+ {"audio/mp4", kMP4AudioCodecsExpression},
+ {"audio/x-m4a", kMP4AudioCodecsExpression},
+ {"video/mp4", kMP4VideoCodecsExpression},
+ {"video/x-m4v", kMP4VideoCodecsExpression},
+ {"application/x-mpegurl", kMP4VideoCodecsExpression},
+ {"application/vnd.apple.mpegurl", kMP4VideoCodecsExpression}};
struct CodecIDMappings {
const char* const codec_id;
@@ -568,32 +563,31 @@ struct CodecIDMappings {
//
// The "mp4a" strings come from RFC 6381.
static const CodecIDMappings kUnambiguousCodecIDs[] = {
- { "1", MimeUtil::PCM }, // We only allow this for WAV so it isn't ambiguous.
- { "mp3", MimeUtil::MP3 },
- { "mp4a.66", MimeUtil::MPEG2_AAC_MAIN },
- { "mp4a.67", MimeUtil::MPEG2_AAC_LC },
- { "mp4a.68", MimeUtil::MPEG2_AAC_SSR },
- { "mp4a.69", MimeUtil::MP3 },
- { "mp4a.6B", MimeUtil::MP3 },
- { "mp4a.40.2", MimeUtil::MPEG4_AAC_LC },
- { "mp4a.40.5", MimeUtil::MPEG4_AAC_SBRv1 },
- { "vorbis", MimeUtil::VORBIS },
- { "opus", MimeUtil::OPUS },
- { "vp8", MimeUtil::VP8 },
- { "vp8.0", MimeUtil::VP8 },
- { "vp9", MimeUtil::VP9 },
- { "vp9.0", MimeUtil::VP9 },
- { "theora", MimeUtil::THEORA }
-};
+ {"1", MimeUtil::PCM}, // We only allow this for WAV so it isn't ambiguous.
+ {"mp3", MimeUtil::MP3},
+ {"mp4a.66", MimeUtil::MPEG2_AAC_MAIN},
+ {"mp4a.67", MimeUtil::MPEG2_AAC_LC},
+ {"mp4a.68", MimeUtil::MPEG2_AAC_SSR},
+ {"mp4a.69", MimeUtil::MP3},
+ {"mp4a.6B", MimeUtil::MP3},
+ {"mp4a.40.2", MimeUtil::MPEG4_AAC_LC},
+ {"mp4a.40.5", MimeUtil::MPEG4_AAC_SBRv1},
+ {"vorbis", MimeUtil::VORBIS},
+ {"opus", MimeUtil::OPUS},
+ {"vp8", MimeUtil::VP8},
+ {"vp8.0", MimeUtil::VP8},
+ {"vp9", MimeUtil::VP9},
+ {"vp9.0", MimeUtil::VP9},
+ {"theora", MimeUtil::THEORA}};
// List of codec IDs that are ambiguous and don't provide
// enough information to determine the codec and profile.
// The codec in these entries indicate the codec and profile
// we assume the user is trying to indicate.
static const CodecIDMappings kAmbiguousCodecIDs[] = {
- { "mp4a.40", MimeUtil::MPEG4_AAC_LC },
- { "avc1", MimeUtil::H264_BASELINE },
- { "avc3", MimeUtil::H264_BASELINE },
+ {"mp4a.40", MimeUtil::MPEG4_AAC_LC},
+ {"avc1", MimeUtil::H264_BASELINE},
+ {"avc3", MimeUtil::H264_BASELINE},
};
MimeUtil::MimeUtil() : allow_proprietary_codecs_(false) {
@@ -681,9 +675,8 @@ void MimeUtil::InitializeMimeTypeMaps() {
// Initialize the strict supported media types.
for (size_t i = 0; i < arraysize(format_codec_mappings); ++i) {
std::vector<std::string> mime_type_codecs;
- ParseCodecString(format_codec_mappings[i].codecs_list,
- &mime_type_codecs,
- false);
+ ParseCodecString(
+ format_codec_mappings[i].codecs_list, &mime_type_codecs, false);
CodecSet codecs;
for (size_t j = 0; j < mime_type_codecs.size(); ++j) {
@@ -708,10 +701,10 @@ bool MimeUtil::IsSupportedMediaMimeType(const std::string& mime_type) const {
bool MimeUtil::IsSupportedNonImageMimeType(const std::string& mime_type) const {
return non_image_map_.find(mime_type) != non_image_map_.end() ||
- (mime_type.compare(0, 5, "text/") == 0 &&
- !IsUnsupportedTextMimeType(mime_type)) ||
- (mime_type.compare(0, 12, "application/") == 0 &&
- MatchesMimeType("application/*+json", mime_type));
+ (mime_type.compare(0, 5, "text/") == 0 &&
+ !IsUnsupportedTextMimeType(mime_type)) ||
+ (mime_type.compare(0, 12, "application/") == 0 &&
+ MatchesMimeType("application/*+json", mime_type));
}
bool MimeUtil::IsUnsupportedTextMimeType(const std::string& mime_type) const {
@@ -742,18 +735,18 @@ bool MatchesMimeTypeParameters(const std::string& mime_type_pattern,
return false;
std::vector<std::string> pattern_parameters;
- base::SplitString(mime_type_pattern.substr(semicolon + 1),
- ';', &pattern_parameters);
+ base::SplitString(
+ mime_type_pattern.substr(semicolon + 1), ';', &pattern_parameters);
std::vector<std::string> test_parameters;
- base::SplitString(mime_type.substr(test_semicolon + 1),
- ';', &test_parameters);
+ base::SplitString(
+ mime_type.substr(test_semicolon + 1), ';', &test_parameters);
sort(pattern_parameters.begin(), pattern_parameters.end());
sort(test_parameters.begin(), test_parameters.end());
std::vector<std::string> difference =
- base::STLSetDifference<std::vector<std::string> >(pattern_parameters,
- test_parameters);
+ base::STLSetDifference<std::vector<std::string> >(pattern_parameters,
+ test_parameters);
return difference.size() == 0;
}
return true;
@@ -811,25 +804,23 @@ bool MimeUtil::MatchesMimeType(const std::string& mime_type_pattern,
// See http://www.iana.org/assignments/media-types/media-types.xhtml
static const char* legal_top_level_types[] = {
- "application",
- "audio",
- "example",
- "image",
- "message",
- "model",
- "multipart",
- "text",
- "video",
+ "application",
+ "audio",
+ "example",
+ "image",
+ "message",
+ "model",
+ "multipart",
+ "text",
+ "video",
};
-bool MimeUtil::ParseMimeTypeWithoutParameter(
- const std::string& type_string,
- std::string* top_level_type,
- std::string* subtype) const {
+bool MimeUtil::ParseMimeTypeWithoutParameter(const std::string& type_string,
+ std::string* top_level_type,
+ std::string* subtype) const {
std::vector<std::string> components;
base::SplitString(type_string, '/', &components);
- if (components.size() != 2 ||
- !HttpUtil::IsToken(components[0]) ||
+ if (components.size() != 2 || !HttpUtil::IsToken(components[0]) ||
!HttpUtil::IsToken(components[1]))
return false;
@@ -897,8 +888,9 @@ SupportsType MimeUtil::IsSupportedStrictMediaMimeType(
if (it_strict_map->second.empty()) {
// We get here if the mimetype does not expect a codecs parameter.
- return (codecs.empty() && IsDefaultCodecSupported(mime_type)) ?
- IsSupported : IsNotSupported;
+ return (codecs.empty() && IsDefaultCodecSupported(mime_type))
+ ? IsSupported
+ : IsNotSupported;
}
if (codecs.empty()) {
@@ -945,10 +937,8 @@ void MimeUtil::RemoveProprietaryMediaTypesAndCodecsForTests() {
// equal to the specified level."
static bool IsValidH264BaselineProfile(const std::string& profile_str) {
uint32 constraint_set_bits;
- if (profile_str.size() != 4 ||
- profile_str[0] != '4' ||
- profile_str[1] != '2' ||
- profile_str[3] != '0' ||
+ if (profile_str.size() != 4 || profile_str[0] != '4' ||
+ profile_str[1] != '2' || profile_str[3] != '0' ||
!base::HexStringToUInt(base::StringPiece(profile_str.c_str() + 2, 1),
&constraint_set_bits)) {
return false;
@@ -964,10 +954,8 @@ static bool IsValidH264Level(const std::string& level_str) {
// Valid levels taken from Table A-1 in ISO-14496-10.
// Essentially |level_str| is toHex(10 * level).
- return ((level >= 10 && level <= 13) ||
- (level >= 20 && level <= 22) ||
- (level >= 30 && level <= 32) ||
- (level >= 40 && level <= 42) ||
+ return ((level >= 10 && level <= 13) || (level >= 20 && level <= 22) ||
+ (level >= 30 && level <= 32) || (level >= 40 && level <= 42) ||
(level >= 50 && level <= 51));
}
@@ -985,9 +973,8 @@ static bool ParseH264CodecID(const std::string& codec_id,
MimeUtil::Codec* codec,
bool* is_ambiguous) {
// Make sure we have avc1.xxxxxx or avc3.xxxxxx
- if (codec_id.size() != 11 ||
- (!StartsWithASCII(codec_id, "avc1.", true) &&
- !StartsWithASCII(codec_id, "avc3.", true))) {
+ if (codec_id.size() != 11 || (!StartsWithASCII(codec_id, "avc1.", true) &&
+ !StartsWithASCII(codec_id, "avc3.", true))) {
return false;
}
@@ -1064,8 +1051,7 @@ bool MimeUtil::IsCodecProprietary(Codec codec) const {
bool MimeUtil::GetDefaultCodec(const std::string& mime_type,
Codec* default_codec) const {
- if (mime_type == "audio/mpeg" ||
- mime_type == "audio/mp3" ||
+ if (mime_type == "audio/mpeg" || mime_type == "audio/mp3" ||
mime_type == "audio/x-mp3") {
*default_codec = MimeUtil::MP3;
return true;
@@ -1074,7 +1060,6 @@ bool MimeUtil::GetDefaultCodec(const std::string& mime_type,
return false;
}
-
bool MimeUtil::IsDefaultCodecSupported(const std::string& mime_type) const {
Codec default_codec = Codec::INVALID_CODEC;
if (!GetDefaultCodec(mime_type, &default_codec))
@@ -1171,66 +1156,60 @@ namespace {
// From http://www.w3schools.com/media/media_mimeref.asp and
// http://plugindoc.mozdev.org/winmime.php
-static const char* const kStandardImageTypes[] = {
- "image/bmp",
- "image/cis-cod",
- "image/gif",
- "image/ief",
- "image/jpeg",
- "image/webp",
- "image/pict",
- "image/pipeg",
- "image/png",
- "image/svg+xml",
- "image/tiff",
- "image/vnd.microsoft.icon",
- "image/x-cmu-raster",
- "image/x-cmx",
- "image/x-icon",
- "image/x-portable-anymap",
- "image/x-portable-bitmap",
- "image/x-portable-graymap",
- "image/x-portable-pixmap",
- "image/x-rgb",
- "image/x-xbitmap",
- "image/x-xpixmap",
- "image/x-xwindowdump"
-};
-static const char* const kStandardAudioTypes[] = {
- "audio/aac",
- "audio/aiff",
- "audio/amr",
- "audio/basic",
- "audio/midi",
- "audio/mp3",
- "audio/mp4",
- "audio/mpeg",
- "audio/mpeg3",
- "audio/ogg",
- "audio/vorbis",
- "audio/wav",
- "audio/webm",
- "audio/x-m4a",
- "audio/x-ms-wma",
- "audio/vnd.rn-realaudio",
- "audio/vnd.wave"
-};
-static const char* const kStandardVideoTypes[] = {
- "video/avi",
- "video/divx",
- "video/flc",
- "video/mp4",
- "video/mpeg",
- "video/ogg",
- "video/quicktime",
- "video/sd-video",
- "video/webm",
- "video/x-dv",
- "video/x-m4v",
- "video/x-mpeg",
- "video/x-ms-asf",
- "video/x-ms-wmv"
-};
+static const char* const kStandardImageTypes[] = {"image/bmp",
+ "image/cis-cod",
+ "image/gif",
+ "image/ief",
+ "image/jpeg",
+ "image/webp",
+ "image/pict",
+ "image/pipeg",
+ "image/png",
+ "image/svg+xml",
+ "image/tiff",
+ "image/vnd.microsoft.icon",
+ "image/x-cmu-raster",
+ "image/x-cmx",
+ "image/x-icon",
+ "image/x-portable-anymap",
+ "image/x-portable-bitmap",
+ "image/x-portable-graymap",
+ "image/x-portable-pixmap",
+ "image/x-rgb",
+ "image/x-xbitmap",
+ "image/x-xpixmap",
+ "image/x-xwindowdump"};
+static const char* const kStandardAudioTypes[] = {"audio/aac",
+ "audio/aiff",
+ "audio/amr",
+ "audio/basic",
+ "audio/midi",
+ "audio/mp3",
+ "audio/mp4",
+ "audio/mpeg",
+ "audio/mpeg3",
+ "audio/ogg",
+ "audio/vorbis",
+ "audio/wav",
+ "audio/webm",
+ "audio/x-m4a",
+ "audio/x-ms-wma",
+ "audio/vnd.rn-realaudio",
+ "audio/vnd.wave"};
+static const char* const kStandardVideoTypes[] = {"video/avi",
+ "video/divx",
+ "video/flc",
+ "video/mp4",
+ "video/mpeg",
+ "video/ogg",
+ "video/quicktime",
+ "video/sd-video",
+ "video/webm",
+ "video/x-dv",
+ "video/x-m4v",
+ "video/x-mpeg",
+ "video/x-ms-asf",
+ "video/x-ms-wmv"};
struct StandardType {
const char* leading_mime_type;
@@ -1238,11 +1217,10 @@ struct StandardType {
size_t standard_types_len;
};
static const StandardType kStandardTypes[] = {
- { "image/", kStandardImageTypes, arraysize(kStandardImageTypes) },
- { "audio/", kStandardAudioTypes, arraysize(kStandardAudioTypes) },
- { "video/", kStandardVideoTypes, arraysize(kStandardVideoTypes) },
- { NULL, NULL, 0 }
-};
+ {"image/", kStandardImageTypes, arraysize(kStandardImageTypes)},
+ {"audio/", kStandardAudioTypes, arraysize(kStandardAudioTypes)},
+ {"video/", kStandardVideoTypes, arraysize(kStandardVideoTypes)},
+ {NULL, NULL, 0}};
void GetExtensionsFromHardCodedMappings(
const MimeInfo* mappings,
@@ -1292,13 +1270,14 @@ void GetExtensionsHelper(
// Note that the elements in the source set will be appended to the target
// vector.
-template<class T>
+template <class T>
void HashSetToVector(base::hash_set<T>* source, std::vector<T>* target) {
size_t old_target_size = target->size();
target->resize(old_target_size + source->size());
size_t i = 0;
for (typename base::hash_set<T>::iterator iter = source->begin();
- iter != source->end(); ++iter, ++i)
+ iter != source->end();
+ ++iter, ++i)
(*target)[old_target_size + i] = *iter;
}
}
@@ -1374,8 +1353,7 @@ CertificateMimeType GetCertificateMimeTypeForMimeType(
}
bool IsSupportedCertificateMimeType(const std::string& mime_type) {
- CertificateMimeType file_type =
- GetCertificateMimeTypeForMimeType(mime_type);
+ CertificateMimeType file_type = GetCertificateMimeTypeForMimeType(mime_type);
return file_type != CERTIFICATE_MIME_TYPE_UNKNOWN;
}
@@ -1388,8 +1366,8 @@ void AddMultipartValueForUpload(const std::string& value_name,
// First line is the boundary.
post_data->append("--" + mime_boundary + "\r\n");
// Next line is the Content-disposition.
- post_data->append("Content-Disposition: form-data; name=\"" +
- value_name + "\"\r\n");
+ post_data->append("Content-Disposition: form-data; name=\"" + value_name +
+ "\"\r\n");
if (!content_type.empty()) {
// If Content-type is specified, the next line is that.
post_data->append("Content-Type: " + content_type + "\r\n");

Powered by Google App Engine
This is Rietveld 408576698