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

Unified Diff: net/tools/quic/quic_dispatcher.cc

Issue 127633002: Land Recent QUIC Changes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/tools/quic/quic_dispatcher.h ('k') | net/tools/quic/quic_dispatcher_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/tools/quic/quic_dispatcher.cc
diff --git a/net/tools/quic/quic_dispatcher.cc b/net/tools/quic/quic_dispatcher.cc
index 21070169a979d8e1f082f78bdddc1637be4db411..e684138f46a00f642480bee5936c47010f089100 100644
--- a/net/tools/quic/quic_dispatcher.cc
+++ b/net/tools/quic/quic_dispatcher.cc
@@ -132,7 +132,6 @@ QuicDispatcher::QuicDispatcher(const QuicConfig& config,
delete_sessions_alarm_(new DeleteSessionsAlarm(this)),
epoll_server_(epoll_server),
fd_(fd),
- write_blocked_(false),
helper_(new QuicEpollConnectionHelper(epoll_server_)),
writer_(new QuicDefaultPacketWriter(fd)),
supported_versions_(supported_versions),
@@ -152,11 +151,13 @@ void QuicDispatcher::set_fd(int fd) {
writer_.reset(new QuicDefaultPacketWriter(fd));
}
+// TODO(fnk): remove the Writer interface implementation in favor of
+// direct requests for blocked list placement from Connection/Session.
WriteResult QuicDispatcher::WritePacket(const char* buffer, size_t buf_len,
const IPAddressNumber& self_address,
const IPEndPoint& peer_address,
QuicBlockedWriterInterface* writer) {
- if (write_blocked_) {
+ if (IsWriteBlocked()) {
write_blocked_list_.insert(make_pair(writer, true));
return WriteResult(WRITE_STATUS_BLOCKED, EAGAIN);
}
@@ -164,8 +165,8 @@ WriteResult QuicDispatcher::WritePacket(const char* buffer, size_t buf_len,
WriteResult result =
writer_->WritePacket(buffer, buf_len, self_address, peer_address, writer);
if (result.status == WRITE_STATUS_BLOCKED) {
+ DCHECK(IsWriteBlocked());
write_blocked_list_.insert(make_pair(writer, true));
- write_blocked_ = true;
}
return result;
}
@@ -174,6 +175,14 @@ bool QuicDispatcher::IsWriteBlockedDataBuffered() const {
return writer_->IsWriteBlockedDataBuffered();
}
+bool QuicDispatcher::IsWriteBlocked() const {
+ return writer_->IsWriteBlocked();
+}
+
+void QuicDispatcher::SetWritable() {
+ writer_->SetWritable();
+}
+
void QuicDispatcher::ProcessPacket(const IPEndPoint& server_address,
const IPEndPoint& client_address,
const QuicEncryptedPacket& packet) {
@@ -263,13 +272,9 @@ void QuicDispatcher::DeleteSessions() {
STLDeleteElements(&closed_session_list_);
}
-void QuicDispatcher::UseWriter(QuicPacketWriter* writer) {
- writer_.reset(writer);
-}
-
bool QuicDispatcher::OnCanWrite() {
// We got an EPOLLOUT: the socket should not be blocked.
- write_blocked_ = false;
+ SetWritable();
// Give each writer one attempt to write.
int num_writers = write_blocked_list_.size();
@@ -280,7 +285,7 @@ bool QuicDispatcher::OnCanWrite() {
QuicBlockedWriterInterface* writer = write_blocked_list_.begin()->first;
write_blocked_list_.erase(write_blocked_list_.begin());
bool can_write_more = writer->OnCanWrite();
- if (write_blocked_) {
+ if (IsWriteBlocked()) {
// We were unable to write. Wait for the next EPOLLOUT.
// In this case, the session would have been added to the blocked list
// up in WritePacket.
« no previous file with comments | « net/tools/quic/quic_dispatcher.h ('k') | net/tools/quic/quic_dispatcher_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698