OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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_write_queue.h" | 5 #include "net/spdy/spdy_write_queue.h" |
6 | 6 |
7 #include <cstddef> | 7 #include <cstddef> |
8 #include <cstring> | 8 #include <cstring> |
9 #include <memory> | 9 #include <memory> |
10 #include <utility> | 10 #include <utility> |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 // Makes a SpdyBufferProducer producing a frame with the data in the | 43 // Makes a SpdyBufferProducer producing a frame with the data in the |
44 // given int (converted to a string). | 44 // given int (converted to a string). |
45 std::unique_ptr<SpdyBufferProducer> IntToProducer(int i) { | 45 std::unique_ptr<SpdyBufferProducer> IntToProducer(int i) { |
46 return StringToProducer(base::IntToString(i)); | 46 return StringToProducer(base::IntToString(i)); |
47 } | 47 } |
48 | 48 |
49 // Producer whose produced buffer will enqueue yet another buffer into the | 49 // Producer whose produced buffer will enqueue yet another buffer into the |
50 // SpdyWriteQueue upon destruction. | 50 // SpdyWriteQueue upon destruction. |
51 class RequeingBufferProducer : public SpdyBufferProducer { | 51 class RequeingBufferProducer : public SpdyBufferProducer { |
52 public: | 52 public: |
53 RequeingBufferProducer(SpdyWriteQueue* queue) { | 53 explicit RequeingBufferProducer(SpdyWriteQueue* queue) { |
54 buffer_.reset(new SpdyBuffer(kOriginal, arraysize(kOriginal))); | 54 buffer_.reset(new SpdyBuffer(kOriginal, arraysize(kOriginal))); |
55 buffer_->AddConsumeCallback( | 55 buffer_->AddConsumeCallback( |
56 base::Bind(RequeingBufferProducer::ConsumeCallback, queue)); | 56 base::Bind(RequeingBufferProducer::ConsumeCallback, queue)); |
57 } | 57 } |
58 | 58 |
59 std::unique_ptr<SpdyBuffer> ProduceBuffer() override { | 59 std::unique_ptr<SpdyBuffer> ProduceBuffer() override { |
60 return std::move(buffer_); | 60 return std::move(buffer_); |
61 } | 61 } |
62 | 62 |
63 size_t EstimateMemoryUsage() const override { | 63 size_t EstimateMemoryUsage() const override { |
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
372 base::WeakPtr<SpdyStream> weak_stream; | 372 base::WeakPtr<SpdyStream> weak_stream; |
373 | 373 |
374 EXPECT_TRUE(queue.Dequeue(&frame_type, &producer, &weak_stream)); | 374 EXPECT_TRUE(queue.Dequeue(&frame_type, &producer, &weak_stream)); |
375 EXPECT_EQ(SpdyString(kRequeued), | 375 EXPECT_EQ(SpdyString(kRequeued), |
376 producer->ProduceBuffer()->GetRemainingData()); | 376 producer->ProduceBuffer()->GetRemainingData()); |
377 } | 377 } |
378 | 378 |
379 } // namespace | 379 } // namespace |
380 | 380 |
381 } // namespace net | 381 } // namespace net |
OLD | NEW |