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

Side by Side Diff: net/base/mime_sniffer.cc

Issue 826973002: replace COMPILE_ASSERT with static_assert in net/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: apply fixups Created 5 years, 11 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
« no previous file with comments | « no previous file | net/base/network_change_notifier.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Detecting mime types is a tricky business because we need to balance 5 // Detecting mime types is a tricky business because we need to balance
6 // compatibility concerns with security issues. Here is a survey of how other 6 // compatibility concerns with security issues. Here is a survey of how other
7 // browsers behave and then a description of how we intend to behave. 7 // browsers behave and then a description of how we intend to behave.
8 // 8 //
9 // HTML payload, no Content-Type header: 9 // HTML payload, no Content-Type header:
10 // * IE 7: Render as HTML 10 // * IE 7: Render as HTML
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 size_t magic_len; 115 size_t magic_len;
116 bool is_string; 116 bool is_string;
117 const char* mask; // if set, must have same length as |magic| 117 const char* mask; // if set, must have same length as |magic|
118 }; 118 };
119 119
120 #define MAGIC_NUMBER(mime_type, magic) \ 120 #define MAGIC_NUMBER(mime_type, magic) \
121 { (mime_type), (magic), sizeof(magic)-1, false, NULL }, 121 { (mime_type), (magic), sizeof(magic)-1, false, NULL },
122 122
123 template <int MagicSize, int MaskSize> 123 template <int MagicSize, int MaskSize>
124 class VerifySizes { 124 class VerifySizes {
125 COMPILE_ASSERT(MagicSize == MaskSize, sizes_must_be_equal); 125 static_assert(MagicSize == MaskSize, "sizes must be equal");
126
126 public: 127 public:
127 enum { SIZES = MagicSize }; 128 enum { SIZES = MagicSize };
128 }; 129 };
129 130
130 #define verified_sizeof(magic, mask) \ 131 #define verified_sizeof(magic, mask) \
131 VerifySizes<sizeof(magic), sizeof(mask)>::SIZES 132 VerifySizes<sizeof(magic), sizeof(mask)>::SIZES
132 133
133 #define MAGIC_MASK(mime_type, magic, mask) \ 134 #define MAGIC_MASK(mime_type, magic, mask) \
134 { (mime_type), (magic), verified_sizeof(magic, mask)-1, false, (mask) }, 135 { (mime_type), (magic), verified_sizeof(magic, mask)-1, false, (mask) },
135 136
(...skipping 827 matching lines...) Expand 10 before | Expand all | Expand 10 after
963 // First check the extra table. 964 // First check the extra table.
964 if (CheckForMagicNumbers(content, size, kExtraMagicNumbers, 965 if (CheckForMagicNumbers(content, size, kExtraMagicNumbers,
965 arraysize(kExtraMagicNumbers), NULL, result)) 966 arraysize(kExtraMagicNumbers), NULL, result))
966 return true; 967 return true;
967 // Finally check the original table. 968 // Finally check the original table.
968 return CheckForMagicNumbers(content, size, kMagicNumbers, 969 return CheckForMagicNumbers(content, size, kMagicNumbers,
969 arraysize(kMagicNumbers), NULL, result); 970 arraysize(kMagicNumbers), NULL, result);
970 } 971 }
971 972
972 } // namespace net 973 } // namespace net
OLDNEW
« no previous file with comments | « no previous file | net/base/network_change_notifier.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698