| 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 "net/quic/core/quic_utils.h" | 5 #include "net/quic/core/quic_utils.h" |
| 6 | 6 |
| 7 #include <ctype.h> | 7 #include <ctype.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 if (data2 == nullptr) { | 120 if (data2 == nullptr) { |
| 121 return hash; | 121 return hash; |
| 122 } | 122 } |
| 123 return IncrementalHash(hash, data2, len2); | 123 return IncrementalHash(hash, data2, len2); |
| 124 } | 124 } |
| 125 | 125 |
| 126 // static | 126 // static |
| 127 bool QuicUtils::FindMutualTag(const QuicTagVector& our_tags_vector, | 127 bool QuicUtils::FindMutualTag(const QuicTagVector& our_tags_vector, |
| 128 const QuicTag* their_tags, | 128 const QuicTag* their_tags, |
| 129 size_t num_their_tags, | 129 size_t num_their_tags, |
| 130 Priority priority, | |
| 131 QuicTag* out_result, | 130 QuicTag* out_result, |
| 132 size_t* out_index) { | 131 size_t* out_index) { |
| 133 if (our_tags_vector.empty()) { | 132 if (our_tags_vector.empty()) { |
| 134 return false; | 133 return false; |
| 135 } | 134 } |
| 136 const size_t num_our_tags = our_tags_vector.size(); | 135 const size_t num_our_tags = our_tags_vector.size(); |
| 137 const QuicTag* our_tags = &our_tags_vector[0]; | 136 for (size_t i = 0; i < num_our_tags; i++) { |
| 138 | 137 for (size_t j = 0; j < num_their_tags; j++) { |
| 139 size_t num_priority_tags, num_inferior_tags; | 138 if (our_tags_vector[i] == their_tags[j]) { |
| 140 const QuicTag* priority_tags; | 139 *out_result = our_tags_vector[i]; |
| 141 const QuicTag* inferior_tags; | 140 if (out_index != nullptr) { |
| 142 if (priority == LOCAL_PRIORITY) { | 141 *out_index = j; |
| 143 num_priority_tags = num_our_tags; | |
| 144 priority_tags = our_tags; | |
| 145 num_inferior_tags = num_their_tags; | |
| 146 inferior_tags = their_tags; | |
| 147 } else { | |
| 148 num_priority_tags = num_their_tags; | |
| 149 priority_tags = their_tags; | |
| 150 num_inferior_tags = num_our_tags; | |
| 151 inferior_tags = our_tags; | |
| 152 } | |
| 153 | |
| 154 for (size_t i = 0; i < num_priority_tags; i++) { | |
| 155 for (size_t j = 0; j < num_inferior_tags; j++) { | |
| 156 if (priority_tags[i] == inferior_tags[j]) { | |
| 157 *out_result = priority_tags[i]; | |
| 158 if (out_index) { | |
| 159 if (priority == LOCAL_PRIORITY) { | |
| 160 *out_index = j; | |
| 161 } else { | |
| 162 *out_index = i; | |
| 163 } | |
| 164 } | 142 } |
| 165 return true; | 143 return true; |
| 166 } | 144 } |
| 167 } | 145 } |
| 168 } | 146 } |
| 169 | 147 |
| 170 return false; | 148 return false; |
| 171 } | 149 } |
| 172 | 150 |
| 173 // static | 151 // static |
| (...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 569 | 547 |
| 570 bytes_remaining -= line_bytes; | 548 bytes_remaining -= line_bytes; |
| 571 offset += line_bytes; | 549 offset += line_bytes; |
| 572 p += line_bytes; | 550 p += line_bytes; |
| 573 s += '\n'; | 551 s += '\n'; |
| 574 } | 552 } |
| 575 return s; | 553 return s; |
| 576 } | 554 } |
| 577 | 555 |
| 578 } // namespace net | 556 } // namespace net |
| OLD | NEW |