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

Side by Side Diff: net/der/input.cc

Issue 1125333005: RFC 2459 name comparison. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: ios copy_test_data Created 5 years, 4 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 <string.h> 5 #include <string.h>
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "net/der/input.h" 8 #include "net/der/input.h"
9 9
10 namespace net { 10 namespace net {
11 11
12 namespace der { 12 namespace der {
13 13
14 Input::Input() : data_(nullptr), len_(0) { 14 Input::Input() : data_(nullptr), len_(0) {
15 } 15 }
16 16
17 Input::Input(const uint8_t* data, size_t len) : data_(data), len_(len) { 17 Input::Input(const uint8_t* data, size_t len) : data_(data), len_(len) {
18 } 18 }
19 19
20 bool Input::Equals(const Input& other) const { 20 bool Input::Equals(const Input& other) const {
21 if (len_ != other.len_) 21 if (len_ != other.len_)
22 return false; 22 return false;
23 return memcmp(data_, other.data_, len_) == 0; 23 return memcmp(data_, other.data_, len_) == 0;
24 } 24 }
25 25
26 std::string Input::AsString() const {
27 return std::string(reinterpret_cast<const char*>(data_), len_);
28 }
29
26 ByteReader::ByteReader(const Input& in) 30 ByteReader::ByteReader(const Input& in)
27 : data_(in.UnsafeData()), len_(in.Length()) { 31 : data_(in.UnsafeData()), len_(in.Length()) {
28 } 32 }
29 33
30 bool ByteReader::ReadByte(uint8_t* byte_p) { 34 bool ByteReader::ReadByte(uint8_t* byte_p) {
31 if (!HasMore()) 35 if (!HasMore())
32 return false; 36 return false;
33 *byte_p = *data_; 37 *byte_p = *data_;
34 Advance(1); 38 Advance(1);
35 return true; 39 return true;
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 91
88 Mark::Mark(const uint8_t* ptr) : ptr_(ptr) { 92 Mark::Mark(const uint8_t* ptr) : ptr_(ptr) {
89 } 93 }
90 94
91 Mark::Mark() : ptr_(nullptr) { 95 Mark::Mark() : ptr_(nullptr) {
92 } 96 }
93 97
94 } // namespace der 98 } // namespace der
95 99
96 } // namespace net 100 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698