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_connection_helper.h" | 5 #include "net/quic/quic_connection_helper.h" |
6 | 6 |
7 #include "base/location.h" | 7 #include "base/location.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/metrics/sparse_histogram.h" | 9 #include "base/metrics/sparse_histogram.h" |
10 #include "base/task_runner.h" | 10 #include "base/task_runner.h" |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 scoped_refptr<StringIOBuffer> buf( | 119 scoped_refptr<StringIOBuffer> buf( |
120 new StringIOBuffer(std::string(packet.data(), | 120 new StringIOBuffer(std::string(packet.data(), |
121 packet.length()))); | 121 packet.length()))); |
122 int rv = socket_->Write(buf.get(), | 122 int rv = socket_->Write(buf.get(), |
123 packet.length(), | 123 packet.length(), |
124 base::Bind(&QuicConnectionHelper::OnWriteComplete, | 124 base::Bind(&QuicConnectionHelper::OnWriteComplete, |
125 weak_factory_.GetWeakPtr())); | 125 weak_factory_.GetWeakPtr())); |
126 if (rv >= 0) { | 126 if (rv >= 0) { |
127 *error = 0; | 127 *error = 0; |
128 } else { | 128 } else { |
129 UMA_HISTOGRAM_SPARSE_SLOWLY("Net.QuicSession.WriteError", -rv); | 129 if (rv != ERR_IO_PENDING) { |
| 130 UMA_HISTOGRAM_SPARSE_SLOWLY("Net.QuicSession.WriteError", -rv); |
| 131 } |
130 *error = rv; | 132 *error = rv; |
131 rv = -1; | 133 rv = -1; |
132 } | 134 } |
133 return rv; | 135 return rv; |
134 } | 136 } |
135 | 137 |
136 bool QuicConnectionHelper::IsWriteBlockedDataBuffered() { | 138 bool QuicConnectionHelper::IsWriteBlockedDataBuffered() { |
137 // Chrome sockets' Write() methods buffer the data until the Write is | 139 // Chrome sockets' Write() methods buffer the data until the Write is |
138 // permitted. | 140 // permitted. |
139 return true; | 141 return true; |
140 } | 142 } |
141 | 143 |
142 bool QuicConnectionHelper::IsWriteBlocked(int error) { | 144 bool QuicConnectionHelper::IsWriteBlocked(int error) { |
143 return error == ERR_IO_PENDING; | 145 return error == ERR_IO_PENDING; |
144 } | 146 } |
145 | 147 |
146 QuicAlarm* QuicConnectionHelper::CreateAlarm(QuicAlarm::Delegate* delegate) { | 148 QuicAlarm* QuicConnectionHelper::CreateAlarm(QuicAlarm::Delegate* delegate) { |
147 return new QuicChromeAlarm(clock_, task_runner_, delegate); | 149 return new QuicChromeAlarm(clock_, task_runner_, delegate); |
148 } | 150 } |
149 | 151 |
150 void QuicConnectionHelper::OnWriteComplete(int result) { | 152 void QuicConnectionHelper::OnWriteComplete(int result) { |
151 // TODO(rch): Inform the connection about the result. | 153 // TODO(rch): Inform the connection about the result. |
152 connection_->OnCanWrite(); | 154 connection_->OnCanWrite(); |
153 } | 155 } |
154 | 156 |
155 } // namespace net | 157 } // namespace net |
OLD | NEW |