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 "net/quic/quic_stream_factory.h" | 5 #include "net/quic/quic_stream_factory.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 | 8 |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "base/message_loop_proxy.h" | 10 #include "base/message_loop_proxy.h" |
11 #include "base/rand_util.h" | 11 #include "base/rand_util.h" |
12 #include "base/stl_util.h" | 12 #include "base/stl_util.h" |
| 13 #include "base/values.h" |
13 #include "net/base/host_resolver.h" | 14 #include "net/base/host_resolver.h" |
14 #include "net/base/net_errors.h" | 15 #include "net/base/net_errors.h" |
15 #include "net/base/single_request_host_resolver.h" | 16 #include "net/base/single_request_host_resolver.h" |
16 #include "net/quic/crypto/quic_random.h" | 17 #include "net/quic/crypto/quic_random.h" |
17 #include "net/quic/quic_client_session.h" | 18 #include "net/quic/quic_client_session.h" |
18 #include "net/quic/quic_clock.h" | 19 #include "net/quic/quic_clock.h" |
19 #include "net/quic/quic_connection.h" | 20 #include "net/quic/quic_connection.h" |
20 #include "net/quic/quic_connection_helper.h" | 21 #include "net/quic/quic_connection_helper.h" |
21 #include "net/quic/quic_http_stream.h" | 22 #include "net/quic/quic_http_stream.h" |
22 #include "net/quic/quic_protocol.h" | 23 #include "net/quic/quic_protocol.h" |
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
326 active_requests_.erase(request); | 327 active_requests_.erase(request); |
327 } | 328 } |
328 | 329 |
329 void QuicStreamFactory::CloseAllSessions(int error) { | 330 void QuicStreamFactory::CloseAllSessions(int error) { |
330 while (!active_sessions_.empty()) { | 331 while (!active_sessions_.empty()) { |
331 active_sessions_.begin()->second->CloseSessionOnError(error); | 332 active_sessions_.begin()->second->CloseSessionOnError(error); |
332 } | 333 } |
333 DCHECK(all_sessions_.empty()); | 334 DCHECK(all_sessions_.empty()); |
334 } | 335 } |
335 | 336 |
| 337 base::Value* QuicStreamFactory::QuicStreamFactoryInfoToValue() const { |
| 338 base::ListValue* list = new base::ListValue(); |
| 339 |
| 340 for (SessionMap::const_iterator it = active_sessions_.begin(); |
| 341 it != active_sessions_.end(); ++it) { |
| 342 const HostPortProxyPair& pair = it->first; |
| 343 const QuicClientSession* session = it->second; |
| 344 |
| 345 list->Append(session->GetInfoAsValue(pair.first)); |
| 346 } |
| 347 return list; |
| 348 } |
| 349 |
336 bool QuicStreamFactory::HasActiveSession( | 350 bool QuicStreamFactory::HasActiveSession( |
337 const HostPortProxyPair& host_port_proxy_pair) { | 351 const HostPortProxyPair& host_port_proxy_pair) { |
338 return ContainsKey(active_sessions_, host_port_proxy_pair); | 352 return ContainsKey(active_sessions_, host_port_proxy_pair); |
339 } | 353 } |
340 | 354 |
341 QuicClientSession* QuicStreamFactory::CreateSession( | 355 QuicClientSession* QuicStreamFactory::CreateSession( |
342 const AddressList& address_list_, | 356 const AddressList& address_list_, |
343 const BoundNetLog& net_log) { | 357 const BoundNetLog& net_log) { |
344 QuicGuid guid = random_generator_->RandUint64(); | 358 QuicGuid guid = random_generator_->RandUint64(); |
345 IPEndPoint addr = *address_list_.begin(); | 359 IPEndPoint addr = *address_list_.begin(); |
(...skipping 22 matching lines...) Expand all Loading... |
368 void QuicStreamFactory::ActivateSession( | 382 void QuicStreamFactory::ActivateSession( |
369 const HostPortProxyPair& host_port_proxy_pair, | 383 const HostPortProxyPair& host_port_proxy_pair, |
370 QuicClientSession* session) { | 384 QuicClientSession* session) { |
371 DCHECK(!HasActiveSession(host_port_proxy_pair)); | 385 DCHECK(!HasActiveSession(host_port_proxy_pair)); |
372 active_sessions_[host_port_proxy_pair] = session; | 386 active_sessions_[host_port_proxy_pair] = session; |
373 session_aliases_[session].insert(host_port_proxy_pair); | 387 session_aliases_[session].insert(host_port_proxy_pair); |
374 } | 388 } |
375 | 389 |
376 | 390 |
377 } // namespace net | 391 } // namespace net |
OLD | NEW |