Page lifecycle observer?

12 views
Skip to first unread message

Dan Murphy

unread,
Oct 10, 2025, 12:28:10 PMOct 10
to content-owners, Marijn Kruisselbrink
Hello!

I'm trying to simplify a bunch of the code in the web_applications system, and we seem to be doing a bunch of crazy stuff with WebContentsObserver to do a seemingly simple thing:
  • Compute a value / do work on a per-"content::Page" basis (fetch manifest and cache it, among some other things)
  • Have that fetch be 'cancelled' / have another callback be called when the page has transitioned from 'active' to 'inactive'
It seems like, right now, I have to use a WebContentsObserver and do a bunch of caching work and listen to PrimaryPageChanged among other things.

My question - is there an observer interface somehow for the page.h or on the Lifecycle of RenderFrameHost? this would make it ultra easy to have one class encapsulate the responsibility of doing async work on an active page for users that also need to know when the page has become inactive.

Thanks,
Dan

Dan Murphy

unread,
Oct 10, 2025, 3:24:07 PMOct 10
to content-owners, Marijn Kruisselbrink
I guess the best I can do is make the thing a WebContentsObserver and listen to RenderFrameHostStateChanged? And I'm guessing pages HAVE to have a render frame host, which HAS to have a web contents? hopefully?

Dave Tapuska

unread,
Oct 10, 2025, 3:28:39 PMOct 10
to Dan Murphy, content-owners, Marijn Kruisselbrink
Yes... RFH will have a WebContents. There is also PageUserData which lets you organize some state.. but doesn't give you the transition listening.

dave.

--
You received this message because you are subscribed to the Google Groups "content-owners" group.
To unsubscribe from this group and stop receiving emails from it, send an email to content-owner...@chromium.org.
To view this discussion visit https://groups.google.com/a/chromium.org/d/msgid/content-owners/CA%2B4qT33ag8VMdF6eQQeg6cZUWtge2ftQczT1%2BwMg7_r5toG4_w%40mail.gmail.com.
Reply all
Reply to author
Forward
0 new messages