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 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
318 delete session; | 319 delete session; |
319 } | 320 } |
320 | 321 |
321 void QuicStreamFactory::CancelRequest(QuicStreamRequest* request) { | 322 void QuicStreamFactory::CancelRequest(QuicStreamRequest* request) { |
322 DCHECK(ContainsKey(active_requests_, request)); | 323 DCHECK(ContainsKey(active_requests_, request)); |
323 Job* job = active_requests_[request]; | 324 Job* job = active_requests_[request]; |
324 job_requests_map_[job].erase(request); | 325 job_requests_map_[job].erase(request); |
325 active_requests_.erase(request); | 326 active_requests_.erase(request); |
326 } | 327 } |
327 | 328 |
| 329 base::Value* QuicStreamFactory::QuicStreamFactoryInfoToValue() const { |
| 330 base::ListValue* list = new base::ListValue(); |
| 331 |
| 332 for (SessionMap::const_iterator it = active_sessions_.begin(); |
| 333 it != active_sessions_.end(); ++it) { |
| 334 const HostPortProxyPair& pair = it->first; |
| 335 const QuicClientSession* session = it->second; |
| 336 |
| 337 list->Append(session->GetInfoAsValue(pair.first)); |
| 338 } |
| 339 return list; |
| 340 } |
| 341 |
328 bool QuicStreamFactory::HasActiveSession( | 342 bool QuicStreamFactory::HasActiveSession( |
329 const HostPortProxyPair& host_port_proxy_pair) { | 343 const HostPortProxyPair& host_port_proxy_pair) { |
330 return ContainsKey(active_sessions_, host_port_proxy_pair); | 344 return ContainsKey(active_sessions_, host_port_proxy_pair); |
331 } | 345 } |
332 | 346 |
333 QuicClientSession* QuicStreamFactory::CreateSession( | 347 QuicClientSession* QuicStreamFactory::CreateSession( |
334 const AddressList& address_list_, | 348 const AddressList& address_list_, |
335 const BoundNetLog& net_log) { | 349 const BoundNetLog& net_log) { |
336 QuicGuid guid = random_generator_->RandUint64(); | 350 QuicGuid guid = random_generator_->RandUint64(); |
337 IPEndPoint addr = *address_list_.begin(); | 351 IPEndPoint addr = *address_list_.begin(); |
(...skipping 22 matching lines...) Expand all Loading... |
360 void QuicStreamFactory::ActivateSession( | 374 void QuicStreamFactory::ActivateSession( |
361 const HostPortProxyPair& host_port_proxy_pair, | 375 const HostPortProxyPair& host_port_proxy_pair, |
362 QuicClientSession* session) { | 376 QuicClientSession* session) { |
363 DCHECK(!HasActiveSession(host_port_proxy_pair)); | 377 DCHECK(!HasActiveSession(host_port_proxy_pair)); |
364 active_sessions_[host_port_proxy_pair] = session; | 378 active_sessions_[host_port_proxy_pair] = session; |
365 session_aliases_[session].insert(host_port_proxy_pair); | 379 session_aliases_[session].insert(host_port_proxy_pair); |
366 } | 380 } |
367 | 381 |
368 | 382 |
369 } // namespace net | 383 } // namespace net |
OLD | NEW |