How to tell from within a renderer process that it has tabs?

533 views
Skip to first unread message

Simon Que

unread,
Mar 30, 2016, 1:32:52 AM3/30/16
to Chromium-dev
How can my code in the Chrome renderer process know that it is running in a renderer process that includes one or more tabs? As opposed to in a renderer process containing extensions or plugins.

Simon

PhistucK

unread,
Mar 30, 2016, 2:35:04 AM3/30/16
to Simon Que, Chromium-dev
Renderers with normal web pages generally have --type=renderer in their command line.

However, I recall instances where renderers were unfortunately shared by extensions and normal web pages, so if a complete distinction is important to you, I am not sure there is one.


PhistucK

On Wed, Mar 30, 2016 at 8:31 AM, Simon Que <sq...@chromium.org> wrote:
How can my code in the Chrome renderer process know that it is running in a renderer process that includes one or more tabs? As opposed to in a renderer process containing extensions or plugins.

Simon

--
--
Chromium Developers mailing list: chromi...@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-dev
---
You received this message because you are subscribed to the Google Groups "Chromium-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-dev...@chromium.org.

Simon Que

unread,
Mar 30, 2016, 5:22:08 AM3/30/16
to PhistucK, Chromium-dev
Yes I know... I was asking specifically how to identify a renderer process as having tabs, assuming I already know it is a renderer process.

Avi Drissman

unread,
Mar 30, 2016, 10:43:29 AM3/30/16
to Simon Que, PhistucK, Chromium-dev
You can't.

From the perspective of the content layer, a WebContents is a WebContents, and it doesn't know or care about what is in it.

A WebContents might be used in a tab, or in an extension, or heck, used in Opera or Chromecast. There is no way to know, and any code that needs to know can't be put into that layer.

Avi

Colin Blundell

unread,
Mar 30, 2016, 11:11:57 AM3/30/16
to a...@chromium.org, Simon Que, PhistucK, Chromium-dev
FWIW, the original email said the *Chrome* renderer process, which makes me assume that it would be fine to use any //chrome-specific information available to answer this question.

Avi Drissman

unread,
Mar 30, 2016, 12:34:38 PM3/30/16
to Colin Blundell, Simon Que, PhistucK, Chromium-dev
Simon, what exactly are you trying to do? As PhistucK pointed out, the render process might be shared. Do you want to know if a specific frame is in a tab? (You could attach a tab helper and have that send IPCs to your code in the render process, etc.) Why were you asking about the entire process?

Avi

Simon Que

unread,
Mar 30, 2016, 3:28:59 PM3/30/16
to Avi Drissman, Colin Blundell, PhistucK, Chromium-dev
I have some code that I'd like to profile for performance. It can run in any process, and eventually it will be randomized to run in only e.g. 1 in 10 processes. But I can't profile that directly because it is non-deterministic.

Instead, I'd like to have only 1 tab open, and the code running in the process that contains that tab. The test code would only run if it is in a renderer process (determined by looking at cmdline flags) that contains a tab (what I'm asking about).

Will Harris

unread,
Mar 30, 2016, 3:49:00 PM3/30/16
to Simon Que, Avi Drissman, Colin Blundell, PhistucK, Chromium-dev
Extension processes have --extension-process on them. Renderer processes can't contain plugins, so any Chrome process with --type=renderer without --extension-process should be a renderer displaying tab content. It might contain multiple tabs though.

It might be best to mediate this via the browser though, since the browser has the definitive knowledge of what every child process is doing and what it's hosting.

Will

Matt Falkenhagen

unread,
Mar 31, 2016, 6:12:01 AM3/31/16
to w...@chromium.org, Simon Que, Avi Drissman, Colin Blundell, PhistucK, Chromium-dev
One exception is a renderer created for a service worker that is not shared with a page. It would not display tab content yet would have --type=renderer.

Avi Drissman

unread,
Mar 31, 2016, 8:54:53 AM3/31/16
to Simon Que, Colin Blundell, PhistucK, Chromium-dev
Is this test code, or code we'll be shipping?

Your code would need to live in the browser, on the chrome side of content (obviously as it deals with tabs) and would need to coordinate what lives on the renderer side.

Simon Que

unread,
Mar 31, 2016, 1:45:26 PM3/31/16
to Avi Drissman, Colin Blundell, PhistucK, Chromium-dev
This is just test code.
Reply all
Reply to author
Forward
0 new messages