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

Side by Side Diff: net/tools/transport_security_state_generator/bit_writer.cc

Issue 2660793002: Add transport security state generator tests. (Closed)
Patch Set: export method for tests Created 3 years, 10 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
OLDNEW
1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2016 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 "net/tools/transport_security_state_generator/bit_writer.h" 5 #include "net/tools/transport_security_state_generator/bit_writer.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 8
9 namespace net { 9 namespace net {
10 10
(...skipping 15 matching lines...) Expand all
26 current_byte_ |= bit << (7 - used_); 26 current_byte_ |= bit << (7 - used_);
27 used_++; 27 used_++;
28 position_++; 28 position_++;
29 29
30 if (used_ == 8) { 30 if (used_ == 8) {
31 Flush(); 31 Flush();
32 } 32 }
33 } 33 }
34 34
35 void BitWriter::Flush() { 35 void BitWriter::Flush() {
36 position_ += (8 - used_);
36 bytes_.push_back(current_byte_); 37 bytes_.push_back(current_byte_);
37 38
38 used_ = 0; 39 used_ = 0;
39 current_byte_ = 0; 40 current_byte_ = 0;
40 } 41 }
41 42
42 uint8_t BitWriter::BitLength(uint32_t input) const {
43 uint8_t number_of_bits = 0;
44 while (input != 0) {
45 number_of_bits++;
46 input >>= 1;
47 }
48 return number_of_bits;
49 }
50
51 } // namespace transport_security_state 43 } // namespace transport_security_state
52 44
53 } // namespace net 45 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698