8000 fix: segfault in SerialChooserController by jkleinsc · Pull Request #25969 · electron/electron · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

fix: segfault in SerialChooserController #25969

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 19, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 de 10000 letions shell/browser/serial/serial_chooser_controller.cc
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,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() {
Expand Down Expand Up @@ -106,10 +108,6 @@ void SerialChooserController::OnPortRemoved(
}
}

void SerialChooserController::OnPortManagerConnectionError() {
observer_.RemoveAll();
}

void SerialChooserController::OnDeviceChosen(const std::string& port_id) {
if (port_id.empty()) {
RunCallback(/*port=*/nullptr);
Expand Down
8 changes: 1 addition & 7 deletions shell/browser/serial/serial_chooser_controller.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

#include "base/macros.h"
#include "base/memory/weak_ptr.h"
#include "base/scoped_observer.h"
#include "base/strings/string16.h"
#include "content/public/browser/serial_chooser.h"
#include "content/public/browser/web_contents.h"
Expand Down Expand Up @@ -44,7 +43,7 @@ class SerialChooserController final : public SerialChooserContext::PortObserver,
// SerialChooserContext::PortObserver:
void OnPortAdded(const device::mojom::SerialPortInfo& port) override;
void OnPortRemoved(const device::mojom::SerialPortInfo& port) override;
void OnPortManagerConnectionError() override;
void OnPortManagerConnectionError() override {}

private:
api::Session* GetSession();
Expand All @@ -59,11 +58,6 @@ class SerialChooserController final : public SerialChooserContext::PortObserver,
url::Origin embedding_origin_;

base::WeakPtr<SerialChooserContext> chooser_context_;
ScopedObserver<SerialChooserContext,
SerialChooser 4EC4 Context::PortObserver,
&SerialChooserContext::AddPortObserver,
&SerialChooserContext::RemovePortObserver>
observer_{this};

std::vector<device::mojom::SerialPortInfoPtr> ports_;

Expand Down
0