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