OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef NET_BASE_MIME_UTIL_H__ | 5 #ifndef NET_BASE_MIME_UTIL_H__ |
6 #define NET_BASE_MIME_UTIL_H__ | 6 #define NET_BASE_MIME_UTIL_H__ |
7 | 7 |
8 // This file defines MIME utility functions. All of them assume the MIME type | 8 // This file defines MIME utility functions. All of them assume the MIME type |
9 // to be of the format specified by rfc2045. According to it, MIME types are | 9 // to be of the format specified by rfc2045. According to it, MIME types are |
10 // case strongly insensitive except parameter values, which may or may not be | 10 // case strongly insensitive except parameter values, which may or may not be |
11 // case sensitive. | 11 // case sensitive. |
12 // | 12 // |
13 // These utilities perform a *case-sensitive* matching for parameter values, | 13 // These utilities perform a *case-sensitive* matching for parameter values, |
14 // which may produce some false negatives. Except that, matching is | 14 // which may produce some false negatives. Except that, matching is |
15 // case-insensitive. | 15 // case-insensitive. |
16 // | 16 // |
17 // All constants in mime_util.cc must be written in lower case, except parameter | 17 // All constants in mime_util.cc must be written in lower case, except parameter |
18 // values, which can be any case. | 18 // values, which can be any case. |
19 | 19 |
20 #include <string> | 20 #include <string> |
21 #include <vector> | 21 #include <vector> |
22 | 22 |
| 23 #include "base/callback.h" |
23 #include "base/files/file_path.h" | 24 #include "base/files/file_path.h" |
24 #include "net/base/net_export.h" | 25 #include "net/base/net_export.h" |
25 | 26 |
26 namespace net { | 27 namespace net { |
27 | 28 |
28 // Get the mime type (if any) that is associated with the given file extension. | 29 // Get the mime type (if any) that is associated with the given file extension. |
29 // Returns true if a corresponding mime type exists. | 30 // Returns true if a corresponding mime type exists. |
30 NET_EXPORT bool GetMimeTypeFromExtension(const base::FilePath::StringType& ext, | 31 NET_EXPORT bool GetMimeTypeFromExtension(const base::FilePath::StringType& ext, |
31 std::string* mime_type); | 32 std::string* mime_type); |
32 | 33 |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 | 87 |
87 // Parses a codec string, populating |codecs_out| with the prefix of each codec | 88 // Parses a codec string, populating |codecs_out| with the prefix of each codec |
88 // in the string |codecs_in|. For example, passed "aaa.b.c,dd.eee", if | 89 // in the string |codecs_in|. For example, passed "aaa.b.c,dd.eee", if |
89 // |strip| == true |codecs_out| will contain {"aaa", "dd"}, if |strip| == false | 90 // |strip| == true |codecs_out| will contain {"aaa", "dd"}, if |strip| == false |
90 // |codecs_out| will contain {"aaa.b.c", "dd.eee"}. | 91 // |codecs_out| will contain {"aaa.b.c", "dd.eee"}. |
91 // See http://www.ietf.org/rfc/rfc4281.txt. | 92 // See http://www.ietf.org/rfc/rfc4281.txt. |
92 NET_EXPORT void ParseCodecString(const std::string& codecs, | 93 NET_EXPORT void ParseCodecString(const std::string& codecs, |
93 std::vector<std::string>* codecs_out, | 94 std::vector<std::string>* codecs_out, |
94 bool strip); | 95 bool strip); |
95 | 96 |
| 97 // Returns true if the given |codec_id|, identified by a codec id string |
| 98 // described in RFC 6381, is supported. Returns false if the codec id is not |
| 99 // recognized or if that codec is not supported. |
| 100 NET_EXPORT bool IsCodecSupported(const std::string& codec_id); |
| 101 |
| 102 // The default implementation of IsCodecSupported, it can be overridden by |
| 103 // providing a custom callback via SetIsCodecSupportedCB. |
| 104 NET_EXPORT bool DefaultIsCodecSupported(const std::string& codec_id); |
| 105 |
| 106 // Provides a custom, platform-specific implementation of IsCodecSupported. |
| 107 typedef base::Callback<bool(const std::string&)> IsCodecSupportedCB; |
| 108 NET_EXPORT void SetIsCodecSupportedCB( |
| 109 const IsCodecSupportedCB& is_codec_supported_cb); |
| 110 |
96 // Check to see if a particular MIME type is in our list which only supports a | 111 // Check to see if a particular MIME type is in our list which only supports a |
97 // certain subset of codecs. | 112 // certain subset of codecs. |
98 NET_EXPORT bool IsStrictMediaMimeType(const std::string& mime_type); | 113 NET_EXPORT bool IsStrictMediaMimeType(const std::string& mime_type); |
99 | 114 |
100 // Indicates that the MIME type and (possible codec string) are supported by the | 115 // Indicates that the MIME type and (possible codec string) are supported by the |
101 // underlying platform. | 116 // underlying platform. |
102 enum SupportsType { | 117 enum SupportsType { |
103 // The underlying platform is known not to support the given MIME type and | 118 // The underlying platform is known not to support the given MIME type and |
104 // codec combination. | 119 // codec combination. |
105 IsNotSupported, | 120 IsNotSupported, |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 std::string* post_data); | 177 std::string* post_data); |
163 | 178 |
164 // Adds the final delimiter to a multi-part upload request. | 179 // Adds the final delimiter to a multi-part upload request. |
165 NET_EXPORT void AddMultipartFinalDelimiterForUpload( | 180 NET_EXPORT void AddMultipartFinalDelimiterForUpload( |
166 const std::string& mime_boundary, | 181 const std::string& mime_boundary, |
167 std::string* post_data); | 182 std::string* post_data); |
168 | 183 |
169 } // namespace net | 184 } // namespace net |
170 | 185 |
171 #endif // NET_BASE_MIME_UTIL_H__ | 186 #endif // NET_BASE_MIME_UTIL_H__ |
OLD | NEW |