fix: segfault in SerialChooserController (#25969)

* fix: segfault in SerialChooserController

* Remove temporary testing
This commit is contained in:
John Kleinschmidt 2020-10-19 10:51:25 -04:00 committed by GitHub
parent 6a0221297e
commit 87d3f3584c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 12 deletions

View file

@ -77,11 +77,13 @@ SerialChooserController::SerialChooserController(
DCHECK(chooser_context_);
chooser_context_->GetPortManager()->GetDevices(base::BindOnce(
&SerialChooserController::OnGetDevices, weak_factory_.GetWeakPtr()));
observer_.Add(chooser_context_.get());
}
SerialChooserController::~SerialChooserController() {
RunCallback(/*port=*/nullptr);
if (chooser_context_) {
chooser_context_->RemovePortObserver(this);
}
}
api::Session* SerialChooserController::GetSession() {
@ -114,10 +116,6 @@ void SerialChooserController::OnPortRemoved(
}
}
void SerialChooserController::OnPortManagerConnectionError() {
observer_.RemoveAll();
}
void SerialChooserController::OnDeviceChosen(const std::string& port_id) {
if (port_id.empty()) {
RunCallback(/*port=*/nullptr);