Extend RefCounted and add private destructor
authorKevin Sawicki <kevinsawicki@gmail.com>
Thu, 23 Feb 2017 16:38:29 +0000 (08:38 -0800)
committerKevin Sawicki <kevinsawicki@gmail.com>
Fri, 24 Feb 2017 15:37:28 +0000 (07:37 -0800)
atom/browser/web_dialog_helper.cc

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