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

Unified Diff: chrome/browser/geolocation/chrome_geolocation_permission_context.cc

Issue 273523007: Dispatch geolocation IPCs on the UI thread. Aside from simplifying the code to avoid a lot of threa… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: sync Created 6 years, 7 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
Index: chrome/browser/geolocation/chrome_geolocation_permission_context.cc
===================================================================
--- chrome/browser/geolocation/chrome_geolocation_permission_context.cc (revision 269778)
+++ chrome/browser/geolocation/chrome_geolocation_permission_context.cc (working copy)
@@ -22,6 +22,7 @@
#include "chrome/browser/ui/website_settings/permission_bubble_request.h"
#include "chrome/common/pref_names.h"
#include "content/public/browser/browser_thread.h"
+#include "content/public/browser/render_process_host.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/web_contents.h"
#include "extensions/browser/extension_registry.h"
@@ -135,30 +136,15 @@
}
void ChromeGeolocationPermissionContext::RequestGeolocationPermission(
- int render_process_id,
- int render_view_id,
+ content::WebContents* web_contents,
int bridge_id,
const GURL& requesting_frame,
bool user_gesture,
base::Callback<void(bool)> callback) {
GURL requesting_frame_origin = requesting_frame.GetOrigin();
- if (!content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)) {
- content::BrowserThread::PostTask(
- content::BrowserThread::UI, FROM_HERE,
- base::Bind(
- &ChromeGeolocationPermissionContext::RequestGeolocationPermission,
- this, render_process_id, render_view_id, bridge_id,
- requesting_frame_origin, user_gesture, callback));
- return;
- }
-
- DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
if (shutting_down_)
return;
- content::WebContents* web_contents =
- tab_util::GetWebContentsByID(render_process_id, render_view_id);
-
WebViewGuest* guest = WebViewGuest::FromWebContents(web_contents);
if (guest) {
guest->RequestGeolocationPermission(bridge_id,
@@ -167,6 +153,9 @@
callback);
return;
}
+
+ int render_process_id = web_contents->GetRenderProcessHost()->GetID();
+ int render_view_id = web_contents->GetRenderViewHost()->GetRoutingID();
const PermissionRequestID id(render_process_id, render_view_id, bridge_id, 0);
ExtensionRegistry* extension_registry = ExtensionRegistry::Get(profile_);
if (extension_registry) {
@@ -212,27 +201,9 @@
}
void ChromeGeolocationPermissionContext::CancelGeolocationPermissionRequest(
- int render_process_id,
- int render_view_id,
+ content::WebContents* web_contents,
int bridge_id,
const GURL& requesting_frame) {
- if (!content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)) {
- content::BrowserThread::PostTask(
- content::BrowserThread::UI, FROM_HERE,
- base::Bind(
- &ChromeGeolocationPermissionContext::
- CancelGeolocationPermissionRequest,
- this,
- render_process_id,
- render_view_id,
- bridge_id,
- requesting_frame));
- return;
- }
-
- DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
- content::WebContents* web_contents =
- tab_util::GetWebContentsByID(render_process_id, render_view_id);
WebViewGuest* guest =
web_contents ? WebViewGuest::FromWebContents(web_contents) : NULL;
if (guest) {
@@ -240,6 +211,8 @@
return;
}
// TODO(gbillock): cancel permission bubble request.
+ int render_process_id = web_contents->GetRenderProcessHost()->GetID();
+ int render_view_id = web_contents->GetRenderViewHost()->GetRoutingID();
CancelPendingInfobarRequest(PermissionRequestID(
render_process_id, render_view_id, bridge_id, 0));
}

Powered by Google App Engine
This is Rietveld 408576698