blob: 3f258902b6e6be9bae7dcd3d7331c8ec273ec866 [file] [log] [blame]
// Copyright 2018 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "scoped_channel.h"
namespace bt {
namespace l2cap {
ScopedChannel::ScopedChannel(fbl::RefPtr<Channel> chan) : chan_(chan) {}
ScopedChannel::~ScopedChannel() { Close(); }
void ScopedChannel::Reset(fbl::RefPtr<Channel> new_channel) {
if (chan_) {
Close();
}
chan_ = std::move(new_channel);
}
void ScopedChannel::Close() {
if (chan_) {
chan_->Deactivate();
chan_ = nullptr;
}
}
} // namespace l2cap
} // namespace bt