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

Side by Side Diff: net/spdy/spdy_deframer_visitor.cc

Issue 2758163003: Use string(StringPiece) instead of StringPiece::as_string(). (Closed)
Patch Set: Add StringPiece unittests. Created 3 years, 9 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
« no previous file with comments | « net/spdy/hpack/hpack_entry.cc ('k') | net/spdy/spdy_framer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/spdy/spdy_deframer_visitor.h" 5 #include "net/spdy/spdy_deframer_visitor.h"
6 6
7 #include <stdlib.h> 7 #include <stdlib.h>
8 #include <string.h> 8 #include <string.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after
413 413
414 void SpdyTestDeframerImpl::OnAltSvc( 414 void SpdyTestDeframerImpl::OnAltSvc(
415 SpdyStreamId stream_id, 415 SpdyStreamId stream_id,
416 StringPiece origin, 416 StringPiece origin,
417 const SpdyAltSvcWireFormat::AlternativeServiceVector& altsvc_vector) { 417 const SpdyAltSvcWireFormat::AlternativeServiceVector& altsvc_vector) {
418 DVLOG(1) << "OnAltSvc stream_id: " << stream_id; 418 DVLOG(1) << "OnAltSvc stream_id: " << stream_id;
419 CHECK_EQ(frame_type_, UNSET) << " frame_type_=" 419 CHECK_EQ(frame_type_, UNSET) << " frame_type_="
420 << Http2FrameTypeToString(frame_type_); 420 << Http2FrameTypeToString(frame_type_);
421 CHECK_GT(stream_id, 0u); 421 CHECK_GT(stream_id, 0u);
422 auto ptr = MakeUnique<SpdyAltSvcIR>(stream_id); 422 auto ptr = MakeUnique<SpdyAltSvcIR>(stream_id);
423 ptr->set_origin(origin.as_string()); 423 ptr->set_origin(std::string(origin));
424 for (auto& altsvc : altsvc_vector) { 424 for (auto& altsvc : altsvc_vector) {
425 ptr->add_altsvc(altsvc); 425 ptr->add_altsvc(altsvc);
426 } 426 }
427 listener_->OnAltSvc(std::move(ptr)); 427 listener_->OnAltSvc(std::move(ptr));
428 } 428 }
429 429
430 // Frame type BLOCKED was removed in draft 12 of HTTP/2. The intent appears to 430 // Frame type BLOCKED was removed in draft 12 of HTTP/2. The intent appears to
431 // have been to support debugging; it is not expected to be seen except if the 431 // have been to support debugging; it is not expected to be seen except if the
432 // peer "thinks" that a bug exists in the flow control such that the peer can't 432 // peer "thinks" that a bug exists in the flow control such that the peer can't
433 // send because the receiver hasn't sent WINDOW_UPDATE frames. Since we might 433 // send because the receiver hasn't sent WINDOW_UPDATE frames. Since we might
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after
754 CHECK_EQ(0u, headers_->size()); 754 CHECK_EQ(0u, headers_->size());
755 got_hpack_end_ = false; 755 got_hpack_end_ = false;
756 } 756 }
757 757
758 void SpdyTestDeframerImpl::OnHeader(StringPiece key, StringPiece value) { 758 void SpdyTestDeframerImpl::OnHeader(StringPiece key, StringPiece value) {
759 CHECK(frame_type_ == HEADERS || frame_type_ == CONTINUATION || 759 CHECK(frame_type_ == HEADERS || frame_type_ == CONTINUATION ||
760 frame_type_ == PUSH_PROMISE) 760 frame_type_ == PUSH_PROMISE)
761 << " frame_type_=" << Http2FrameTypeToString(frame_type_); 761 << " frame_type_=" << Http2FrameTypeToString(frame_type_);
762 CHECK(!got_hpack_end_); 762 CHECK(!got_hpack_end_);
763 CHECK(headers_); 763 CHECK(headers_);
764 headers_->emplace_back(key.as_string(), value.as_string()); 764 headers_->emplace_back(std::string(key), std::string(value));
765 CHECK(headers_handler_); 765 CHECK(headers_handler_);
766 headers_handler_->OnHeader(key, value); 766 headers_handler_->OnHeader(key, value);
767 } 767 }
768 768
769 void SpdyTestDeframerImpl::OnHeaderBlockEnd(size_t header_bytes_parsed) { 769 void SpdyTestDeframerImpl::OnHeaderBlockEnd(size_t header_bytes_parsed) {
770 CHECK(headers_); 770 CHECK(headers_);
771 CHECK(frame_type_ == HEADERS || frame_type_ == CONTINUATION || 771 CHECK(frame_type_ == HEADERS || frame_type_ == CONTINUATION ||
772 frame_type_ == PUSH_PROMISE) 772 frame_type_ == PUSH_PROMISE)
773 << " frame_type_=" << Http2FrameTypeToString(frame_type_); 773 << " frame_type_=" << Http2FrameTypeToString(frame_type_);
774 CHECK(end_); 774 CHECK(end_);
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
1035 // The SpdyFramer will not process any more data at this point. 1035 // The SpdyFramer will not process any more data at this point.
1036 void DeframerCallbackCollector::OnError(SpdyFramer* framer, 1036 void DeframerCallbackCollector::OnError(SpdyFramer* framer,
1037 SpdyTestDeframer* deframer) { 1037 SpdyTestDeframer* deframer) {
1038 CollectedFrame cf; 1038 CollectedFrame cf;
1039 cf.error_reported = true; 1039 cf.error_reported = true;
1040 collected_frames_->push_back(std::move(cf)); 1040 collected_frames_->push_back(std::move(cf));
1041 } 1041 }
1042 1042
1043 } // namespace test 1043 } // namespace test
1044 } // namespace net 1044 } // namespace net
OLDNEW
« no previous file with comments | « net/spdy/hpack/hpack_entry.cc ('k') | net/spdy/spdy_framer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698