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

Issue 2127973002: Geolocation: change GeolocationDelegate to injected by content/ (Closed)

Created:
4 years, 5 months ago by mcasas
Modified:
4 years, 4 months ago
CC:
chromium-reviews, creis+watch_chromium.org, darin-cc_chromium.org, mlamouri+watch-geolocation_chromium.org, Michael van Ouwerkerk, nasko+codewatch_chromium.org
Base URL:
https://chromium.googlesource.com/chromium/src.git@master
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

Geolocation: change GeolocationDelegate to injected by content/ GeolocationProviderImpl is a singleton that directly references GetContentClient()::browser() on ctor, to retrieve an embedder- provider GeolocationDelegate. This blocks moving Geolocation out of content/ This CL changes that mechanism: the GeolocationDelegate is injected in BrowserMainLoop::PostMainMessageLoopStart() (so it won't affect startup time IIUC), and kept in a variable until the singleton construction. This CL is the last blocking factor before taking Geolocation out of content/browser and into device. BUG=612334 TEST=./out/gn/browser_tests --gtest_filter="GeolocationBrowserTest.*" PS: A note about shell_content_browser_client.cc: Changing GeolocationDelegate to injected, causes component's AutofillRiskFingerprintTest to start failing because ShellGeolocationDelegate was initialized too early and could not get a correct ShellBrowserContext*. This CL also changes the ShellGeolocationDelegate to get the browser_context() when is needed. Committed: https://crrev.com/19677cb9f1901f0eb7881380ac85a0255195e06d Cr-Commit-Position: refs/heads/master@{#407015}

Patch Set 1 : #

Total comments: 7

Patch Set 2 : rockot@ comments and sorting out ShellGeolocationDelegate. Rebased. #

Total comments: 2

Patch Set 3 : simplified shell_content_browser_client.cc #

Unified diffs Side-by-side diffs Delta from patch set Stats (+32 lines, -16 lines) Patch
M content/browser/browser_main_loop.cc View 1 2 chunks +4 lines, -0 lines 0 comments Download
M content/browser/geolocation/geolocation_provider_impl.h View 2 chunks +0 lines, -4 lines 0 comments Download
M content/browser/geolocation/geolocation_provider_impl.cc View 1 4 chunks +19 lines, -6 lines 0 comments Download
M content/public/browser/geolocation_provider.h View 2 chunks +5 lines, -0 lines 0 comments Download
M content/shell/browser/shell_content_browser_client.cc View 1 2 2 chunks +4 lines, -6 lines 0 comments Download

Messages

Total messages: 31 (18 generated)
mcasas
rockot@: following up our discussion of changing a direct dependency on content/ with an injected ...
4 years, 5 months ago (2016-07-19 22:51:04 UTC) #9
Ken Rockot(use gerrit already)
https://codereview.chromium.org/2127973002/diff/80001/content/browser/geolocation/geolocation_provider_impl.cc File content/browser/geolocation/geolocation_provider_impl.cc (right): https://codereview.chromium.org/2127973002/diff/80001/content/browser/geolocation/geolocation_provider_impl.cc#newcode36 content/browser/geolocation/geolocation_provider_impl.cc:36: if (!g_delegate.Pointer()) g_delegate.Pointer() is always true. It's the address ...
4 years, 5 months ago (2016-07-20 17:47:52 UTC) #10
Ken Rockot(use gerrit already)
https://codereview.chromium.org/2127973002/diff/120001/content/shell/browser/shell_content_browser_client.cc File content/shell/browser/shell_content_browser_client.cc (right): https://codereview.chromium.org/2127973002/diff/120001/content/shell/browser/shell_content_browser_client.cc#newcode376 content/shell/browser/shell_content_browser_client.cc:376: &ShellContentBrowserClient::browser_context, base::Unretained(this))); This is pretty weird. Why not just ...
4 years, 5 months ago (2016-07-20 20:47:04 UTC) #15
mcasas
https://codereview.chromium.org/2127973002/diff/80001/content/browser/geolocation/geolocation_provider_impl.cc File content/browser/geolocation/geolocation_provider_impl.cc (right): https://codereview.chromium.org/2127973002/diff/80001/content/browser/geolocation/geolocation_provider_impl.cc#newcode36 content/browser/geolocation/geolocation_provider_impl.cc:36: if (!g_delegate.Pointer()) On 2016/07/20 17:47:52, Ken Rockot wrote: > ...
4 years, 5 months ago (2016-07-20 20:47:08 UTC) #16
mcasas
jam@ PTAL/RS rockot@: all done, thanks! https://codereview.chromium.org/2127973002/diff/120001/content/shell/browser/shell_content_browser_client.cc File content/shell/browser/shell_content_browser_client.cc (right): https://codereview.chromium.org/2127973002/diff/120001/content/shell/browser/shell_content_browser_client.cc#newcode376 content/shell/browser/shell_content_browser_client.cc:376: &ShellContentBrowserClient::browser_context, base::Unretained(this))); On ...
4 years, 5 months ago (2016-07-20 20:53:15 UTC) #19
jam
Let's remove the ContentBrowserClient method to set GeolocationDelegate though.
4 years, 5 months ago (2016-07-21 16:41:14 UTC) #20
jam
lgtm (as we discussed in person, this will be done in follow-ups)
4 years, 5 months ago (2016-07-21 22:35:53 UTC) #21
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2127973002/140001
4 years, 5 months ago (2016-07-21 22:38:06 UTC) #23
commit-bot: I haz the power
Committed patchset #3 (id:140001)
4 years, 5 months ago (2016-07-22 03:20:45 UTC) #25
commit-bot: I haz the power
Patchset 3 (id:??) landed as https://crrev.com/19677cb9f1901f0eb7881380ac85a0255195e06d Cr-Commit-Position: refs/heads/master@{#407015}
4 years, 5 months ago (2016-07-22 03:23:30 UTC) #27
Wez
https://codereview.chromium.org/2127973002/diff/80001/content/browser/geolocation/geolocation_provider_impl.cc File content/browser/geolocation/geolocation_provider_impl.cc (right): https://codereview.chromium.org/2127973002/diff/80001/content/browser/geolocation/geolocation_provider_impl.cc#newcode25 content/browser/geolocation/geolocation_provider_impl.cc:25: LAZY_INSTANCE_INITIALIZER; Why do we need a LazyInstance here, rather ...
4 years, 4 months ago (2016-07-25 22:25:35 UTC) #29
mcasas
https://codereview.chromium.org/2127973002/diff/80001/content/browser/geolocation/geolocation_provider_impl.cc File content/browser/geolocation/geolocation_provider_impl.cc (right): https://codereview.chromium.org/2127973002/diff/80001/content/browser/geolocation/geolocation_provider_impl.cc#newcode25 content/browser/geolocation/geolocation_provider_impl.cc:25: LAZY_INSTANCE_INITIALIZER; On 2016/07/25 22:25:35, Wez wrote: > Why do ...
4 years, 4 months ago (2016-07-26 18:46:34 UTC) #30
Wez
4 years, 4 months ago (2016-07-26 19:08:31 UTC) #31
Message was sent while issue was closed.
https://codereview.chromium.org/2127973002/diff/80001/content/browser/geoloca...
File content/browser/geolocation/geolocation_provider_impl.cc (right):

https://codereview.chromium.org/2127973002/diff/80001/content/browser/geoloca...
content/browser/geolocation/geolocation_provider_impl.cc:25:
LAZY_INSTANCE_INITIALIZER;
On 2016/07/26 18:46:34, mcasas wrote:
> On 2016/07/25 22:25:35, Wez wrote:
> > Why do we need a LazyInstance here, rather than a bare-pointer?
> 
> Essentially, because I wanted the |g_delegate| to clean
> itself up during shutdown.  Using a naked pointer would
> have implied making it a member variable of 
> GeolocationProvider to clean it up, but that'd have forced
> the creation of the (evil?) singleton...

If you want it cleaned up on shutdown then you either want a Singleton or a
non-Leaky LazyInstance.  What you have right now won't clean up on shutdown,
AFAIK.

Also I'm not sure that we actually instantiate AtExitManager in the Browser
process; I think we may deliberately skip destructing Singletons etc on browser
teardown because it usually just generates unnecessary memory paging, to no
purpose.

Powered by Google App Engine
This is Rietveld 408576698