Include all dupe types (event when value is zero) in scan stats.
[chromium-blink-merge.git] / net / http / http_content_disposition.h
blobc96ba6186034b558a1c0d20104396290df7f6507
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
3 // found in the LICENSE file.
5 #ifndef NET_HTTP_HTTP_CONTENT_DISPOSITION_H_
6 #define NET_HTTP_HTTP_CONTENT_DISPOSITION_H_
8 #include <string>
10 #include "base/basictypes.h"
11 #include "net/base/net_export.h"
13 namespace net {
15 class NET_EXPORT HttpContentDisposition {
16 public:
17 enum Type {
18 INLINE,
19 ATTACHMENT,
22 // Properties of the Content-Disposition header. These flags are used to
23 // report download metrics in UMA. This enum isn't directly used in UMA but
24 // mapped to another one for binary compatiblity; ie. changes are OK.
25 enum ParseResultFlags {
26 INVALID = 0,
28 // A valid disposition-type is present.
29 HAS_DISPOSITION_TYPE = 1 << 0,
31 // The disposition-type is not 'inline' or 'attachment'.
32 HAS_UNKNOWN_DISPOSITION_TYPE = 1 << 1,
34 // Has a valid non-empty 'filename' attribute.
35 HAS_FILENAME = 1 << 2,
37 // Has a valid non-empty 'filename*' attribute.
38 HAS_EXT_FILENAME = 1 << 3,
40 // The following fields are properties of the 'filename' attribute:
42 // Quoted-string contains non-ASCII characters.
43 HAS_NON_ASCII_STRINGS = 1 << 4,
45 // Quoted-string contains percent-encoding.
46 HAS_PERCENT_ENCODED_STRINGS = 1 << 5,
48 // Quoted-string contains RFC 2047 encoded words.
49 HAS_RFC2047_ENCODED_STRINGS = 1 << 6
52 HttpContentDisposition(const std::string& header,
53 const std::string& referrer_charset);
54 ~HttpContentDisposition();
56 bool is_attachment() const { return type() == ATTACHMENT; }
58 Type type() const { return type_; }
59 const std::string& filename() const { return filename_; }
61 // A combination of ParseResultFlags values.
62 int parse_result_flags() const { return parse_result_flags_; }
64 private:
65 void Parse(const std::string& header, const std::string& referrer_charset);
66 std::string::const_iterator ConsumeDispositionType(
67 std::string::const_iterator begin, std::string::const_iterator end);
69 Type type_;
70 std::string filename_;
71 int parse_result_flags_;
73 DISALLOW_COPY_AND_ASSIGN(HttpContentDisposition);
76 } // namespace net
78 #endif // NET_HTTP_HTTP_CONTENT_DISPOSITION_H_