| 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 <string> | 9 #include <string> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 const char kOriginal[] = "original"; | 28 const char kOriginal[] = "original"; |
| 29 const char kRequeued[] = "requeued"; | 29 const char kRequeued[] = "requeued"; |
| 30 | 30 |
| 31 class SpdyWriteQueueTest : public ::testing::Test {}; | 31 class SpdyWriteQueueTest : public ::testing::Test {}; |
| 32 | 32 |
| 33 // Makes a SpdyFrameProducer producing a frame with the data in the | 33 // Makes a SpdyFrameProducer producing a frame with the data in the |
| 34 // given string. | 34 // given string. |
| 35 scoped_ptr<SpdyBufferProducer> StringToProducer(const std::string& s) { | 35 scoped_ptr<SpdyBufferProducer> StringToProducer(const std::string& s) { |
| 36 scoped_ptr<char[]> data(new char[s.size()]); | 36 scoped_ptr<char[]> data(new char[s.size()]); |
| 37 std::memcpy(data.get(), s.data(), s.size()); | 37 std::memcpy(data.get(), s.data(), s.size()); |
| 38 return scoped_ptr<SpdyBufferProducer>( | 38 return scoped_ptr<SpdyBufferProducer>(new SimpleBufferProducer( |
| 39 new SimpleBufferProducer( | 39 scoped_ptr<SpdyBuffer>(new SpdyBuffer(scoped_ptr<SpdySerializedFrame>( |
| 40 scoped_ptr<SpdyBuffer>( | 40 new SpdySerializedFrame(data.release(), s.size(), true)))))); |
| 41 new SpdyBuffer( | |
| 42 scoped_ptr<SpdyFrame>( | |
| 43 new SpdyFrame(data.release(), s.size(), true)))))); | |
| 44 } | 41 } |
| 45 | 42 |
| 46 // Makes a SpdyBufferProducer producing a frame with the data in the | 43 // Makes a SpdyBufferProducer producing a frame with the data in the |
| 47 // given int (converted to a string). | 44 // given int (converted to a string). |
| 48 scoped_ptr<SpdyBufferProducer> IntToProducer(int i) { | 45 scoped_ptr<SpdyBufferProducer> IntToProducer(int i) { |
| 49 return StringToProducer(base::IntToString(i)); | 46 return StringToProducer(base::IntToString(i)); |
| 50 } | 47 } |
| 51 | 48 |
| 52 // Producer whose produced buffer will enqueue yet another buffer into the | 49 // Producer whose produced buffer will enqueue yet another buffer into the |
| 53 // SpdyWriteQueue upon destruction. | 50 // SpdyWriteQueue upon destruction. |
| (...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 364 scoped_ptr<SpdyBufferProducer> producer; | 361 scoped_ptr<SpdyBufferProducer> producer; |
| 365 base::WeakPtr<SpdyStream> weak_stream; | 362 base::WeakPtr<SpdyStream> weak_stream; |
| 366 | 363 |
| 367 EXPECT_TRUE(queue.Dequeue(&frame_type, &producer, &weak_stream)); | 364 EXPECT_TRUE(queue.Dequeue(&frame_type, &producer, &weak_stream)); |
| 368 EXPECT_EQ(string(kRequeued), producer->ProduceBuffer()->GetRemainingData()); | 365 EXPECT_EQ(string(kRequeued), producer->ProduceBuffer()->GetRemainingData()); |
| 369 } | 366 } |
| 370 | 367 |
| 371 } // namespace | 368 } // namespace |
| 372 | 369 |
| 373 } // namespace net | 370 } // namespace net |
| OLD | NEW |