OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <stddef.h> | 5 #include <stddef.h> |
6 #include <stdint.h> | 6 #include <stdint.h> |
7 | 7 |
8 #include <algorithm> | 8 #include <algorithm> |
| 9 #include <map> |
9 #include <memory> | 10 #include <memory> |
10 #include <set> | 11 #include <set> |
11 | 12 |
12 #include "base/base64.h" | 13 #include "base/base64.h" |
13 #include "base/bind.h" | 14 #include "base/bind.h" |
14 #include "base/callback.h" | 15 #include "base/callback.h" |
15 #include "base/command_line.h" | 16 #include "base/command_line.h" |
16 #include "base/json/json_string_value_serializer.h" | 17 #include "base/json/json_string_value_serializer.h" |
17 #include "base/macros.h" | 18 #include "base/macros.h" |
18 #include "base/memory/ptr_util.h" | 19 #include "base/memory/ptr_util.h" |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 enum SocketStatus { SOCKET_ACCEPTED, SOCKET_READ_FROM }; | 249 enum SocketStatus { SOCKET_ACCEPTED, SOCKET_READ_FROM }; |
249 | 250 |
250 base::RunLoop accept_loop_; | 251 base::RunLoop accept_loop_; |
251 base::RunLoop read_loop_; | 252 base::RunLoop read_loop_; |
252 | 253 |
253 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | 254 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
254 | 255 |
255 // This lock protects all the members below, which each are used on both the | 256 // This lock protects all the members below, which each are used on both the |
256 // IO and UI thread. Members declared after the lock are protected by it. | 257 // IO and UI thread. Members declared after the lock are protected by it. |
257 mutable base::Lock lock_; | 258 mutable base::Lock lock_; |
258 typedef base::hash_map<uint16_t, SocketStatus> SocketContainer; | 259 typedef std::map<uint16_t, SocketStatus> SocketContainer; |
259 SocketContainer sockets_; | 260 SocketContainer sockets_; |
260 | 261 |
261 // If |num_accepted_connections_needed_| is non zero, then the object is | 262 // If |num_accepted_connections_needed_| is non zero, then the object is |
262 // waiting for |num_accepted_connections_needed_| sockets to be accepted | 263 // waiting for |num_accepted_connections_needed_| sockets to be accepted |
263 // before quitting the |num_accepted_connections_loop_|. | 264 // before quitting the |num_accepted_connections_loop_|. |
264 size_t num_accepted_connections_needed_; | 265 size_t num_accepted_connections_needed_; |
265 base::RunLoop* num_accepted_connections_loop_; | 266 base::RunLoop* num_accepted_connections_loop_; |
266 | 267 |
267 DISALLOW_COPY_AND_ASSIGN(ConnectionListener); | 268 DISALLOW_COPY_AND_ASSIGN(ConnectionListener); |
268 }; | 269 }; |
(...skipping 1315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1584 // Second navigation to content with an img. | 1585 // Second navigation to content with an img. |
1585 std::string img_content = | 1586 std::string img_content = |
1586 "<img src=\"" + preconnect_url.spec() + "test.gif\">"; | 1587 "<img src=\"" + preconnect_url.spec() + "test.gif\">"; |
1587 NavigateToDataURLWithContent(img_content); | 1588 NavigateToDataURLWithContent(img_content); |
1588 connection_listener_->WaitUntilFirstConnectionRead(); | 1589 connection_listener_->WaitUntilFirstConnectionRead(); |
1589 EXPECT_EQ(2u, connection_listener_->GetAcceptedSocketCount()); | 1590 EXPECT_EQ(2u, connection_listener_->GetAcceptedSocketCount()); |
1590 EXPECT_EQ(1u, connection_listener_->GetReadSocketCount()); | 1591 EXPECT_EQ(1u, connection_listener_->GetReadSocketCount()); |
1591 } | 1592 } |
1592 | 1593 |
1593 } // namespace chrome_browser_net | 1594 } // namespace chrome_browser_net |
OLD | NEW |