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/task_runner.h" | 9 #include "base/task_runner.h" |
10 #include "base/time.h" | 10 #include "base/time.h" |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 int* error) { | 51 int* error) { |
52 if (connection_->ShouldSimulateLostPacket()) { | 52 if (connection_->ShouldSimulateLostPacket()) { |
53 DLOG(INFO) << "Dropping packet due to fake packet loss."; | 53 DLOG(INFO) << "Dropping packet due to fake packet loss."; |
54 *error = 0; | 54 *error = 0; |
55 return packet.length(); | 55 return packet.length(); |
56 } | 56 } |
57 | 57 |
58 scoped_refptr<StringIOBuffer> buf( | 58 scoped_refptr<StringIOBuffer> buf( |
59 new StringIOBuffer(std::string(packet.data(), | 59 new StringIOBuffer(std::string(packet.data(), |
60 packet.length()))); | 60 packet.length()))); |
61 int rv = socket_->Write(buf, packet.length(), | 61 int rv = socket_->Write(buf.get(), |
| 62 packet.length(), |
62 base::Bind(&QuicConnectionHelper::OnWriteComplete, | 63 base::Bind(&QuicConnectionHelper::OnWriteComplete, |
63 weak_factory_.GetWeakPtr())); | 64 weak_factory_.GetWeakPtr())); |
64 if (rv >= 0) { | 65 if (rv >= 0) { |
65 *error = 0; | 66 *error = 0; |
66 } else { | 67 } else { |
67 *error = rv; | 68 *error = rv; |
68 rv = -1; | 69 rv = -1; |
69 } | 70 } |
70 return rv; | 71 return rv; |
71 } | 72 } |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 ack_alarm_time_ = QuicTime::Zero(); | 173 ack_alarm_time_ = QuicTime::Zero(); |
173 connection_->SendAck(); | 174 connection_->SendAck(); |
174 } | 175 } |
175 | 176 |
176 void QuicConnectionHelper::OnWriteComplete(int result) { | 177 void QuicConnectionHelper::OnWriteComplete(int result) { |
177 // TODO(rch): Inform the connection about the result. | 178 // TODO(rch): Inform the connection about the result. |
178 connection_->OnCanWrite(); | 179 connection_->OnCanWrite(); |
179 } | 180 } |
180 | 181 |
181 } // namespace net | 182 } // namespace net |
OLD | NEW |