| 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 "content/browser/renderer_host/p2p/socket_host_test_utils.h" | 5 #include "content/browser/renderer_host/p2p/socket_host_test_utils.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/sys_byteorder.h" | 10 #include "base/sys_byteorder.h" |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 void FakeSocket::AppendInputData(const char* data, int data_size) { | 35 void FakeSocket::AppendInputData(const char* data, int data_size) { |
| 36 input_data_.insert(input_data_.end(), data, data + data_size); | 36 input_data_.insert(input_data_.end(), data, data + data_size); |
| 37 // Complete pending read if any. | 37 // Complete pending read if any. |
| 38 if (read_pending_) { | 38 if (read_pending_) { |
| 39 read_pending_ = false; | 39 read_pending_ = false; |
| 40 int result = std::min(read_buffer_size_, | 40 int result = std::min(read_buffer_size_, |
| 41 static_cast<int>(input_data_.size() - input_pos_)); | 41 static_cast<int>(input_data_.size() - input_pos_)); |
| 42 CHECK(result > 0); | 42 CHECK(result > 0); |
| 43 memcpy(read_buffer_->data(), &input_data_[0] + input_pos_, result); | 43 memcpy(read_buffer_->data(), &input_data_[0] + input_pos_, result); |
| 44 input_pos_ += result; | 44 input_pos_ += result; |
| 45 read_buffer_ = NULL; | 45 read_buffer_ = nullptr; |
| 46 net::CompletionCallback cb = read_callback_; | 46 net::CompletionCallback cb = read_callback_; |
| 47 read_callback_.Reset(); | 47 read_callback_.Reset(); |
| 48 cb.Run(result); | 48 cb.Run(result); |
| 49 } | 49 } |
| 50 } | 50 } |
| 51 | 51 |
| 52 void FakeSocket::SetPeerAddress(const net::IPEndPoint& peer_address) { | 52 void FakeSocket::SetPeerAddress(const net::IPEndPoint& peer_address) { |
| 53 peer_address_ = peer_address; | 53 peer_address_ = peer_address; |
| 54 } | 54 } |
| 55 | 55 |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 | 211 |
| 212 void CreateStunError(std::vector<char>* packet) { | 212 void CreateStunError(std::vector<char>* packet) { |
| 213 CreateStunPacket(packet, kStunBindingError); | 213 CreateStunPacket(packet, kStunBindingError); |
| 214 } | 214 } |
| 215 | 215 |
| 216 net::IPEndPoint ParseAddress(const std::string& ip_str, uint16_t port) { | 216 net::IPEndPoint ParseAddress(const std::string& ip_str, uint16_t port) { |
| 217 net::IPAddress ip; | 217 net::IPAddress ip; |
| 218 EXPECT_TRUE(ip.AssignFromIPLiteral(ip_str)); | 218 EXPECT_TRUE(ip.AssignFromIPLiteral(ip_str)); |
| 219 return net::IPEndPoint(ip, port); | 219 return net::IPEndPoint(ip, port); |
| 220 } | 220 } |
| OLD | NEW |