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

Unified Diff: net/spdy/spdy_protocol.h

Issue 2400463002: Eliminate use of StringPiece(nullptr, n) with non zero n. (Closed)
Patch Set: Created 4 years, 2 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/spdy/spdy_framer.cc ('k') | net/spdy/spdy_protocol.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/spdy/spdy_protocol.h
diff --git a/net/spdy/spdy_protocol.h b/net/spdy/spdy_protocol.h
index cb6296b08aaebc4b1f7437ff3afe09cbf1c0d2be..922e649e33d6dcc1a139b9644e683d888b3b0089 100644
--- a/net/spdy/spdy_protocol.h
+++ b/net/spdy/spdy_protocol.h
@@ -752,7 +752,8 @@ class NET_EXPORT_PRIVATE SpdyDataIR
~SpdyDataIR() override;
- base::StringPiece data() const { return data_; }
+ const char* data() const { return data_; }
+ size_t data_len() const { return data_len_; }
bool padded() const { return padded_; }
@@ -768,14 +769,24 @@ class NET_EXPORT_PRIVATE SpdyDataIR
// Deep-copy of data (keep private copy).
void SetDataDeep(base::StringPiece data) {
- data_store_.reset(new std::string(data.data(), data.length()));
- data_ = *(data_store_.get());
+ data_store_.reset(new std::string(data.data(), data.size()));
+ data_ = data_store_->data();
+ data_len_ = data.size();
}
// Shallow-copy of data (do not keep private copy).
void SetDataShallow(base::StringPiece data) {
data_store_.reset();
- data_ = data;
+ data_ = data.data();
+ data_len_ = data.size();
+ }
+
+ // Use this method if we don't have a contiguous buffer and only
+ // need a length.
+ void SetDataShallow(size_t len) {
+ data_store_.reset();
+ data_ = nullptr;
+ data_len_ = len;
}
void Visit(SpdyFrameVisitor* visitor) const override;
@@ -783,7 +794,8 @@ class NET_EXPORT_PRIVATE SpdyDataIR
private:
// Used to store data that this SpdyDataIR should own.
std::unique_ptr<std::string> data_store_;
- base::StringPiece data_;
+ const char* data_;
+ size_t data_len_;
bool padded_;
// padding_payload_len_ = desired padding length - len(padding length field).
« no previous file with comments | « net/spdy/spdy_framer.cc ('k') | net/spdy/spdy_protocol.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698