OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_tcp.h" | 5 #include "content/browser/renderer_host/p2p/socket_host_tcp.h" |
6 | 6 |
7 #include <deque> | 7 #include <deque> |
8 | 8 |
9 #include "base/sys_byteorder.h" | 9 #include "base/sys_byteorder.h" |
10 #include "content/browser/renderer_host/p2p/socket_host_test_utils.h" | 10 #include "content/browser/renderer_host/p2p/socket_host_test_utils.h" |
(...skipping 24 matching lines...) Expand all Loading... |
35 | 35 |
36 local_address_ = ParseAddress(kTestLocalIpAddress, kTestPort1); | 36 local_address_ = ParseAddress(kTestLocalIpAddress, kTestPort1); |
37 | 37 |
38 socket_host_->remote_address_ = dest_; | 38 socket_host_->remote_address_ = dest_; |
39 socket_host_->state_ = P2PSocketHost::STATE_CONNECTING; | 39 socket_host_->state_ = P2PSocketHost::STATE_CONNECTING; |
40 socket_host_->OnConnected(net::OK); | 40 socket_host_->OnConnected(net::OK); |
41 } | 41 } |
42 | 42 |
43 std::string IntToSize(int size) { | 43 std::string IntToSize(int size) { |
44 std::string result; | 44 std::string result; |
45 uint16 size16 = htons(size); | 45 uint16 size16 = base::HostToNet16(size); |
46 result.resize(sizeof(size16)); | 46 result.resize(sizeof(size16)); |
47 memcpy(&result[0], &size16, sizeof(size16)); | 47 memcpy(&result[0], &size16, sizeof(size16)); |
48 return result; | 48 return result; |
49 } | 49 } |
50 | 50 |
51 std::string sent_data_; | 51 std::string sent_data_; |
52 FakeSocket* socket_; // Owned by |socket_host_|. | 52 FakeSocket* socket_; // Owned by |socket_host_|. |
53 scoped_ptr<P2PSocketHostTcp> socket_host_; | 53 scoped_ptr<P2PSocketHostTcp> socket_host_; |
54 MockIPCSender sender_; | 54 MockIPCSender sender_; |
55 | 55 |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 socket_host_->Send(dest_, packet); | 162 socket_host_->Send(dest_, packet); |
163 | 163 |
164 std::string expected_data; | 164 std::string expected_data; |
165 expected_data.append(IntToSize(packet.size())); | 165 expected_data.append(IntToSize(packet.size())); |
166 expected_data.append(packet.begin(), packet.end()); | 166 expected_data.append(packet.begin(), packet.end()); |
167 | 167 |
168 EXPECT_EQ(expected_data, sent_data_); | 168 EXPECT_EQ(expected_data, sent_data_); |
169 } | 169 } |
170 | 170 |
171 } // namespace content | 171 } // namespace content |
OLD | NEW |