Migrating code that will use ContentClient

225 views
Skip to first unread message

Ryan Tarpine

unread,
Sep 25, 2024, 2:14:01 PM9/25/24
to content...@chromium.org
Hello Content Owners,

I'm moving a lot of code from //chrome to //content. A big part of that migration involves using ContentClient instead of Chrome APIs.

To make sure I'm using ContentClient correctly, I want to use it now, before I actually move all the code, but content::GetContentClient() is not exposed outside of //content.

I could do it by making instances of classes like ChromeContentBrowserClient, but that could have side effects. It's meant to be a singleton after all.

I noticed content::GetContentClientForTesting() is exposed, and defined exactly the same as GetContentClient(). And it works if I use it!

Could I create another variant, maybe GetContentClientForMigration(), maybe taking base::NotFatalUntil? Or do you have any other ideas? (Technically I could probably get away with using GetContentClientForTesting() if I put a "// IN-TEST" comment on it 🙃 I just need this for a couple of weeks)

Thanks,
Ryan




Dave Tapuska

unread,
Sep 25, 2024, 2:23:24 PM9/25/24
to Ryan Tarpine, content...@chromium.org
It not being exposed outside of //content is an explicit choice.

Since you are already inside //chrome you should just grab a reference however you want in //chrome to the Delegate which owns the ContentClient... Then when you migrate any code you'd change that to GetContentClient()

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 on the web visit https://groups.google.com/a/chromium.org/d/msgid/content-owners/CAFdQzkR5zf9eyLrY_jH3_%2BoDgZ2y57SZDQgHy2QZ8ujihBvcXA%40mail.gmail.com.

Ryan Tarpine

unread,
Sep 25, 2024, 2:47:19 PM9/25/24
to Dave Tapuska, content...@chromium.org
How can I get a reference to the delegate? I looked but couldn't find a way.

Thanks,
Ryan

Dave Tapuska

unread,
Sep 25, 2024, 2:49:01 PM9/25/24
to Ryan Tarpine, content...@chromium.org
As the Content API stores just as a static global you'll have to add one. I'm just saying you can do this all in the //chrome layer (and not involve the //content layer right now until you move it).

dave.
Reply all
Reply to author
Forward
0 new messages