| 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/socket/fuzzed_socket.h" | 5 #include "net/socket/fuzzed_socket.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/location.h" | 8 #include "base/location.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/thread_task_runner_handle.h" | 10 #include "base/thread_task_runner_handle.h" |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 | 146 |
| 147 void FuzzedSocket::Disconnect() { | 147 void FuzzedSocket::Disconnect() { |
| 148 net_error_ = ERR_CONNECTION_CLOSED; | 148 net_error_ = ERR_CONNECTION_CLOSED; |
| 149 weak_factory_.InvalidateWeakPtrs(); | 149 weak_factory_.InvalidateWeakPtrs(); |
| 150 read_pending_ = false; | 150 read_pending_ = false; |
| 151 write_pending_ = false; | 151 write_pending_ = false; |
| 152 error_pending_ = false; | 152 error_pending_ = false; |
| 153 } | 153 } |
| 154 | 154 |
| 155 bool FuzzedSocket::IsConnected() const { | 155 bool FuzzedSocket::IsConnected() const { |
| 156 return net_error_ != OK && !error_pending_; | 156 return net_error_ == OK && !error_pending_; |
| 157 } | 157 } |
| 158 | 158 |
| 159 bool FuzzedSocket::IsConnectedAndIdle() const { | 159 bool FuzzedSocket::IsConnectedAndIdle() const { |
| 160 return IsConnected(); | 160 return IsConnected(); |
| 161 } | 161 } |
| 162 | 162 |
| 163 int FuzzedSocket::GetPeerAddress(IPEndPoint* address) const { | 163 int FuzzedSocket::GetPeerAddress(IPEndPoint* address) const { |
| 164 if (!IsConnected()) | 164 if (!IsConnected()) |
| 165 return ERR_SOCKET_NOT_CONNECTED; | 165 return ERR_SOCKET_NOT_CONNECTED; |
| 166 *address = IPEndPoint(IPAddress(127, 0, 0, 1), 80); | 166 *address = IPEndPoint(IPAddress(127, 0, 0, 1), 80); |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 243 write_pending_ = false; | 243 write_pending_ = false; |
| 244 if (result <= 0) { | 244 if (result <= 0) { |
| 245 error_pending_ = false; | 245 error_pending_ = false; |
| 246 } else { | 246 } else { |
| 247 total_bytes_written_ += result; | 247 total_bytes_written_ += result; |
| 248 } | 248 } |
| 249 callback.Run(result); | 249 callback.Run(result); |
| 250 } | 250 } |
| 251 | 251 |
| 252 } // namespace net | 252 } // namespace net |
| OLD | NEW |