diff --git a/src/developer/debug/zxdb/client/system_impl.cc b/src/developer/debug/zxdb/client/system_impl.cc index 2d8a1c62bc4f7e0fc82b2fb212ee9346414cc5df..9d57c1882ba776b4a1cc430bdff65a60929aa55a 100644 --- a/src/developer/debug/zxdb/client/system_impl.cc +++ b/src/developer/debug/zxdb/client/system_impl.cc @@ -48,11 +48,13 @@ class Download { : build_id_(build_id), result_cb_(std::move(result_cb)) {} ~Download() { - debug_ipc::MessageLoop::Current()->PostTask( - FROM_HERE, [result_cb = std::move(result_cb_), err = std::move(err_), - path = std::move(path_)]() { result_cb(err, path); }); + Finish(); } + // Notify this download object that we have gotten the symbols if we're going + // to get them. + void Finish(); + // Notify this Download object that one of the servers has the symbols // available. void Found(std::shared_ptr<Download> self, @@ -76,9 +78,23 @@ class Download { bool trying_ = false; }; +void Download::Finish() { + if (!result_cb_) + return; + + debug_ipc::MessageLoop::Current()->PostTask( + FROM_HERE, [result_cb = std::move(result_cb_), err = std::move(err_), + path = std::move(path_)]() { result_cb(err, path); }); + + result_cb_ = nullptr; +} + void Download::AddServer(std::shared_ptr<Download> self, SymbolServer* server) { FXL_DCHECK(self.get() == this); + if (!result_cb_) + return; + server->CheckFetch( build_id_, [self](const Err& err, @@ -94,6 +110,9 @@ void Download::Found(std::shared_ptr<Download> self, std::function<void(SymbolServer::FetchCallback)> cb) { FXL_DCHECK(self.get() == this); + if (!result_cb_) + return; + if (trying_) { server_cbs_.push_back(std::move(cb)); return; @@ -105,6 +124,9 @@ void Download::Found(std::shared_ptr<Download> self, void Download::Error(std::shared_ptr<Download> self, const Err& err) { FXL_DCHECK(self.get() == this); + if (!result_cb_) + return; + if (!err_.has_error()) { err_ = err; } else if (err.has_error()) { @@ -130,6 +152,7 @@ void Download::RunCB(std::shared_ptr<Download> self, } else { self->err_ = err; self->path_ = path; + self->Finish(); } }); }