| OLD | NEW |
| 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/core/spdy_deframer_visitor.h" | 5 #include "net/spdy/core/spdy_deframer_visitor.h" |
| 6 | 6 |
| 7 #include <stdlib.h> | 7 #include <stdlib.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <limits> | 10 #include <limits> |
| 11 | 11 |
| 12 #include "base/logging.h" | 12 #include "base/logging.h" |
| 13 #include "base/memory/ptr_util.h" | 13 #include "base/memory/ptr_util.h" |
| 14 #include "base/rand_util.h" | 14 #include "base/rand_util.h" |
| 15 #include "net/spdy/core/hpack/hpack_constants.h" | 15 #include "net/spdy/core/hpack/hpack_constants.h" |
| 16 #include "net/spdy/core/mock_spdy_framer_visitor.h" | 16 #include "net/spdy/core/mock_spdy_framer_visitor.h" |
| 17 #include "net/spdy/core/spdy_frame_builder.h" | 17 #include "net/spdy/core/spdy_frame_builder.h" |
| 18 #include "net/spdy/core/spdy_frame_reader.h" | 18 #include "net/spdy/core/spdy_frame_reader.h" |
| 19 #include "net/spdy/core/spdy_protocol.h" | 19 #include "net/spdy/core/spdy_protocol.h" |
| 20 #include "net/spdy/core/spdy_protocol_test_utils.h" | 20 #include "net/spdy/core/spdy_protocol_test_utils.h" |
| 21 #include "net/spdy/core/spdy_test_utils.h" | 21 #include "net/spdy/core/spdy_test_utils.h" |
| 22 | 22 #include "net/spdy/platform/api/spdy_ptr_util.h" |
| 23 using ::base::MakeUnique; | |
| 24 | 23 |
| 25 namespace net { | 24 namespace net { |
| 26 namespace test { | 25 namespace test { |
| 27 namespace { | 26 namespace { |
| 28 | 27 |
| 29 class SpdyDeframerVisitorTest : public ::testing::Test { | 28 class SpdyDeframerVisitorTest : public ::testing::Test { |
| 30 protected: | 29 protected: |
| 31 SpdyDeframerVisitorTest() | 30 SpdyDeframerVisitorTest() |
| 32 : encoder_(SpdyFramer::ENABLE_COMPRESSION), | 31 : encoder_(SpdyFramer::ENABLE_COMPRESSION), |
| 33 decoder_(SpdyFramer::ENABLE_COMPRESSION) { | 32 decoder_(SpdyFramer::ENABLE_COMPRESSION) { |
| 34 decoder_.set_process_single_input_frame(true); | 33 decoder_.set_process_single_input_frame(true); |
| 35 auto collector = MakeUnique<DeframerCallbackCollector>(&collected_frames_); | 34 auto collector = |
| 35 SpdyMakeUnique<DeframerCallbackCollector>(&collected_frames_); |
| 36 auto log_and_collect = | 36 auto log_and_collect = |
| 37 SpdyDeframerVisitorInterface::LogBeforeVisiting(std::move(collector)); | 37 SpdyDeframerVisitorInterface::LogBeforeVisiting(std::move(collector)); |
| 38 deframer_ = SpdyTestDeframer::CreateConverter(std::move(log_and_collect)); | 38 deframer_ = SpdyTestDeframer::CreateConverter(std::move(log_and_collect)); |
| 39 decoder_.set_visitor(deframer_.get()); | 39 decoder_.set_visitor(deframer_.get()); |
| 40 } | 40 } |
| 41 | 41 |
| 42 bool DeframeInput(const char* input, size_t size) { | 42 bool DeframeInput(const char* input, size_t size) { |
| 43 size_t input_remaining = size; | 43 size_t input_remaining = size; |
| 44 while (input_remaining > 0 && | 44 while (input_remaining > 0 && |
| 45 decoder_.spdy_framer_error() == SpdyFramer::SPDY_NO_ERROR) { | 45 decoder_.spdy_framer_error() == SpdyFramer::SPDY_NO_ERROR) { |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 262 // TODO(jamessynge): Please implement. | 262 // TODO(jamessynge): Please implement. |
| 263 } | 263 } |
| 264 | 264 |
| 265 TEST_F(SpdyDeframerVisitorTest, DISABLED_AltSvcFrame) { | 265 TEST_F(SpdyDeframerVisitorTest, DISABLED_AltSvcFrame) { |
| 266 // TODO(jamessynge): Please implement. | 266 // TODO(jamessynge): Please implement. |
| 267 } | 267 } |
| 268 | 268 |
| 269 } // namespace | 269 } // namespace |
| 270 } // namespace test | 270 } // namespace test |
| 271 } // namespace net | 271 } // namespace net |
| OLD | NEW |