Chromium Code Reviews| Index: third_party/WebKit/Source/platform/network/ParsedParameterizedContentHeaderField.h |
| diff --git a/third_party/WebKit/Source/platform/network/ParsedContentType.h b/third_party/WebKit/Source/platform/network/ParsedParameterizedContentHeaderField.h |
| similarity index 71% |
| copy from third_party/WebKit/Source/platform/network/ParsedContentType.h |
| copy to third_party/WebKit/Source/platform/network/ParsedParameterizedContentHeaderField.h |
| index a014b6df29e96afdd1f980bc9a05e4d54e79c728..45299d7aa789320052b786c553c0469cf16f9a1c 100644 |
| --- a/third_party/WebKit/Source/platform/network/ParsedContentType.h |
| +++ b/third_party/WebKit/Source/platform/network/ParsedParameterizedContentHeaderField.h |
| @@ -29,8 +29,8 @@ |
| * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| */ |
| -#ifndef ParsedContentType_h |
| -#define ParsedContentType_h |
| +#ifndef ParsedParameterizedContentHeaderField_h |
| +#define ParsedParameterizedContentHeaderField_h |
| #include "platform/PlatformExport.h" |
| #include "platform/wtf/Allocator.h" |
| @@ -39,10 +39,10 @@ |
| namespace blink { |
| -// ParsedContentType parses the constructor argument as specified in RFC2045 |
| -// and stores the result. |
| +// ParsedParameterizedContentHeaderField parses the constructor argument as |
| +// specified in RFC2045 and stores the result. |
| // FIXME: add support for comments. |
| -class PLATFORM_EXPORT ParsedContentType final { |
| +class PLATFORM_EXPORT ParsedParameterizedContentHeaderField { |
|
yhirano
2017/05/15 11:14:51
Please write tests.
e_hakkinen
2017/05/18 09:35:48
Done.
|
| STACK_ALLOCATED(); |
| public: |
| @@ -57,10 +57,11 @@ class PLATFORM_EXPORT ParsedContentType final { |
| kRelaxed, |
| kStrict, |
| }; |
| - explicit ParsedContentType(const String&, Mode = Mode::kNormal); |
| - String MimeType() const { return mime_type_; } |
| - String Charset() const; |
| + explicit ParsedParameterizedContentHeaderField(const String&, |
| + Mode = Mode::kNormal); |
| + |
| + String Type() const { return type_; } |
| // Note that in the case of multiple values for the same name, the last value |
| // is returned. |
| @@ -69,15 +70,38 @@ class PLATFORM_EXPORT ParsedContentType final { |
| bool IsValid() const { return is_valid_; } |
| + protected: |
| + class Input final { |
| + public: |
| + explicit Input(const String& header_field); |
| + |
| + bool Consume(char); |
| + bool ConsumeToken(Mode, StringView& output); |
| + bool ConsumeTokenOrQuotedString(Mode, String& output); |
| + unsigned Index() const { return index_; } |
| + bool IsConsumed() const { return index_ >= input_.length(); } |
| + void SkipSpaces(); |
| + |
| + private: |
| + bool ConsumeQuotedString(String& output); |
| + |
| + unsigned index_; |
| + String input_; |
|
horo
2017/05/15 05:57:54
nit: const String input_;
e_hakkinen
2017/05/18 09:35:48
Done.
|
| + }; |
| + |
| + ParsedParameterizedContentHeaderField(); |
| + |
| + bool ParseParameters(Input&, Mode); |
| + void SetType(const String& type) { type_ = type; } |
| + |
| private: |
| - bool Parse(const String&); |
| + bool Parse(const String&, Mode); |
| - const Mode mode_; |
| bool is_valid_; |
| typedef HashMap<String, String> KeyValuePairs; |
| KeyValuePairs parameters_; |
| - String mime_type_; |
| + String type_; |
| }; |
| } // namespace blink |