summaryrefslogtreecommitdiffstats
path: root/remoting
diff options
context:
space:
mode:
authorsergeyu <sergeyu@chromium.org>2015-05-26 17:23:34 -0700
committerCommit bot <commit-bot@chromium.org>2015-05-27 00:25:11 +0000
commitf74533f8f91755a796c17fb1a88fb887726444fe (patch)
tree2e1d4e3c3e72fb4d36cd63df7874f11d50adaeea /remoting
parent55a41a677015add974720eb87544d35cd9fd942a (diff)
downloadchromium_src-f74533f8f91755a796c17fb1a88fb887726444fe.zip
chromium_src-f74533f8f91755a796c17fb1a88fb887726444fe.tar.gz
chromium_src-f74533f8f91755a796c17fb1a88fb887726444fe.tar.bz2
Fix ClientVideoDispatcher not to crash during shutdown.
ClientVideoDispatcher was passing base::Unretained() callbacks to VideoStub which it doesn't own, as result the callback may be called after the dispatcher is destroyed causing crashes during shutdown. Fixed ClientVideoDispatcher to use weak pointers for the done callbacks passed to VideoStub. BUG=491366 Review URL: https://codereview.chromium.org/1149703005 Cr-Commit-Position: refs/heads/master@{#331489}
Diffstat (limited to 'remoting')
-rw-r--r--remoting/protocol/client_video_dispatcher.cc9
-rw-r--r--remoting/protocol/client_video_dispatcher.h3
2 files changed, 8 insertions, 4 deletions
diff --git a/remoting/protocol/client_video_dispatcher.cc b/remoting/protocol/client_video_dispatcher.cc
index d9918fb..a98bee3 100644
--- a/remoting/protocol/client_video_dispatcher.cc
+++ b/remoting/protocol/client_video_dispatcher.cc
@@ -28,7 +28,8 @@ ClientVideoDispatcher::ClientVideoDispatcher(VideoStub* video_stub)
video_stub_(video_stub),
parser_(base::Bind(&ClientVideoDispatcher::ProcessVideoPacket,
base::Unretained(this)),
- reader()) {
+ reader()),
+ weak_factory_(this) {
}
ClientVideoDispatcher::~ClientVideoDispatcher() {
@@ -50,9 +51,9 @@ void ClientVideoDispatcher::ProcessVideoPacket(
pending_frames_.insert(pending_frames_.end(), PendingFrame(frame_id));
video_stub_->ProcessVideoPacket(
- video_packet.Pass(), base::Bind(&ClientVideoDispatcher::OnPacketDone,
- base::Unretained(this), pending_frame));
-
+ video_packet.Pass(),
+ base::Bind(&ClientVideoDispatcher::OnPacketDone,
+ weak_factory_.GetWeakPtr(), pending_frame));
}
void ClientVideoDispatcher::OnPacketDone(
diff --git a/remoting/protocol/client_video_dispatcher.h b/remoting/protocol/client_video_dispatcher.h
index a86142f..0c01087 100644
--- a/remoting/protocol/client_video_dispatcher.h
+++ b/remoting/protocol/client_video_dispatcher.h
@@ -6,6 +6,7 @@
#define REMOTING_PROTOCOL_CLIENT_VIDEO_DISPATCHER_H_
#include "base/compiler_specific.h"
+#include "base/memory/weak_ptr.h"
#include "remoting/proto/video.pb.h"
#include "remoting/protocol/channel_dispatcher_base.h"
#include "remoting/protocol/protobuf_message_parser.h"
@@ -35,6 +36,8 @@ class ClientVideoDispatcher : public ChannelDispatcherBase {
VideoStub* video_stub_;
ProtobufMessageParser<VideoPacket> parser_;
+ base::WeakPtrFactory<ClientVideoDispatcher> weak_factory_;
+
DISALLOW_COPY_AND_ASSIGN(ClientVideoDispatcher);
};