| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "extensions/browser/api/cast_channel/cast_socket.h" | 5 #include "extensions/browser/api/cast_channel/cast_socket.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
| 10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 test_message.set_namespace_("ns"); | 88 test_message.set_namespace_("ns"); |
| 89 test_message.set_source_id("source"); | 89 test_message.set_source_id("source"); |
| 90 test_message.set_destination_id("dest"); | 90 test_message.set_destination_id("dest"); |
| 91 test_message.set_payload_type(CastMessage::STRING); | 91 test_message.set_payload_type(CastMessage::STRING); |
| 92 test_message.set_payload_utf8("payload"); | 92 test_message.set_payload_utf8("payload"); |
| 93 return test_message; | 93 return test_message; |
| 94 } | 94 } |
| 95 | 95 |
| 96 class MockTCPSocket : public net::TCPClientSocket { | 96 class MockTCPSocket : public net::TCPClientSocket { |
| 97 public: | 97 public: |
| 98 explicit MockTCPSocket(const net::MockConnect& connect_data) : | 98 explicit MockTCPSocket(const net::MockConnect& connect_data) |
| 99 TCPClientSocket(net::AddressList(), NULL, net::NetLog::Source()), | 99 : TCPClientSocket(net::AddressList(), nullptr, net::NetLog::Source()), |
| 100 connect_data_(connect_data), | 100 connect_data_(connect_data), |
| 101 do_nothing_(false) { } | 101 do_nothing_(false) {} |
| 102 | 102 |
| 103 explicit MockTCPSocket(bool do_nothing) : | 103 explicit MockTCPSocket(bool do_nothing) |
| 104 TCPClientSocket(net::AddressList(), NULL, net::NetLog::Source()) { | 104 : TCPClientSocket(net::AddressList(), nullptr, net::NetLog::Source()) { |
| 105 CHECK(do_nothing); | 105 CHECK(do_nothing); |
| 106 do_nothing_ = do_nothing; | 106 do_nothing_ = do_nothing; |
| 107 } | 107 } |
| 108 | 108 |
| 109 virtual int Connect(const net::CompletionCallback& callback) { | 109 virtual int Connect(const net::CompletionCallback& callback) { |
| 110 if (do_nothing_) { | 110 if (do_nothing_) { |
| 111 // Stall the I/O event loop. | 111 // Stall the I/O event loop. |
| 112 return net::ERR_IO_PENDING; | 112 return net::ERR_IO_PENDING; |
| 113 } | 113 } |
| 114 | 114 |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 &capturing_net_log_, | 197 &capturing_net_log_, |
| 198 base::TimeDelta::FromMilliseconds(timeout_ms), | 198 base::TimeDelta::FromMilliseconds(timeout_ms), |
| 199 logger), | 199 logger), |
| 200 ip_(ip_endpoint), | 200 ip_(ip_endpoint), |
| 201 connect_index_(0), | 201 connect_index_(0), |
| 202 extract_cert_result_(true), | 202 extract_cert_result_(true), |
| 203 verify_challenge_result_(true), | 203 verify_challenge_result_(true), |
| 204 verify_challenge_disallow_(false), | 204 verify_challenge_disallow_(false), |
| 205 tcp_unresponsive_(false), | 205 tcp_unresponsive_(false), |
| 206 mock_timer_(new base::MockTimer(false, false)), | 206 mock_timer_(new base::MockTimer(false, false)), |
| 207 mock_transport_(NULL) {} | 207 mock_transport_(nullptr) {} |
| 208 | 208 |
| 209 ~TestCastSocket() override {} | 209 ~TestCastSocket() override {} |
| 210 | 210 |
| 211 void SetupMockTransport() { | 211 void SetupMockTransport() { |
| 212 mock_transport_ = new MockCastTransport; | 212 mock_transport_ = new MockCastTransport; |
| 213 SetTransportForTesting(make_scoped_ptr(mock_transport_)); | 213 SetTransportForTesting(make_scoped_ptr(mock_transport_)); |
| 214 } | 214 } |
| 215 | 215 |
| 216 // Socket connection helpers. | 216 // Socket connection helpers. |
| 217 void SetupTcp1Connect(net::IoMode mode, int result) { | 217 void SetupTcp1Connect(net::IoMode mode, int result) { |
| (...skipping 639 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 857 test_message, base::Bind(&CompleteHandler::OnWriteComplete, | 857 test_message, base::Bind(&CompleteHandler::OnWriteComplete, |
| 858 base::Unretained(&handler_))); | 858 base::Unretained(&handler_))); |
| 859 RunPendingTasks(); | 859 RunPendingTasks(); |
| 860 | 860 |
| 861 EXPECT_EQ(cast_channel::READY_STATE_OPEN, socket_->ready_state()); | 861 EXPECT_EQ(cast_channel::READY_STATE_OPEN, socket_->ready_state()); |
| 862 EXPECT_EQ(cast_channel::CHANNEL_ERROR_NONE, socket_->error_state()); | 862 EXPECT_EQ(cast_channel::CHANNEL_ERROR_NONE, socket_->error_state()); |
| 863 } | 863 } |
| 864 } // namespace cast_channel | 864 } // namespace cast_channel |
| 865 } // namespace core_api | 865 } // namespace core_api |
| 866 } // namespace extensions | 866 } // namespace extensions |
| OLD | NEW |