Commit 764ab69a authored by jknotten@chromium.org's avatar jknotten@chromium.org

Destroy GeolocationInfobarQueueController on UI thread.

ChromeGeolocationPermissionContext is RefcountedThreadsafe and
may lose it's last reference from either the UI thread or the
IO thread. GeolocationInfobarQueueController must be destroyed
on the UI thread, however.

Depends on https://codereview.chromium.org/11587003/

TEST=
BUG=127751

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@176112 0039d316-1c4b-4281-b951-d872f2087c98
parent 7585f4c1
......@@ -31,10 +31,15 @@ using extensions::APIPermission;
ChromeGeolocationPermissionContext::ChromeGeolocationPermissionContext(
Profile* profile)
: profile_(profile) {
: profile_(profile),
shutting_down_(false) {
}
ChromeGeolocationPermissionContext::~ChromeGeolocationPermissionContext() {
// ChromeGeolocationPermissionContext may be destroyed on either the UI thread
// or the IO thread, but the GeolocationInfobarQueueController must have been
// destroyed on the UI thread.
DCHECK(!geolocation_infobar_queue_controller_.get());
}
void ChromeGeolocationPermissionContext::RequestGeolocationPermission(
......@@ -54,6 +59,9 @@ void ChromeGeolocationPermissionContext::RequestGeolocationPermission(
}
DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
if (shutting_down_)
return;
content::WebContents* web_contents =
tab_util::GetWebContentsByID(render_process_id, render_view_id);
const GeolocationPermissionRequestID id(render_process_id, render_view_id,
......@@ -100,7 +108,6 @@ void ChromeGeolocationPermissionContext::RequestGeolocationPermission(
}
DecidePermission(id, requesting_frame, embedder, callback);
}
void ChromeGeolocationPermissionContext::CancelGeolocationPermissionRequest(
......@@ -139,6 +146,12 @@ void ChromeGeolocationPermissionContext::DecidePermission(
}
}
void ChromeGeolocationPermissionContext::ShutdownOnUIThread() {
DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
geolocation_infobar_queue_controller_.reset();
shutting_down_ = true;
}
void ChromeGeolocationPermissionContext::PermissionDecided(
const GeolocationPermissionRequestID& id,
const GURL& requesting_frame,
......@@ -170,6 +183,7 @@ void ChromeGeolocationPermissionContext::NotifyPermissionSet(
GeolocationInfoBarQueueController*
ChromeGeolocationPermissionContext::QueueController() {
DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
DCHECK(!shutting_down_);
if (!geolocation_infobar_queue_controller_)
geolocation_infobar_queue_controller_.reset(CreateQueueController());
return geolocation_infobar_queue_controller_.get();
......@@ -192,5 +206,7 @@ void ChromeGeolocationPermissionContext::CancelPendingInfoBarRequest(
return;
}
DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
if (shutting_down_)
return;
QueueController()->CancelInfoBarRequest(id);
}
......@@ -35,6 +35,9 @@ class ChromeGeolocationPermissionContext
int bridge_id,
const GURL& requesting_frame) OVERRIDE;
// Called on the UI thread when the profile is about to be destroyed.
void ShutdownOnUIThread();
protected:
virtual ~ChromeGeolocationPermissionContext();
......@@ -81,9 +84,9 @@ class ChromeGeolocationPermissionContext
// Removes any pending InfoBar request.
void CancelPendingInfoBarRequest(const GeolocationPermissionRequestID& id);
// This must only be accessed from the UI thread.
// These must only be accessed from the UI thread.
Profile* const profile_;
bool shutting_down_;
scoped_ptr<GeolocationInfoBarQueueController>
geolocation_infobar_queue_controller_;
......
......@@ -28,6 +28,10 @@ class Service : public ProfileKeyedService {
return context_.get();
}
virtual void Shutdown() OVERRIDE {
context()->ShutdownOnUIThread();
}
private:
scoped_refptr<ChromeGeolocationPermissionContext> context_;
......
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