OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 Google Inc. All rights reserved. |
3 * Copyright (C) 2012 Intel Corporation. All rights reserved. | 3 * Copyright (C) 2012 Intel Corporation. All rights reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions are | 6 * modification, are permitted provided that the following conditions are |
7 * met: | 7 * met: |
8 * | 8 * |
9 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
(...skipping 28 matching lines...) Expand all Loading... |
39 | 39 |
40 namespace blink { | 40 namespace blink { |
41 | 41 |
42 // ParsedContentType parses the constructor argument as specified in RFC2045 | 42 // ParsedContentType parses the constructor argument as specified in RFC2045 |
43 // and stores the result. | 43 // and stores the result. |
44 // FIXME: add support for comments. | 44 // FIXME: add support for comments. |
45 class PLATFORM_EXPORT ParsedContentType final { | 45 class PLATFORM_EXPORT ParsedContentType final { |
46 STACK_ALLOCATED(); | 46 STACK_ALLOCATED(); |
47 | 47 |
48 public: | 48 public: |
49 // <index, length> | 49 // When |Relaxed| is specified, the parser parses parameter values in a sloppy |
50 using SubstringRange = std::pair<unsigned, unsigned>; | 50 // manner, i.e., only ';' and '"' are treated as special characters. |
51 | 51 // See https://chromiumcodereview.appspot.com/23043002. |
52 explicit ParsedContentType(const String&); | 52 enum class Mode { |
| 53 Normal, |
| 54 Relaxed, |
| 55 }; |
| 56 explicit ParsedContentType(const String&, Mode = Mode::Normal); |
53 | 57 |
54 String mimeType() const { return m_mimeType; } | 58 String mimeType() const { return m_mimeType; } |
55 String charset() const; | 59 String charset() const; |
56 | 60 |
57 // Note that in the case of multiple values for the same name, the last value | 61 // Note that in the case of multiple values for the same name, the last value |
58 // is returned. | 62 // is returned. |
59 String parameterValueForName(const String&) const; | 63 String parameterValueForName(const String&) const; |
60 size_t parameterCount() const; | 64 size_t parameterCount() const; |
61 | 65 |
62 bool isValid() const { return m_isValid; } | 66 bool isValid() const { return m_isValid; } |
63 | 67 |
64 private: | 68 private: |
65 bool parse(const String&); | 69 bool parse(const String&); |
66 | 70 |
| 71 const Mode m_mode; |
67 bool m_isValid; | 72 bool m_isValid; |
| 73 |
68 typedef HashMap<String, String> KeyValuePairs; | 74 typedef HashMap<String, String> KeyValuePairs; |
69 KeyValuePairs m_parameters; | 75 KeyValuePairs m_parameters; |
70 String m_mimeType; | 76 String m_mimeType; |
71 }; | 77 }; |
72 | 78 |
73 } // namespace blink | 79 } // namespace blink |
74 | 80 |
75 #endif | 81 #endif |
OLD | NEW |