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

Unified Diff: net/der/input.cc

Issue 1573243011: Refactor der::Input helper methods into new constructors (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix nits Created 4 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/der/input.h ('k') | net/socket/ssl_client_socket_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/der/input.cc
diff --git a/net/der/input.cc b/net/der/input.cc
index 5065ccaca93e9bdc3ffc06b5af2eaa332d57f1ae..871f9f4ec7dc29a52d645f9c2194c2795d559394 100644
--- a/net/der/input.cc
+++ b/net/der/input.cc
@@ -19,6 +19,11 @@ Input::Input() : data_(nullptr), len_(0) {
Input::Input(const uint8_t* data, size_t len) : data_(data), len_(len) {
}
+Input::Input(const base::StringPiece& in)
+ : data_(reinterpret_cast<const uint8_t*>(in.data())), len_(in.length()) {}
+
+Input::Input(const std::string* s) : Input(base::StringPiece(*s)) {}
+
bool Input::Equals(const Input& other) const {
if (len_ != other.len_)
return false;
@@ -29,6 +34,10 @@ std::string Input::AsString() const {
return std::string(reinterpret_cast<const char*>(data_), len_);
}
+base::StringPiece Input::AsStringPiece() const {
+ return base::StringPiece(reinterpret_cast<const char*>(data_), len_);
+}
+
bool operator<(const Input& lhs, const Input& rhs) {
return std::lexicographical_compare(
lhs.UnsafeData(), lhs.UnsafeData() + lhs.Length(), rhs.UnsafeData(),
« no previous file with comments | « net/der/input.h ('k') | net/socket/ssl_client_socket_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698