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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
94 | 95 |
95 // Parses a codec string, populating |codecs_out| with the prefix of each codec | 96 // Parses a codec string, populating |codecs_out| with the prefix of each codec |
96 // in the string |codecs_in|. For example, passed "aaa.b.c,dd.eee", if | 97 // in the string |codecs_in|. For example, passed "aaa.b.c,dd.eee", if |
97 // |strip| == true |codecs_out| will contain {"aaa", "dd"}, if |strip| == false | 98 // |strip| == true |codecs_out| will contain {"aaa", "dd"}, if |strip| == false |
98 // |codecs_out| will contain {"aaa.b.c", "dd.eee"}. | 99 // |codecs_out| will contain {"aaa.b.c", "dd.eee"}. |
99 // See http://www.ietf.org/rfc/rfc4281.txt. | 100 // See http://www.ietf.org/rfc/rfc4281.txt. |
100 NET_EXPORT void ParseCodecString(const std::string& codecs, | 101 NET_EXPORT void ParseCodecString(const std::string& codecs, |
101 std::vector<std::string>* codecs_out, | 102 std::vector<std::string>* codecs_out, |
102 bool strip); | 103 bool strip); |
103 | 104 |
105 // Returns true if the given |codec_id|, identified by a codec id string | |
106 // described in RFC 6381, is supported. Returns false if the codec id is not | |
107 // recognized or if that codec is not supported. | |
108 NET_EXPORT bool IsCodecSupported(const std::string& codec_id); | |
109 | |
110 // The default implementation of IsCodecSupported, it can be overridden by | |
111 // providing a custom callback via SetIsCodecSupportedCB. | |
112 NET_EXPORT bool DefaultIsCodecSupported(const std::string& codec_id); | |
113 | |
114 // Provides a custom, platform-specific implementation of IsCodecSupported. | |
115 typedef base::Callback<bool(const std::string&)> IsCodecSupportedCB; | |
116 NET_EXPORT void SetIsCodecSupportedCB(IsCodecSupportedCB is_codec_supported_cb); | |
Ryan Sleevi
2015/04/21 13:23:29
STYLE: Callbacks should *always* be passed as cons
servolk
2015/04/21 22:09:02
Changed to const-ref. Re typedef - I've posted my
| |
117 | |
104 // Check to see if a particular MIME type is in our list which only supports a | 118 // Check to see if a particular MIME type is in our list which only supports a |
105 // certain subset of codecs. | 119 // certain subset of codecs. |
106 NET_EXPORT bool IsStrictMediaMimeType(const std::string& mime_type); | 120 NET_EXPORT bool IsStrictMediaMimeType(const std::string& mime_type); |
107 | 121 |
108 // Indicates that the MIME type and (possible codec string) are supported by the | 122 // Indicates that the MIME type and (possible codec string) are supported by the |
109 // underlying platform. | 123 // underlying platform. |
110 enum SupportsType { | 124 enum SupportsType { |
111 // The underlying platform is known not to support the given MIME type and | 125 // The underlying platform is known not to support the given MIME type and |
112 // codec combination. | 126 // codec combination. |
113 IsNotSupported, | 127 IsNotSupported, |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
173 std::string* post_data); | 187 std::string* post_data); |
174 | 188 |
175 // Adds the final delimiter to a multi-part upload request. | 189 // Adds the final delimiter to a multi-part upload request. |
176 NET_EXPORT void AddMultipartFinalDelimiterForUpload( | 190 NET_EXPORT void AddMultipartFinalDelimiterForUpload( |
177 const std::string& mime_boundary, | 191 const std::string& mime_boundary, |
178 std::string* post_data); | 192 std::string* post_data); |
179 | 193 |
180 } // namespace net | 194 } // namespace net |
181 | 195 |
182 #endif // NET_BASE_MIME_UTIL_H__ | 196 #endif // NET_BASE_MIME_UTIL_H__ |
OLD | NEW |