Page Speed Optimization Libraries
1.2.24.1
|
00001 /* 00002 * Copyright 2010 Google Inc. 00003 * 00004 * Licensed under the Apache License, Version 2.0 (the "License"); 00005 * you may not use this file except in compliance with the License. 00006 * You may obtain a copy of the License at 00007 * 00008 * http:///www.apache.org/licenses/LICENSE-2.0 00009 * 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an "AS IS" BASIS, 00012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 00015 */ 00016 00020 00021 #ifndef NET_INSTAWEB_HTTP_PUBLIC_CONTENT_TYPE_H_ 00022 #define NET_INSTAWEB_HTTP_PUBLIC_CONTENT_TYPE_H_ 00023 00024 #include "net/instaweb/util/public/string.h" 00025 #include "net/instaweb/util/public/string_util.h" 00026 00027 namespace net_instaweb { 00028 00029 struct ContentType { 00030 public: 00032 enum Type { 00033 kHtml, 00034 kXhtml, 00035 kCeHtml, 00036 kJavascript, 00037 kCss, 00038 kText, 00039 kXml, 00040 kPng, 00041 kGif, 00042 kJpeg, 00043 kSwf, 00044 kWebp, 00045 kJson, 00046 kPdf, 00047 kVideo, 00048 kOther, 00049 }; 00050 00054 static int MaxProducedExtensionLength(); 00055 00056 const char* mime_type() const { return mime_type_; } 00058 const char* file_extension() const { return file_extension_; } 00059 Type type() const { return type_; } 00060 00063 bool IsHtmlLike() const; 00064 00067 bool IsXmlLike() const; 00068 00070 bool IsFlash() const; 00071 00073 bool IsImage() const; 00074 00076 bool IsVideo() const; 00077 00081 const char* mime_type_; 00082 const char* file_extension_; 00083 Type type_; 00084 }; 00085 00087 extern const ContentType& kContentTypeHtml; 00088 extern const ContentType& kContentTypeXhtml; 00089 extern const ContentType& kContentTypeCeHtml; 00091 extern const ContentType& kContentTypeJavascript; 00092 extern const ContentType& kContentTypeCss; 00093 extern const ContentType& kContentTypeText; 00094 extern const ContentType& kContentTypeXml; 00095 extern const ContentType& kContentTypeJson; 00097 extern const ContentType& kContentTypePng; 00098 extern const ContentType& kContentTypeGif; 00099 extern const ContentType& kContentTypeJpeg; 00100 extern const ContentType& kContentTypeSwf; 00101 extern const ContentType& kContentTypeWebp; 00103 extern const ContentType& kContentTypePdf; 00104 00107 const ContentType* NameExtensionToContentType(const StringPiece& name); 00108 const ContentType* MimeTypeToContentType(const StringPiece& mime_type); 00109 00115 bool ParseContentType(const StringPiece& content_type_str, 00116 GoogleString* mime_type, 00117 GoogleString* charset); 00118 00119 } 00120 00121 #endif ///< NET_INSTAWEB_HTTP_PUBLIC_CONTENT_TYPE_H_