Commit ed0757ec authored by asargent@chromium.org's avatar asargent@chromium.org

Ensure that the WebstoreInstaller is always deleted on the UI thread

The crash stacks show a CHECK failure when doing the unregistration due to
NotificationRegistrar deletion, indicating that the WebstoreInstaller is
getting deleted on a different thread from where the original notification
registration took place. This CL makes the ref counting infrastructure always
do the delete on the UI thread instead of whichever thread happened to do the
last Release, which should hopefully fix the problem.

BUG=125485
TEST=CHECK failures with a stack matching the signature in the bug report
should stop appearing


Review URL: https://chromiumcodereview.appspot.com/10832105

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@149646 0039d316-1c4b-4281-b951-d872f2087c98
parent a7a7bf94
......@@ -188,6 +188,7 @@ WebstoreInstaller::WebstoreInstaller(Profile* profile,
download_url_ = GetWebstoreInstallURL(id, flags & FLAG_INLINE_INSTALL ?
kInlineInstallSource : kDefaultInstallSource);
CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
registrar_.Add(this, chrome::NOTIFICATION_CRX_INSTALLER_DONE,
content::NotificationService::AllSources());
registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_INSTALLED,
......
......@@ -12,6 +12,7 @@
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
#include "base/values.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/download_id.h"
#include "content/public/browser/download_item.h"
#include "content/public/browser/notification_observer.h"
......@@ -29,9 +30,10 @@ class NavigationController;
namespace extensions {
// Downloads and installs extensions from the web store.
class WebstoreInstaller : public content::NotificationObserver,
public content::DownloadItem::Observer,
public base::RefCounted<WebstoreInstaller> {
class WebstoreInstaller :public content::NotificationObserver,
public content::DownloadItem::Observer,
public base::RefCountedThreadSafe<
WebstoreInstaller, content::BrowserThread::DeleteOnUIThread> {
public:
enum Flag {
FLAG_NONE = 0,
......@@ -125,7 +127,9 @@ class WebstoreInstaller : public content::NotificationObserver,
static void SetDownloadDirectoryForTests(FilePath* directory);
private:
friend class base::RefCounted<WebstoreInstaller>;
friend struct content::BrowserThread::DeleteOnThread<
content::BrowserThread::UI>;
friend class base::DeleteHelper<WebstoreInstaller>;
virtual ~WebstoreInstaller();
// DownloadManager::DownloadUrl callback.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment