Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef ParsedParameterizedContentHeaderField_h | |
| 6 #define ParsedParameterizedContentHeaderField_h | |
|
kinuko
2017/05/22 07:39:45
Things look inconsistent across here, class-level
e_hakkinen
2017/05/22 08:11:59
Yep, old class name from before refactoring. Fixed
| |
| 7 | |
| 8 #include "platform/PlatformExport.h" | |
| 9 #include "platform/wtf/Allocator.h" | |
| 10 #include "platform/wtf/HashMap.h" | |
| 11 #include "platform/wtf/text/StringHash.h" | |
| 12 | |
| 13 namespace blink { | |
| 14 | |
| 15 class ContentHeaderFieldInput; | |
| 16 | |
| 17 // ParsedParameterizedContentHeaderField parses the constructor argument as | |
| 18 // specified in RFC2045 and stores the result. | |
| 19 // FIXME: add support for comments. | |
| 20 class PLATFORM_EXPORT ParsedContentHeaderFieldParameters final { | |
| 21 STACK_ALLOCATED(); | |
| 22 | |
| 23 public: | |
| 24 // When |Relaxed| is specified, the parser parses parameter values in a sloppy | |
| 25 // manner, i.e., only ';' and '"' are treated as special characters. | |
| 26 // See https://chromiumcodereview.appspot.com/23043002. | |
| 27 // When |Strict| is specified, the parser does not allow multiple values | |
| 28 // for the same parameter. Some RFCs based on RFC2045 (e.g. RFC6838) note that | |
| 29 // "It is an error for a specific parameter to be specified more than once." | |
| 30 enum class Mode { | |
| 31 kNormal, | |
| 32 kRelaxed, | |
| 33 kStrict, | |
| 34 }; | |
| 35 | |
| 36 ParsedContentHeaderFieldParameters(); | |
| 37 | |
| 38 // Note that in the case of multiple values for the same name, the last value | |
| 39 // is returned. | |
| 40 String ParameterValueForName(const String&) const; | |
| 41 size_t ParameterCount() const; | |
| 42 | |
| 43 bool IsValid() const { return is_valid_; } | |
| 44 | |
| 45 void ParseParameters(ContentHeaderFieldInput, Mode); | |
| 46 | |
| 47 static ParsedContentHeaderFieldParameters CreateForTesting( | |
| 48 const String&, | |
| 49 Mode = Mode::kNormal); | |
| 50 | |
| 51 private: | |
| 52 typedef HashMap<String, String> KeyValuePairs; | |
| 53 bool is_valid_; | |
| 54 KeyValuePairs parameters_; | |
| 55 }; | |
| 56 | |
| 57 } // namespace blink | |
| 58 | |
| 59 #endif | |
| OLD | NEW |