Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(418)

Side by Side Diff: third_party/WebKit/Source/platform/network/ParsedContentType.h

Issue 2708523003: Make ParsedContentType more conformant to the spec (Closed)
Patch Set: fix Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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.
kinuko 2017/02/21 11:43:02 maybe add a link to the CL that changed default pa
yhirano 2017/02/22 05:17:03 Done.
51 51 enum class Mode {
52 explicit ParsedContentType(const String&); 52 Normal,
53 Relaxed,
54 };
55 ParsedContentType(const String&, Mode = Mode::Normal);
kinuko 2017/02/21 11:43:02 nit: still need explicit
yhirano 2017/02/22 05:17:03 Done.
53 56
54 String mimeType() const { return m_mimeType; } 57 String mimeType() const { return m_mimeType; }
55 String charset() const; 58 String charset() const;
56 59
57 // Note that in the case of multiple values for the same name, the last value 60 // Note that in the case of multiple values for the same name, the last value
58 // is returned. 61 // is returned.
59 String parameterValueForName(const String&) const; 62 String parameterValueForName(const String&) const;
60 size_t parameterCount() const; 63 size_t parameterCount() const;
61 64
62 bool isValid() const { return m_isValid; } 65 bool isValid() const { return m_isValid; }
63 66
64 private: 67 private:
65 bool parse(const String&); 68 bool parse(const String&);
66 69
70 const Mode m_mode;
67 bool m_isValid; 71 bool m_isValid;
72
68 typedef HashMap<String, String> KeyValuePairs; 73 typedef HashMap<String, String> KeyValuePairs;
69 KeyValuePairs m_parameters; 74 KeyValuePairs m_parameters;
70 String m_mimeType; 75 String m_mimeType;
71 }; 76 };
72 77
73 } // namespace blink 78 } // namespace blink
74 79
75 #endif 80 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698