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

Unified Diff: remoting/protocol/channel_multiplexer.cc

Issue 1655433002: Remove done notifications from incoming message handlers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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 | « remoting/protocol/channel_multiplexer.h ('k') | remoting/protocol/client_control_dispatcher.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/protocol/channel_multiplexer.cc
diff --git a/remoting/protocol/channel_multiplexer.cc b/remoting/protocol/channel_multiplexer.cc
index 7625afbb2cdc446d17e2e4a0919ebd7350aa49bf..65d29c029f35f58c626eb4c4a515c2b9b013ec40 100644
--- a/remoting/protocol/channel_multiplexer.cc
+++ b/remoting/protocol/channel_multiplexer.cc
@@ -30,15 +30,9 @@ const int kMaxPacketSize = 1024;
class PendingPacket {
public:
- PendingPacket(scoped_ptr<MultiplexPacket> packet,
- const base::Closure& done_task)
- : packet(std::move(packet)),
- done_task(done_task),
- pos(0U) {
- }
- ~PendingPacket() {
- done_task.Run();
- }
+ PendingPacket(scoped_ptr<MultiplexPacket> packet)
+ : packet(std::move(packet)) {}
+ ~PendingPacket() {}
bool is_empty() { return pos >= packet->data().size(); }
@@ -51,8 +45,7 @@ class PendingPacket {
private:
scoped_ptr<MultiplexPacket> packet;
- base::Closure done_task;
- size_t pos;
+ size_t pos = 0U;
DISALLOW_COPY_AND_ASSIGN(PendingPacket);
};
@@ -82,8 +75,7 @@ class ChannelMultiplexer::MuxChannel {
// Called by ChannelMultiplexer.
scoped_ptr<P2PStreamSocket> CreateSocket();
- void OnIncomingPacket(scoped_ptr<MultiplexPacket> packet,
- const base::Closure& done_task);
+ void OnIncomingPacket(scoped_ptr<MultiplexPacket> packet);
void OnBaseChannelError(int error);
// Called by MuxSocket.
@@ -164,11 +156,10 @@ scoped_ptr<P2PStreamSocket> ChannelMultiplexer::MuxChannel::CreateSocket() {
}
void ChannelMultiplexer::MuxChannel::OnIncomingPacket(
- scoped_ptr<MultiplexPacket> packet,
- const base::Closure& done_task) {
+ scoped_ptr<MultiplexPacket> packet) {
DCHECK_EQ(packet->channel_id(), receive_id_);
if (packet->data().size() > 0) {
- pending_packets_.push_back(new PendingPacket(std::move(packet), done_task));
+ pending_packets_.push_back(new PendingPacket(std::move(packet)));
if (socket_) {
// Notify the socket that we have more data.
socket_->OnPacketReceived();
@@ -433,12 +424,10 @@ void ChannelMultiplexer::NotifyBaseChannelError(const std::string& name,
it->second->OnBaseChannelError(error);
}
-void ChannelMultiplexer::OnIncomingPacket(scoped_ptr<MultiplexPacket> packet,
- const base::Closure& done_task) {
+void ChannelMultiplexer::OnIncomingPacket(scoped_ptr<MultiplexPacket> packet) {
DCHECK(packet->has_channel_id());
if (!packet->has_channel_id()) {
LOG(ERROR) << "Received packet without channel_id.";
- done_task.Run();
return;
}
@@ -453,7 +442,6 @@ void ChannelMultiplexer::OnIncomingPacket(scoped_ptr<MultiplexPacket> packet,
if (!packet->has_channel_name()) {
LOG(ERROR) << "Received packet with unknown channel_id and "
"without channel_name.";
- done_task.Run();
return;
}
channel = GetOrCreateChannel(packet->channel_name());
@@ -461,7 +449,7 @@ void ChannelMultiplexer::OnIncomingPacket(scoped_ptr<MultiplexPacket> packet,
channels_by_receive_id_[receive_id] = channel;
}
- channel->OnIncomingPacket(std::move(packet), done_task);
+ channel->OnIncomingPacket(std::move(packet));
}
void ChannelMultiplexer::DoWrite(scoped_ptr<MultiplexPacket> packet,
« no previous file with comments | « remoting/protocol/channel_multiplexer.h ('k') | remoting/protocol/client_control_dispatcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698