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

Issue 2410123002: Remove content::BrowserThread knowledge from Device Sensors (Closed)

Created:
4 years, 2 months ago by blundell
Modified:
4 years, 1 month ago
Reviewers:
timvolodine
CC:
chromium-reviews, riju_, jam, darin-cc_chromium.org, mlamouri+watch-sensors_chromium.org
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

Remove content::BrowserThread knowledge from Device Sensors In preparation for decoupling the Device Sensors implementation from //content, this CL removes knowledge of content::BrowserThread from that code. It does so by explicitly initializing relevant classes on the UI thread so that they can save the TaskRunner of that thread in an ivar and later post to it when necessary. BUG=612322

Patch Set 1 #

Patch Set 2 : Handle DeviceSensorService's ThreadChecker #

Total comments: 1

Patch Set 3 : Rebase #

Patch Set 4 : Rebase, avoid object creation on startup #

Unified diffs Side-by-side diffs Delta from patch set Stats (+113 lines, -80 lines) Patch
M content/browser/browser_main_loop.cc View 1 2 3 2 chunks +2 lines, -2 lines 0 comments Download
M content/browser/device_sensors/data_fetcher_shared_memory.h View 1 chunk +1 line, -1 line 0 comments Download
M content/browser/device_sensors/data_fetcher_shared_memory_android.cc View 1 chunk +3 lines, -3 lines 0 comments Download
M content/browser/device_sensors/data_fetcher_shared_memory_base.h View 1 chunk +1 line, -1 line 0 comments Download
M content/browser/device_sensors/data_fetcher_shared_memory_base.cc View 1 chunk +1 line, -1 line 0 comments Download
M content/browser/device_sensors/device_sensor_host.h View 1 2 3 3 chunks +6 lines, -2 lines 0 comments Download
M content/browser/device_sensors/device_sensor_host.cc View 1 2 3 2 chunks +16 lines, -5 lines 0 comments Download
M content/browser/device_sensors/device_sensor_service.h View 1 2 3 2 chunks +8 lines, -5 lines 0 comments Download
M content/browser/device_sensors/device_sensor_service.cc View 1 2 3 3 chunks +5 lines, -5 lines 0 comments Download
M content/browser/device_sensors/sensor_manager_android.h View 1 2 3 3 chunks +6 lines, -1 line 0 comments Download
M content/browser/device_sensors/sensor_manager_android.cc View 1 2 3 11 chunks +47 lines, -48 lines 0 comments Download
M content/browser/device_sensors/sensor_manager_android_unittest.cc View 1 2 3 7 chunks +9 lines, -2 lines 0 comments Download
M content/browser/renderer_host/render_process_host_impl.cc View 1 2 3 1 chunk +8 lines, -4 lines 0 comments Download

Dependent Patchsets:

Messages

Total messages: 24 (18 generated)
blundell
4 years, 2 months ago (2016-10-11 17:06:01 UTC) #10
timvolodine
https://codereview.chromium.org/2410123002/diff/20001/content/browser/device_sensors/device_sensor_service.cc File content/browser/device_sensors/device_sensor_service.cc (right): https://codereview.chromium.org/2410123002/diff/20001/content/browser/device_sensors/device_sensor_service.cc#newcode109 content/browser/device_sensors/device_sensor_service.cc:109: void DeviceSensorService::InitOnIOThread() { I am slightly confused by the ...
4 years, 2 months ago (2016-10-12 16:28:58 UTC) #11
blundell
On 2016/10/12 16:28:58, timvolodine wrote: > https://codereview.chromium.org/2410123002/diff/20001/content/browser/device_sensors/device_sensor_service.cc > File content/browser/device_sensors/device_sensor_service.cc (right): > > https://codereview.chromium.org/2410123002/diff/20001/content/browser/device_sensors/device_sensor_service.cc#newcode109 > ...
4 years, 2 months ago (2016-10-13 14:09:54 UTC) #12
blundell
On 2016/10/13 14:09:54, blundell wrote: > On 2016/10/12 16:28:58, timvolodine wrote: > > > https://codereview.chromium.org/2410123002/diff/20001/content/browser/device_sensors/device_sensor_service.cc ...
4 years, 2 months ago (2016-10-13 14:12:37 UTC) #13
timvolodine
On 2016/10/13 14:12:37, blundell wrote: > On 2016/10/13 14:09:54, blundell wrote: > > On 2016/10/12 ...
4 years, 2 months ago (2016-10-13 16:14:56 UTC) #16
blundell
4 years, 2 months ago (2016-10-14 09:58:57 UTC) #17
On 2016/10/13 16:14:56, timvolodine wrote:
> On 2016/10/13 14:12:37, blundell wrote:
> > On 2016/10/13 14:09:54, blundell wrote:
> > > On 2016/10/12 16:28:58, timvolodine wrote:
> > > >
> > >
> >
>
https://codereview.chromium.org/2410123002/diff/20001/content/browser/device_...
> > > > File content/browser/device_sensors/device_sensor_service.cc (right):
> > > > 
> > > >
> > >
> >
>
https://codereview.chromium.org/2410123002/diff/20001/content/browser/device_...
> > > > content/browser/device_sensors/device_sensor_service.cc:109: void
> > > > DeviceSensorService::InitOnIOThread() {
> > > > I am slightly confused by the two Init methods, with the first only
doing
> > > > something for android, while the second seems a bit 'hacky'. Is there a
> way
> > to
> > > > limit the change to android (and drop the InitOnIOThread/UIThread)?
> > > >
> > > 
> > > The reason for the two init methods is that the DeviceSensorService
> singleton
> > > assumed that it was created on the IO thread (cf. its thread_checker_
> > variable).
> > > 
> > >  
> > > > A few ideas: maybe by either putting the ifdef block in InitOnUIThread
in
> > > > browser_main_loop.cc directly.. or maybe even better to let the mojo IPC
> > > arrive
> > > > on UI thread for android and set the taskrunner there since most android
> > calls
> > > > happen on UI anyway. That way we avoid the overhead of constructing
> > > > sensor_manager_android and its java counterpart on each startup. wdyt?
> > > 
> > > I think that we could indeed do the latter. The tradeoff then is that
we'll
> > have
> > > DeviceSensorService and DeviceSensorHost living on the UI thread on
Android
> > and
> > > the IO thread on other platforms. Is that overall less confusing in your
> > > opinion?
> > 
> > (apologies if this came off as hostile, it's an honest question as I can't
> > decide which is "better" ;).
> 
> not at all, all valid questions ;)
> 
> I think I prefer the option with the mojo host on UI thread (for Android),
this
> has  a number of benefits:
> - it's local (in the sense we stay in device_sensors/ and don't touch startup
> etc)
> - probably easier to change if we decide to put it on a different thread later
> - does not 'pollute' startup, objects are created on demand
> - we do similar things for some IPCs in other places
> - probably requires less methods..

Agree with all of this. Will create that patch.

> 
> > 
> > > 
> > > We could also do the former, in which case I would drop the
> "InitOnUIThread()"
> > > from DeviceSensorService entirely and just have browser_main_loop.cc
> directly
> > > call SensorManagerAndroid::InitOnUIThread() on Android. This does still
have
> > the
> > > property of creating SensorManagerAndroid on startup though, as you point
> out.
> > > 
> > > Out of curiosity, why do these objects need to live on the IO thread on
> > > platforms other than Android?
> 
> I guess they could live on UI but if I remember correctly the original
thinking
> was to unload the UI thread as much as possible..

Powered by Google App Engine
This is Rietveld 408576698