Re-land: C++ readability review
[chromium-blink-merge.git] / remoting / protocol / monitored_video_stub.cc
blobdcc4e1fc90f83f0dae67fe0ce3e0da9ae0e1712a
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "remoting/protocol/monitored_video_stub.h"
7 #include "base/bind.h"
8 #include "base/logging.h"
9 #include "remoting/codec/video_decoder.h"
10 #include "remoting/codec/video_decoder_verbatim.h"
11 #include "remoting/codec/video_decoder_vpx.h"
13 namespace remoting {
14 namespace protocol {
16 MonitoredVideoStub::MonitoredVideoStub(VideoStub* video_stub,
17 base::TimeDelta connectivity_check_delay,
18 const ChannelStateCallback& callback)
19 : video_stub_(video_stub),
20 callback_(callback),
21 is_connected_(false),
22 connectivity_check_timer_(
23 FROM_HERE,
24 connectivity_check_delay,
25 this,
26 &MonitoredVideoStub::OnConnectivityCheckTimeout) {
29 MonitoredVideoStub::~MonitoredVideoStub() {
32 void MonitoredVideoStub::ProcessVideoPacket(scoped_ptr<VideoPacket> packet,
33 const base::Closure& done) {
34 DCHECK(thread_checker_.CalledOnValidThread());
36 connectivity_check_timer_.Reset();
38 NotifyChannelState(true);
40 video_stub_->ProcessVideoPacket(packet.Pass(), done);
43 void MonitoredVideoStub::OnConnectivityCheckTimeout() {
44 DCHECK(thread_checker_.CalledOnValidThread());
45 NotifyChannelState(false);
48 void MonitoredVideoStub::NotifyChannelState(bool connected) {
49 if (is_connected_ != connected) {
50 is_connected_ = connected;
51 callback_.Run(is_connected_);
55 } // namespace protocol
56 } // namespace remoting