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

Side by Side Diff: net/ssl/ssl_connection_status_flags.h

Issue 1535363003: Switch to standard integer types in net/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: stddef Created 5 years 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 | « net/ssl/ssl_config_service_unittest.cc ('k') | net/ssl/ssl_connection_status_flags_unittest.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 #ifndef NET_SSL_SSL_CONNECTION_STATUS_FLAGS_H_ 5 #ifndef NET_SSL_SSL_CONNECTION_STATUS_FLAGS_H_
6 #define NET_SSL_SSL_CONNECTION_STATUS_FLAGS_H_ 6 #define NET_SSL_SSL_CONNECTION_STATUS_FLAGS_H_
7 7
8 #include <stdint.h>
9
8 #include "base/logging.h" 10 #include "base/logging.h"
9 #include "base/macros.h" 11 #include "base/macros.h"
10 12
11 namespace net { 13 namespace net {
12 14
13 // Status flags for SSLInfo::connection_status. 15 // Status flags for SSLInfo::connection_status.
14 enum { 16 enum {
15 // The lower 16 bits are reserved for the TLS ciphersuite id. 17 // The lower 16 bits are reserved for the TLS ciphersuite id.
16 SSL_CONNECTION_CIPHERSUITE_MASK = 0xffff, 18 SSL_CONNECTION_CIPHERSUITE_MASK = 0xffff,
17 19
(...skipping 28 matching lines...) Expand all
46 SSL_CONNECTION_VERSION_TLS1 = 3, 48 SSL_CONNECTION_VERSION_TLS1 = 3,
47 SSL_CONNECTION_VERSION_TLS1_1 = 4, 49 SSL_CONNECTION_VERSION_TLS1_1 = 4,
48 SSL_CONNECTION_VERSION_TLS1_2 = 5, 50 SSL_CONNECTION_VERSION_TLS1_2 = 5,
49 // Reserve 6 for TLS 1.3. 51 // Reserve 6 for TLS 1.3.
50 SSL_CONNECTION_VERSION_QUIC = 7, 52 SSL_CONNECTION_VERSION_QUIC = 7,
51 SSL_CONNECTION_VERSION_MAX, 53 SSL_CONNECTION_VERSION_MAX,
52 }; 54 };
53 static_assert(SSL_CONNECTION_VERSION_MAX - 1 <= SSL_CONNECTION_VERSION_MASK, 55 static_assert(SSL_CONNECTION_VERSION_MAX - 1 <= SSL_CONNECTION_VERSION_MASK,
54 "SSL_CONNECTION_VERSION_MASK too small"); 56 "SSL_CONNECTION_VERSION_MASK too small");
55 57
56 inline uint16 SSLConnectionStatusToCipherSuite(int connection_status) { 58 inline uint16_t SSLConnectionStatusToCipherSuite(int connection_status) {
57 return static_cast<uint16>(connection_status); 59 return static_cast<uint16_t>(connection_status);
58 } 60 }
59 61
60 inline int SSLConnectionStatusToVersion(int connection_status) { 62 inline int SSLConnectionStatusToVersion(int connection_status) {
61 return (connection_status >> SSL_CONNECTION_VERSION_SHIFT) & 63 return (connection_status >> SSL_CONNECTION_VERSION_SHIFT) &
62 SSL_CONNECTION_VERSION_MASK; 64 SSL_CONNECTION_VERSION_MASK;
63 } 65 }
64 66
65 inline void SSLConnectionStatusSetCipherSuite(uint16 cipher_suite, 67 inline void SSLConnectionStatusSetCipherSuite(uint16_t cipher_suite,
66 int* connection_status) { 68 int* connection_status) {
67 // Clear out the old ciphersuite. 69 // Clear out the old ciphersuite.
68 *connection_status &= ~SSL_CONNECTION_CIPHERSUITE_MASK; 70 *connection_status &= ~SSL_CONNECTION_CIPHERSUITE_MASK;
69 // Set the new ciphersuite. 71 // Set the new ciphersuite.
70 *connection_status |= cipher_suite; 72 *connection_status |= cipher_suite;
71 } 73 }
72 74
73 inline void SSLConnectionStatusSetVersion(int version, int* connection_status) { 75 inline void SSLConnectionStatusSetVersion(int version, int* connection_status) {
74 DCHECK_GT(version, 0); 76 DCHECK_GT(version, 0);
75 DCHECK_LT(version, SSL_CONNECTION_VERSION_MAX); 77 DCHECK_LT(version, SSL_CONNECTION_VERSION_MAX);
76 78
77 // Clear out the old version. 79 // Clear out the old version.
78 *connection_status &= 80 *connection_status &=
79 ~(SSL_CONNECTION_VERSION_MASK << SSL_CONNECTION_VERSION_SHIFT); 81 ~(SSL_CONNECTION_VERSION_MASK << SSL_CONNECTION_VERSION_SHIFT);
80 // Set the new version. 82 // Set the new version.
81 *connection_status |= 83 *connection_status |=
82 ((version & SSL_CONNECTION_VERSION_MASK) << SSL_CONNECTION_VERSION_SHIFT); 84 ((version & SSL_CONNECTION_VERSION_MASK) << SSL_CONNECTION_VERSION_SHIFT);
83 } 85 }
84 86
85 } // namespace net 87 } // namespace net
86 88
87 #endif // NET_SSL_SSL_CONNECTION_STATUS_FLAGS_H_ 89 #endif // NET_SSL_SSL_CONNECTION_STATUS_FLAGS_H_
OLDNEW
« no previous file with comments | « net/ssl/ssl_config_service_unittest.cc ('k') | net/ssl/ssl_connection_status_flags_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698