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

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

Issue 149263002: Refactor QuicConnection to use explicit notification for getting onto (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') | no next file » | 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 e5fecc962b4ab03436a7ab564b6e850ed2a89732..4604209c4cffff77c145af4a7ba86575e1044a34 100644
--- a/net/tools/quic/quic_dispatcher.cc
+++ b/net/tools/quic/quic_dispatcher.cc
@@ -150,38 +150,6 @@ void QuicDispatcher::Initialize(int fd) {
epoll_server(), supported_versions()));
}
-// 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 (IsWriteBlocked()) {
- write_blocked_list_.insert(make_pair(writer, true));
- return WriteResult(WRITE_STATUS_BLOCKED, EAGAIN);
- }
-
- 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));
- }
- return result;
-}
-
-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) {
@@ -273,7 +241,7 @@ void QuicDispatcher::DeleteSessions() {
bool QuicDispatcher::OnCanWrite() {
// We got an EPOLLOUT: the socket should not be blocked.
- SetWritable();
+ writer_->SetWritable();
// Give each writer one attempt to write.
int num_writers = write_blocked_list_.size();
@@ -284,7 +252,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 (IsWriteBlocked()) {
+ if (writer_->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.
@@ -336,24 +304,33 @@ void QuicDispatcher::OnWriteBlocked(QuicBlockedWriterInterface* writer) {
write_blocked_list_.insert(make_pair(writer, true));
}
+QuicPacketWriter* QuicDispatcher::CreateWriter(int fd) {
+ return new QuicDefaultPacketWriter(fd);
+}
+
+QuicPacketWriterWrapper* QuicDispatcher::CreateWriterWrapper(
+ QuicPacketWriter* writer) {
+ return new QuicPacketWriterWrapper(writer);
+}
+
QuicSession* QuicDispatcher::CreateQuicSession(
QuicGuid guid,
const IPEndPoint& server_address,
const IPEndPoint& client_address) {
QuicServerSession* session = new QuicServerSession(
- config_, new QuicConnection(guid, client_address, helper_.get(), this,
- true, supported_versions_), this);
+ config_,
+ CreateQuicConnection(guid, server_address, client_address),
+ this);
session->InitializeSession(crypto_config_);
return session;
}
-QuicPacketWriter* QuicDispatcher::CreateWriter(int fd) {
- return new QuicDefaultPacketWriter(fd);
-}
-
-QuicPacketWriterWrapper* QuicDispatcher::CreateWriterWrapper(
- QuicPacketWriter* writer) {
- return new QuicPacketWriterWrapper(writer);
+QuicConnection* QuicDispatcher::CreateQuicConnection(
+ QuicGuid guid,
+ const IPEndPoint& server_address,
+ const IPEndPoint& client_address) {
+ return new QuicConnection(guid, client_address, helper_.get(), writer_.get(),
+ true, supported_versions_);
}
void QuicDispatcher::set_writer(QuicPacketWriter* writer) {
« no previous file with comments | « net/tools/quic/quic_dispatcher.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698