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_client_session.h" | 5 #include "net/quic/quic_client_session.h" |
6 | 6 |
7 #include "base/callback_helpers.h" | 7 #include "base/callback_helpers.h" |
8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
10 #include "base/metrics/sparse_histogram.h" | 10 #include "base/metrics/sparse_histogram.h" |
(...skipping 812 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
823 } | 823 } |
824 | 824 |
825 void QuicClientSession::CloseAllObservers(int net_error) { | 825 void QuicClientSession::CloseAllObservers(int net_error) { |
826 while (!observers_.empty()) { | 826 while (!observers_.empty()) { |
827 Observer* observer = *observers_.begin(); | 827 Observer* observer = *observers_.begin(); |
828 observers_.erase(observer); | 828 observers_.erase(observer); |
829 observer->OnSessionClosed(net_error); | 829 observer->OnSessionClosed(net_error); |
830 } | 830 } |
831 } | 831 } |
832 | 832 |
833 base::Value* QuicClientSession::GetInfoAsValue( | 833 scoped_ptr<base::Value> QuicClientSession::GetInfoAsValue( |
834 const std::set<HostPortPair>& aliases) { | 834 const std::set<HostPortPair>& aliases) { |
835 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); | 835 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); |
836 dict->SetString("version", QuicVersionToString(connection()->version())); | 836 dict->SetString("version", QuicVersionToString(connection()->version())); |
837 dict->SetInteger("open_streams", GetNumOpenStreams()); | 837 dict->SetInteger("open_streams", GetNumOpenStreams()); |
838 base::ListValue* stream_list = new base::ListValue(); | 838 scoped_ptr<base::ListValue> stream_list(new base::ListValue()); |
839 for (base::hash_map<QuicStreamId, QuicDataStream*>::const_iterator it | 839 for (base::hash_map<QuicStreamId, QuicDataStream*>::const_iterator it |
840 = streams()->begin(); | 840 = streams()->begin(); |
841 it != streams()->end(); | 841 it != streams()->end(); |
842 ++it) { | 842 ++it) { |
843 stream_list->Append(new base::StringValue( | 843 stream_list->Append(new base::StringValue( |
844 base::Uint64ToString(it->second->id()))); | 844 base::Uint64ToString(it->second->id()))); |
845 } | 845 } |
846 dict->Set("active_streams", stream_list); | 846 dict->Set("active_streams", stream_list.Pass()); |
847 | 847 |
848 dict->SetInteger("total_streams", num_total_streams_); | 848 dict->SetInteger("total_streams", num_total_streams_); |
849 dict->SetString("peer_address", peer_address().ToString()); | 849 dict->SetString("peer_address", peer_address().ToString()); |
850 dict->SetString("connection_id", base::Uint64ToString(connection_id())); | 850 dict->SetString("connection_id", base::Uint64ToString(connection_id())); |
851 dict->SetBoolean("connected", connection()->connected()); | 851 dict->SetBoolean("connected", connection()->connected()); |
852 const QuicConnectionStats& stats = connection()->GetStats(); | 852 const QuicConnectionStats& stats = connection()->GetStats(); |
853 dict->SetInteger("packets_sent", stats.packets_sent); | 853 dict->SetInteger("packets_sent", stats.packets_sent); |
854 dict->SetInteger("packets_received", stats.packets_received); | 854 dict->SetInteger("packets_received", stats.packets_received); |
855 dict->SetInteger("packets_lost", stats.packets_lost); | 855 dict->SetInteger("packets_lost", stats.packets_lost); |
856 SSLInfo ssl_info; | 856 SSLInfo ssl_info; |
857 dict->SetBoolean("secure", GetSSLInfo(&ssl_info) && ssl_info.cert.get()); | 857 dict->SetBoolean("secure", GetSSLInfo(&ssl_info) && ssl_info.cert.get()); |
858 | 858 |
859 base::ListValue* alias_list = new base::ListValue(); | 859 scoped_ptr<base::ListValue> alias_list(new base::ListValue()); |
860 for (std::set<HostPortPair>::const_iterator it = aliases.begin(); | 860 for (std::set<HostPortPair>::const_iterator it = aliases.begin(); |
861 it != aliases.end(); it++) { | 861 it != aliases.end(); it++) { |
862 alias_list->Append(new base::StringValue(it->ToString())); | 862 alias_list->Append(new base::StringValue(it->ToString())); |
863 } | 863 } |
864 dict->Set("aliases", alias_list); | 864 dict->Set("aliases", alias_list.Pass()); |
865 | 865 |
866 return dict.release(); | 866 return dict.Pass(); |
867 } | 867 } |
868 | 868 |
869 base::WeakPtr<QuicClientSession> QuicClientSession::GetWeakPtr() { | 869 base::WeakPtr<QuicClientSession> QuicClientSession::GetWeakPtr() { |
870 return weak_factory_.GetWeakPtr(); | 870 return weak_factory_.GetWeakPtr(); |
871 } | 871 } |
872 | 872 |
873 void QuicClientSession::OnReadError(int result) { | 873 void QuicClientSession::OnReadError(int result) { |
874 DVLOG(1) << "Closing session on read error: " << result; | 874 DVLOG(1) << "Closing session on read error: " << result; |
875 UMA_HISTOGRAM_SPARSE_SLOWLY("Net.QuicSession.ReadError", -result); | 875 UMA_HISTOGRAM_SPARSE_SLOWLY("Net.QuicSession.ReadError", -result); |
876 NotifyFactoryOfSessionGoingAway(); | 876 NotifyFactoryOfSessionGoingAway(); |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
933 return; | 933 return; |
934 | 934 |
935 // TODO(rch): re-enable this code once beta is cut. | 935 // TODO(rch): re-enable this code once beta is cut. |
936 // if (stream_factory_) | 936 // if (stream_factory_) |
937 // stream_factory_->OnSessionConnectTimeout(this); | 937 // stream_factory_->OnSessionConnectTimeout(this); |
938 // CloseAllStreams(ERR_QUIC_HANDSHAKE_FAILED); | 938 // CloseAllStreams(ERR_QUIC_HANDSHAKE_FAILED); |
939 // DCHECK_EQ(0u, GetNumOpenStreams()); | 939 // DCHECK_EQ(0u, GetNumOpenStreams()); |
940 } | 940 } |
941 | 941 |
942 } // namespace net | 942 } // namespace net |
OLD | NEW |