Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1789)

Unified Diff: chrome/browser/file_select_helper.h

Issue 1616563002: Ensure that FileSelectHelper is destroyed on the UI thread. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add a comment describing why FileSelectHelper needs to be destroyed on the UI thread. Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/file_select_helper.h
diff --git a/chrome/browser/file_select_helper.h b/chrome/browser/file_select_helper.h
index f0669eb90bd8c97ca24702f159834fee8fb9c38c..21a6a87b44be38edf1783fd2a529c1b9ff0b1c1f 100644
--- a/chrome/browser/file_select_helper.h
+++ b/chrome/browser/file_select_helper.h
@@ -13,6 +13,7 @@
#include "base/macros.h"
#include "base/memory/scoped_ptr.h"
#include "build/build_config.h"
+#include "content/public/browser/browser_thread.h"
#include "content/public/browser/notification_observer.h"
#include "content/public/browser/notification_registrar.h"
#include "content/public/browser/web_contents_observer.h"
@@ -39,12 +40,17 @@ struct SelectedFileInfo;
// This class handles file-selection requests coming from WebUI elements
// (via the extensions::ExtensionHost class). It implements both the
// initialisation and listener functions for file-selection dialogs.
-class FileSelectHelper : public base::RefCountedThreadSafe<FileSelectHelper>,
+//
+// Since FileSelectHelper has-a NotificationRegistrar, it needs to live on and
+// be destroyed on the UI thread. References to FileSelectHelper may be passed
+// on to other threads.
+class FileSelectHelper : public base::RefCountedThreadSafe<
+ FileSelectHelper,
+ content::BrowserThread::DeleteOnUIThread>,
public ui::SelectFileDialog::Listener,
public content::WebContentsObserver,
public content::NotificationObserver {
public:
-
// Show the file chooser dialog.
static void RunFileChooser(content::WebContents* tab,
const content::FileChooserParams& params);
@@ -56,6 +62,10 @@ class FileSelectHelper : public base::RefCountedThreadSafe<FileSelectHelper>,
private:
friend class base::RefCountedThreadSafe<FileSelectHelper>;
+ friend class base::DeleteHelper<FileSelectHelper>;
+ friend struct content::BrowserThread::DeleteOnThread<
+ content::BrowserThread::UI>;
+
FRIEND_TEST_ALL_PREFIXES(FileSelectHelperTest, IsAcceptTypeValid);
FRIEND_TEST_ALL_PREFIXES(FileSelectHelperTest, ZipPackage);
FRIEND_TEST_ALL_PREFIXES(FileSelectHelperTest, GetSanitizedFileName);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698