| 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 437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 448 } | 448 } |
| 449 | 449 |
| 450 string QuicUtils::HexEncode(const char* data, size_t length) { | 450 string QuicUtils::HexEncode(const char* data, size_t length) { |
| 451 return HexEncode(StringPiece(data, length)); | 451 return HexEncode(StringPiece(data, length)); |
| 452 } | 452 } |
| 453 | 453 |
| 454 string QuicUtils::HexEncode(StringPiece data) { | 454 string QuicUtils::HexEncode(StringPiece data) { |
| 455 return ::base::HexEncode(data.data(), data.size()); | 455 return ::base::HexEncode(data.data(), data.size()); |
| 456 } | 456 } |
| 457 | 457 |
| 458 string QuicUtils::HexDecode(const char* data, size_t length) { | |
| 459 return HexDecode(StringPiece(data, length)); | |
| 460 } | |
| 461 | |
| 462 string QuicUtils::HexDecode(StringPiece data) { | 458 string QuicUtils::HexDecode(StringPiece data) { |
| 463 if (data.empty()) | 459 if (data.empty()) |
| 464 return ""; | 460 return ""; |
| 465 std::vector<uint8_t> v; | 461 std::vector<uint8_t> v; |
| 466 if (!base::HexStringToBytes(data.as_string(), &v)) | 462 if (!base::HexStringToBytes(data.as_string(), &v)) |
| 467 return ""; | 463 return ""; |
| 468 string out; | 464 string out; |
| 469 if (!v.empty()) | 465 if (!v.empty()) |
| 470 out.assign(reinterpret_cast<const char*>(&v[0]), v.size()); | 466 out.assign(reinterpret_cast<const char*>(&v[0]), v.size()); |
| 471 return out; | 467 return out; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 497 | 493 |
| 498 bytes_remaining -= line_bytes; | 494 bytes_remaining -= line_bytes; |
| 499 offset += line_bytes; | 495 offset += line_bytes; |
| 500 p += line_bytes; | 496 p += line_bytes; |
| 501 s += '\n'; | 497 s += '\n'; |
| 502 } | 498 } |
| 503 return s; | 499 return s; |
| 504 } | 500 } |
| 505 | 501 |
| 506 } // namespace net | 502 } // namespace net |
| OLD | NEW |