Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 <algorithm> | 5 #include <algorithm> |
| 6 #include <memory> | 6 #include <memory> |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "blimp/common/create_blimp_message.h" | 10 #include "blimp/common/create_blimp_message.h" |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 37 engine_(local_address_, nullptr), | 37 engine_(local_address_, nullptr), |
| 38 read_buffer_(new net::GrowableIOBuffer) { | 38 read_buffer_(new net::GrowableIOBuffer) { |
| 39 size_t buf_size = std::max(payload_1_.size(), payload_2_.size()); | 39 size_t buf_size = std::max(payload_1_.size(), payload_2_.size()); |
| 40 write_buffer_ = make_scoped_refptr( | 40 write_buffer_ = make_scoped_refptr( |
| 41 new net::DrainableIOBuffer(new net::IOBuffer(buf_size), buf_size)); | 41 new net::DrainableIOBuffer(new net::IOBuffer(buf_size), buf_size)); |
| 42 read_buffer_->SetCapacity(buf_size); | 42 read_buffer_->SetCapacity(buf_size); |
| 43 } | 43 } |
| 44 | 44 |
| 45 net::IPEndPoint GetLocalEndpoint() const { | 45 net::IPEndPoint GetLocalEndpoint() const { |
| 46 net::IPEndPoint local_address; | 46 net::IPEndPoint local_address; |
| 47 CHECK_EQ(net::OK, engine_.GetLocalAddress(&local_address)); | 47 engine_.GetLocalAddress(&local_address); |
|
Wez
2016/11/09 22:47:17
Why remove the CHECK?
| |
| 48 return local_address; | 48 return local_address; |
| 49 } | 49 } |
| 50 | 50 |
| 51 std::string payload_1_ = "foo"; | 51 std::string payload_1_ = "foo"; |
| 52 std::string payload_2_ = "bar"; | 52 std::string payload_2_ = "bar"; |
| 53 base::MessageLoopForIO message_loop_; | 53 base::MessageLoopForIO message_loop_; |
| 54 net::IPEndPoint local_address_; | 54 net::IPEndPoint local_address_; |
| 55 TCPEngineTransport engine_; | 55 TCPEngineTransport engine_; |
| 56 scoped_refptr<net::DrainableIOBuffer> write_buffer_; | 56 scoped_refptr<net::DrainableIOBuffer> write_buffer_; |
| 57 scoped_refptr<net::GrowableIOBuffer> read_buffer_; | 57 scoped_refptr<net::GrowableIOBuffer> read_buffer_; |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 126 engine_message_port->reader()->ReadPacket(read_buffer_, read_cb2.callback()); | 126 engine_message_port->reader()->ReadPacket(read_buffer_, read_cb2.callback()); |
| 127 EXPECT_EQ(payload_2_.size(), static_cast<size_t>(read_cb2.WaitForResult())); | 127 EXPECT_EQ(payload_2_.size(), static_cast<size_t>(read_cb2.WaitForResult())); |
| 128 EXPECT_EQ(net::OK, write_cb2.WaitForResult()); | 128 EXPECT_EQ(net::OK, write_cb2.WaitForResult()); |
| 129 EXPECT_TRUE( | 129 EXPECT_TRUE( |
| 130 BufferStartsWith(read_buffer_.get(), payload_2_.size(), payload_2_)); | 130 BufferStartsWith(read_buffer_.get(), payload_2_.size(), payload_2_)); |
| 131 } | 131 } |
| 132 | 132 |
| 133 } // namespace | 133 } // namespace |
| 134 | 134 |
| 135 } // namespace blimp | 135 } // namespace blimp |
| OLD | NEW |