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/message_loop.h" | 7 #include "base/message_loop.h" |
8 #include "base/stl_util.h" | 8 #include "base/stl_util.h" |
9 #include "base/string_number_conversions.h" | |
10 #include "base/values.h" | |
9 #include "net/base/io_buffer.h" | 11 #include "net/base/io_buffer.h" |
10 #include "net/base/net_errors.h" | 12 #include "net/base/net_errors.h" |
11 #include "net/quic/quic_connection_helper.h" | 13 #include "net/quic/quic_connection_helper.h" |
12 #include "net/quic/quic_stream_factory.h" | 14 #include "net/quic/quic_stream_factory.h" |
13 #include "net/udp/datagram_client_socket.h" | 15 #include "net/udp/datagram_client_socket.h" |
14 | 16 |
15 namespace net { | 17 namespace net { |
16 | 18 |
17 QuicClientSession::QuicClientSession(QuicConnection* connection, | 19 QuicClientSession::QuicClientSession(QuicConnection* connection, |
18 QuicConnectionHelper* helper, | 20 QuicConnectionHelper* helper, |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
96 | 98 |
97 // Data was read, process it. | 99 // Data was read, process it. |
98 // Schedule the work through the message loop to avoid recursive | 100 // Schedule the work through the message loop to avoid recursive |
99 // callbacks. | 101 // callbacks. |
100 MessageLoop::current()->PostTask( | 102 MessageLoop::current()->PostTask( |
101 FROM_HERE, | 103 FROM_HERE, |
102 base::Bind(&QuicClientSession::OnReadComplete, | 104 base::Bind(&QuicClientSession::OnReadComplete, |
103 weak_factory_.GetWeakPtr(), rv)); | 105 weak_factory_.GetWeakPtr(), rv)); |
104 } | 106 } |
105 | 107 |
108 Value* QuicClientSession::GetInfoAsValue(const HostPortPair& pair) const { | |
109 DictionaryValue* dict = new DictionaryValue(); | |
110 //dict->SetInteger("source_id", net_log_.source().id); | |
eroman
2013/01/04 00:16:14
If unused, then delete this line.
Ryan Hamilton
2013/01/04 02:56:05
Done.
| |
111 dict->SetString("host_port_pair", pair.ToString()); | |
112 dict->SetInteger("open_streams", GetNumOpenStreams()); | |
113 dict->SetString("peer_address", peer_address().ToString()); | |
114 dict->SetString("guid", base::Uint64ToString(guid())); | |
115 return dict; | |
116 } | |
117 | |
106 void QuicClientSession::OnReadComplete(int result) { | 118 void QuicClientSession::OnReadComplete(int result) { |
107 read_pending_ = false; | 119 read_pending_ = false; |
108 // TODO(rch): Inform the connection about the result. | 120 // TODO(rch): Inform the connection about the result. |
109 if (result > 0) { | 121 if (result > 0) { |
110 scoped_refptr<IOBufferWithSize> buffer(read_buffer_); | 122 scoped_refptr<IOBufferWithSize> buffer(read_buffer_); |
111 read_buffer_ = new IOBufferWithSize(kMaxPacketSize); | 123 read_buffer_ = new IOBufferWithSize(kMaxPacketSize); |
112 QuicEncryptedPacket packet(buffer->data(), result); | 124 QuicEncryptedPacket packet(buffer->data(), result); |
113 IPEndPoint local_address; | 125 IPEndPoint local_address; |
114 IPEndPoint peer_address; | 126 IPEndPoint peer_address; |
115 helper_->GetLocalAddress(&local_address); | 127 helper_->GetLocalAddress(&local_address); |
116 helper_->GetPeerAddress(&peer_address); | 128 helper_->GetPeerAddress(&peer_address); |
117 // ProcessUdpPacket might result in |this| being deleted, so we | 129 // ProcessUdpPacket might result in |this| being deleted, so we |
118 // use a weak pointer to be safe. | 130 // use a weak pointer to be safe. |
119 connection()->ProcessUdpPacket(local_address, peer_address, packet); | 131 connection()->ProcessUdpPacket(local_address, peer_address, packet); |
120 if (!connection()->connected()) { | 132 if (!connection()->connected()) { |
121 stream_factory_->OnSessionClose(this); | 133 stream_factory_->OnSessionClose(this); |
122 return; | 134 return; |
123 } | 135 } |
124 StartReading(); | 136 StartReading(); |
125 } | 137 } |
126 } | 138 } |
127 | 139 |
128 } // namespace net | 140 } // namespace net |
OLD | NEW |