Extend RefCounted and add private destructor

This commit is contained in:
Kevin Sawicki 2017-02-23 08:38:29 -08:00
parent a33ffd621f
commit 29f92bfb53

View file

@ -28,9 +28,7 @@
namespace { namespace {
class FileSelectHelper : public base::RefCountedThreadSafe< class FileSelectHelper : public base::RefCounted<FileSelectHelper>,
FileSelectHelper,
content::BrowserThread::DeleteOnUIThread>,
public content::WebContentsObserver { public content::WebContentsObserver {
public: public:
FileSelectHelper(content::RenderFrameHost* render_frame_host, FileSelectHelper(content::RenderFrameHost* render_frame_host,
@ -44,18 +42,20 @@ class FileSelectHelper : public base::RefCountedThreadSafe<
} }
void ShowOpenDialog(const file_dialog::DialogSettings& settings) { void ShowOpenDialog(const file_dialog::DialogSettings& settings) {
auto callback = base::Bind(&FileSelectHelper::OnOpenDialogDone, auto callback = base::Bind(&FileSelectHelper::OnOpenDialogDone, this);
base::Unretained(this));
file_dialog::ShowOpenDialog(settings, callback); file_dialog::ShowOpenDialog(settings, callback);
} }
void ShowSaveDialog(const file_dialog::DialogSettings& settings) { void ShowSaveDialog(const file_dialog::DialogSettings& settings) {
auto callback = base::Bind(&FileSelectHelper::OnSaveDialogDone, auto callback = base::Bind(&FileSelectHelper::OnSaveDialogDone, this);
base::Unretained(this));
file_dialog::ShowSaveDialog(settings, callback); file_dialog::ShowSaveDialog(settings, callback);
} }
private: private:
friend class base::RefCounted<FileSelectHelper>;
~FileSelectHelper() {}
void OnOpenDialogDone(bool result, const std::vector<base::FilePath>& paths) { void OnOpenDialogDone(bool result, const std::vector<base::FilePath>& paths) {
std::vector<content::FileChooserFileInfo> file_info; std::vector<content::FileChooserFileInfo> file_info;
if (result) { if (result) {