Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(570)

Side by Side Diff: net/tools/quic/quic_simple_server_packet_writer.cc

Issue 1660533002: Landing Recent QUIC changes until 01/26/2016 18:14 UTC (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/tools/quic/quic_simple_server_packet_writer.h" 5 #include "net/tools/quic/quic_simple_server_packet_writer.h"
6 6
7 #include "base/callback_helpers.h" 7 #include "base/callback_helpers.h"
8 #include "base/location.h" 8 #include "base/location.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/metrics/sparse_histogram.h" 10 #include "base/metrics/sparse_histogram.h"
(...skipping 11 matching lines...) Expand all
22 write_blocked_(false), 22 write_blocked_(false),
23 weak_factory_(this) {} 23 weak_factory_(this) {}
24 24
25 QuicSimpleServerPacketWriter::~QuicSimpleServerPacketWriter() {} 25 QuicSimpleServerPacketWriter::~QuicSimpleServerPacketWriter() {}
26 26
27 WriteResult QuicSimpleServerPacketWriter::WritePacketWithCallback( 27 WriteResult QuicSimpleServerPacketWriter::WritePacketWithCallback(
28 const char* buffer, 28 const char* buffer,
29 size_t buf_len, 29 size_t buf_len,
30 const IPAddressNumber& self_address, 30 const IPAddressNumber& self_address,
31 const IPEndPoint& peer_address, 31 const IPEndPoint& peer_address,
32 PerPacketOptions* options,
32 WriteCallback callback) { 33 WriteCallback callback) {
33 DCHECK(callback_.is_null()); 34 DCHECK(callback_.is_null());
34 callback_ = callback; 35 callback_ = callback;
35 WriteResult result = WritePacket(buffer, buf_len, self_address, peer_address); 36 WriteResult result =
37 WritePacket(buffer, buf_len, self_address, peer_address, options);
36 if (result.status != WRITE_STATUS_BLOCKED) { 38 if (result.status != WRITE_STATUS_BLOCKED) {
37 callback_.Reset(); 39 callback_.Reset();
38 } 40 }
39 return result; 41 return result;
40 } 42 }
41 43
42 void QuicSimpleServerPacketWriter::OnWriteComplete(int rv) { 44 void QuicSimpleServerPacketWriter::OnWriteComplete(int rv) {
43 DCHECK_NE(rv, ERR_IO_PENDING); 45 DCHECK_NE(rv, ERR_IO_PENDING);
44 write_blocked_ = false; 46 write_blocked_ = false;
45 WriteResult result(rv < 0 ? WRITE_STATUS_ERROR : WRITE_STATUS_OK, rv); 47 WriteResult result(rv < 0 ? WRITE_STATUS_ERROR : WRITE_STATUS_OK, rv);
(...skipping 11 matching lines...) Expand all
57 } 59 }
58 60
59 void QuicSimpleServerPacketWriter::SetWritable() { 61 void QuicSimpleServerPacketWriter::SetWritable() {
60 write_blocked_ = false; 62 write_blocked_ = false;
61 } 63 }
62 64
63 WriteResult QuicSimpleServerPacketWriter::WritePacket( 65 WriteResult QuicSimpleServerPacketWriter::WritePacket(
64 const char* buffer, 66 const char* buffer,
65 size_t buf_len, 67 size_t buf_len,
66 const IPAddressNumber& self_address, 68 const IPAddressNumber& self_address,
67 const IPEndPoint& peer_address) { 69 const IPEndPoint& peer_address,
70 PerPacketOptions* options) {
68 scoped_refptr<StringIOBuffer> buf( 71 scoped_refptr<StringIOBuffer> buf(
69 new StringIOBuffer(std::string(buffer, buf_len))); 72 new StringIOBuffer(std::string(buffer, buf_len)));
70 DCHECK(!IsWriteBlocked()); 73 DCHECK(!IsWriteBlocked());
71 DCHECK(!callback_.is_null()); 74 DCHECK(!callback_.is_null());
72 int rv; 75 int rv;
73 if (buf_len <= static_cast<size_t>(std::numeric_limits<int>::max())) { 76 if (buf_len <= static_cast<size_t>(std::numeric_limits<int>::max())) {
74 rv = socket_->SendTo( 77 rv = socket_->SendTo(
75 buf.get(), static_cast<int>(buf_len), peer_address, 78 buf.get(), static_cast<int>(buf_len), peer_address,
76 base::Bind(&QuicSimpleServerPacketWriter::OnWriteComplete, 79 base::Bind(&QuicSimpleServerPacketWriter::OnWriteComplete,
77 weak_factory_.GetWeakPtr())); 80 weak_factory_.GetWeakPtr()));
(...skipping 12 matching lines...) Expand all
90 } 93 }
91 return WriteResult(status, rv); 94 return WriteResult(status, rv);
92 } 95 }
93 96
94 QuicByteCount QuicSimpleServerPacketWriter::GetMaxPacketSize( 97 QuicByteCount QuicSimpleServerPacketWriter::GetMaxPacketSize(
95 const IPEndPoint& peer_address) const { 98 const IPEndPoint& peer_address) const {
96 return kMaxPacketSize; 99 return kMaxPacketSize;
97 } 100 }
98 101
99 } // namespace net 102 } // namespace net
OLDNEW
« no previous file with comments | « net/tools/quic/quic_simple_server_packet_writer.h ('k') | net/tools/quic/quic_simple_server_stream_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698