OLD | NEW |
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 #include "extensions/browser/api/declarative_webrequest/request_stage.h" | 5 #include "extensions/browser/api/declarative_webrequest/request_stage.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 | 8 |
9 namespace extensions { | 9 namespace extensions { |
10 | 10 |
11 const unsigned int kActiveStages = ON_BEFORE_REQUEST | | 11 const unsigned int kActiveStages = ON_BEFORE_REQUEST | |
12 ON_BEFORE_SEND_HEADERS | | 12 ON_BEFORE_SEND_HEADERS | |
13 ON_HEADERS_RECEIVED | | 13 ON_HEADERS_RECEIVED | |
14 ON_AUTH_REQUIRED; | 14 ON_AUTH_REQUIRED; |
15 | 15 |
16 // HighestBit<n> computes the highest bit of |n| in compile time, provided that | 16 // HighestBit<n> computes the highest bit of |n| in compile time, provided that |
17 // |n| is a positive compile-time constant. | 17 // |n| is a positive compile-time constant. |
18 template <long unsigned int n> | 18 template <long unsigned int n> |
19 struct HighestBit { | 19 struct HighestBit { |
20 COMPILE_ASSERT(n > 0, argument_is_not_a_positive_compile_time_constant); | 20 static_assert(n > 0, "argument is not a positive compile time constant"); |
21 enum { VALUE = HighestBit<(n >> 1)>::VALUE << 1 }; | 21 enum { VALUE = HighestBit<(n >> 1)>::VALUE << 1 }; |
22 }; | 22 }; |
23 template <> | 23 template <> |
24 struct HighestBit<1> { | 24 struct HighestBit<1> { |
25 enum { VALUE = 1 }; | 25 enum { VALUE = 1 }; |
26 }; | 26 }; |
27 | 27 |
28 const unsigned int kLastActiveStage = HighestBit<kActiveStages>::VALUE; | 28 const unsigned int kLastActiveStage = HighestBit<kActiveStages>::VALUE; |
29 | 29 |
30 } // namespace extensions | 30 } // namespace extensions |
OLD | NEW |