diff options
Diffstat (limited to 'blimp/net/blimp_message_pump.cc')
-rw-r--r-- | blimp/net/blimp_message_pump.cc | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/blimp/net/blimp_message_pump.cc b/blimp/net/blimp_message_pump.cc index 14d8d2e..70c3217 100644 --- a/blimp/net/blimp_message_pump.cc +++ b/blimp/net/blimp_message_pump.cc @@ -26,10 +26,11 @@ BlimpMessagePump::BlimpMessagePump(PacketReader* reader) BlimpMessagePump::~BlimpMessagePump() {} void BlimpMessagePump::SetMessageProcessor(BlimpMessageProcessor* processor) { - DCHECK(processor); - bool reading_packet = !!processor_; + process_msg_callback_.Cancel(); processor_ = processor; - if (!reading_packet) { + if (!processor_) { + read_packet_callback_.Cancel(); + } else if (read_packet_callback_.IsCancelled()) { buffer_->SetCapacity(kMaxPacketPayloadSizeBytes); ReadNextPacket(); } @@ -49,6 +50,7 @@ void BlimpMessagePump::ReadNextPacket() { } void BlimpMessagePump::OnReadPacketComplete(int result) { + read_packet_callback_.Cancel(); if (result > 0) { // The result is the size of the packet in bytes. scoped_ptr<BlimpMessage> message(new BlimpMessage); @@ -70,6 +72,7 @@ void BlimpMessagePump::OnReadPacketComplete(int result) { void BlimpMessagePump::OnProcessMessageComplete(int result) { // No error is expected from the message receiver. DCHECK_EQ(result, net::OK); + process_msg_callback_.Cancel(); ReadNextPacket(); } |