Skip to content

Commit

Permalink
Better ref management
Browse files Browse the repository at this point in the history
  • Loading branch information
codebytere committed Aug 19, 2020
1 parent 5c8a1a4 commit 5122b49
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion shell/browser/file_select_helper.cc
Expand Up @@ -61,6 +61,8 @@ void FileSelectHelper::ShowOpenDialog(
ignore_result(promise.Then(std::move(callback)));

file_dialog::ShowOpenDialog(settings, std::move(promise));

AddRef();
}

void FileSelectHelper::ShowSaveDialog(
Expand All @@ -73,6 +75,8 @@ void FileSelectHelper::ShowSaveDialog(
ignore_result(promise.Then(std::move(callback)));

file_dialog::ShowSaveDialog(settings, std::move(promise));

AddRef();
}

// net::DirectoryLister::DirectoryListerDelegate
Expand All @@ -97,6 +101,8 @@ void FileSelectHelper::RunSelectionEnd() {

render_frame_host_ = nullptr;
web_contents_ = nullptr;

Release();
}

// net::DirectoryLister::DirectoryListerDelegate
Expand All @@ -107,7 +113,6 @@ void FileSelectHelper::OnListDone(int error) {
NativeFileInfo::New(path, base::string16())));

OnFilesSelected(std::move(file_info), lister_base_dir_);
Release();
}

void FileSelectHelper::DeleteTemporaryFiles() {
Expand Down Expand Up @@ -211,7 +216,9 @@ void FileSelectHelper::OnFilesSelected(
listener_->FileSelected(std::move(file_info), base_dir, mode_);
listener_.reset();
}

render_frame_host_ = nullptr;
Release();
}

// content::WebContentsObserver:
Expand Down Expand Up @@ -241,4 +248,5 @@ void FileSelectHelper::WebContentsDestroyed() {
web_contents_ = nullptr;

DeleteTemporaryFiles();
Release();
}

0 comments on commit 5122b49

Please sign in to comment.