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; ...@@ -31,10 +31,15 @@ using extensions::APIPermission;
ChromeGeolocationPermissionContext::ChromeGeolocationPermissionContext( ChromeGeolocationPermissionContext::ChromeGeolocationPermissionContext(
Profile* profile) Profile* profile)
: profile_(profile) { : profile_(profile),
shutting_down_(false) {
} }
ChromeGeolocationPermissionContext::~ChromeGeolocationPermissionContext() { 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( void ChromeGeolocationPermissionContext::RequestGeolocationPermission(
...@@ -54,6 +59,9 @@ void ChromeGeolocationPermissionContext::RequestGeolocationPermission( ...@@ -54,6 +59,9 @@ void ChromeGeolocationPermissionContext::RequestGeolocationPermission(
} }
DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
if (shutting_down_)
return;
content::WebContents* web_contents = content::WebContents* web_contents =
tab_util::GetWebContentsByID(render_process_id, render_view_id); tab_util::GetWebContentsByID(render_process_id, render_view_id);
const GeolocationPermissionRequestID id(render_process_id, render_view_id, const GeolocationPermissionRequestID id(render_process_id, render_view_id,
...@@ -100,7 +108,6 @@ void ChromeGeolocationPermissionContext::RequestGeolocationPermission( ...@@ -100,7 +108,6 @@ void ChromeGeolocationPermissionContext::RequestGeolocationPermission(
} }
DecidePermission(id, requesting_frame, embedder, callback); DecidePermission(id, requesting_frame, embedder, callback);
} }
void ChromeGeolocationPermissionContext::CancelGeolocationPermissionRequest( void ChromeGeolocationPermissionContext::CancelGeolocationPermissionRequest(
...@@ -139,6 +146,12 @@ void ChromeGeolocationPermissionContext::DecidePermission( ...@@ -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( void ChromeGeolocationPermissionContext::PermissionDecided(
const GeolocationPermissionRequestID& id, const GeolocationPermissionRequestID& id,
const GURL& requesting_frame, const GURL& requesting_frame,
...@@ -170,6 +183,7 @@ void ChromeGeolocationPermissionContext::NotifyPermissionSet( ...@@ -170,6 +183,7 @@ void ChromeGeolocationPermissionContext::NotifyPermissionSet(
GeolocationInfoBarQueueController* GeolocationInfoBarQueueController*
ChromeGeolocationPermissionContext::QueueController() { ChromeGeolocationPermissionContext::QueueController() {
DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
DCHECK(!shutting_down_);
if (!geolocation_infobar_queue_controller_) if (!geolocation_infobar_queue_controller_)
geolocation_infobar_queue_controller_.reset(CreateQueueController()); geolocation_infobar_queue_controller_.reset(CreateQueueController());
return geolocation_infobar_queue_controller_.get(); return geolocation_infobar_queue_controller_.get();
...@@ -192,5 +206,7 @@ void ChromeGeolocationPermissionContext::CancelPendingInfoBarRequest( ...@@ -192,5 +206,7 @@ void ChromeGeolocationPermissionContext::CancelPendingInfoBarRequest(
return; return;
} }
DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
if (shutting_down_)
return;
QueueController()->CancelInfoBarRequest(id); QueueController()->CancelInfoBarRequest(id);
} }
...@@ -35,6 +35,9 @@ class ChromeGeolocationPermissionContext ...@@ -35,6 +35,9 @@ class ChromeGeolocationPermissionContext
int bridge_id, int bridge_id,
const GURL& requesting_frame) OVERRIDE; const GURL& requesting_frame) OVERRIDE;
// Called on the UI thread when the profile is about to be destroyed.
void ShutdownOnUIThread();
protected: protected:
virtual ~ChromeGeolocationPermissionContext(); virtual ~ChromeGeolocationPermissionContext();
...@@ -81,9 +84,9 @@ class ChromeGeolocationPermissionContext ...@@ -81,9 +84,9 @@ class ChromeGeolocationPermissionContext
// Removes any pending InfoBar request. // Removes any pending InfoBar request.
void CancelPendingInfoBarRequest(const GeolocationPermissionRequestID& id); 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_; Profile* const profile_;
bool shutting_down_;
scoped_ptr<GeolocationInfoBarQueueController> scoped_ptr<GeolocationInfoBarQueueController>
geolocation_infobar_queue_controller_; geolocation_infobar_queue_controller_;
......
...@@ -28,6 +28,10 @@ class Service : public ProfileKeyedService { ...@@ -28,6 +28,10 @@ class Service : public ProfileKeyedService {
return context_.get(); return context_.get();
} }
virtual void Shutdown() OVERRIDE {
context()->ShutdownOnUIThread();
}
private: private:
scoped_refptr<ChromeGeolocationPermissionContext> context_; 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