Repository navigation
refactor: decouple api::WebRequest from api::BrowserContext - #48848
Merged
Merged
Conversation
…eate() This is both clearer and more consistent with other classes
ckerr
force-pushed
the
refactor/decouple-WebRequest-and-BrowserContext
branch
from
November 7, 2025 22:41
8fc4a6b to
3e3c69d
Compare
…ion::FromOrCreate()
no longer needed; Session already guarantees uniqueness
no longer needed now that access goes through Session
ckerr
force-pushed
the
refactor/decouple-WebRequest-and-BrowserContext
branch
from
November 7, 2025 22:46
3e3c69d to
102e656
Compare
3 tasks done
codebytere
approved these changes
Nov 8, 2025
|
No Release Notes |
deepak1556
reviewed
Nov 10, 2025
Comment on lines
+1696
to
+1697
| DCHECK(false); | ||
| return {}; |
Member
There was a problem hiding this comment.
Expecting a DCHECK that is always false but returning a null value in release builds seems to contradict, would this be better with NOTREACHED ?
Member
Author
There was a problem hiding this comment.
I'm fine with making this NOTREACHED
3 tasks done
nilayarya
pushed a commit
to nilayarya/electron
that referenced
this pull request
Nov 21, 2025
…tron#48848) * refactor: rename api::Session::CreateFrom() to api::Session::FromOrCreate() This is both clearer and more consistent with other classes * refactor: add Session::FromOrCreate(content::BrowserContext*) * refactor: reimplement api::WebRequest::FromOrCreate() using api::Session::FromOrCreate() * refactor: use base::PassKey to ensure WebRequest is only instantiated by Session * refactor: remove WebRequest::From() no longer needed; Session already guarantees uniqueness * refactor: remove unused isolate arg from WebRequest ctor * refactor: do not attach WebRequest to BrowserContext no longer needed now that access goes through Session
nilayarya
added a commit
to nilayarya/electron
that referenced
this pull request
Nov 21, 2025
…tron#48848) * refactor: rename api::Session::CreateFrom() to api::Session::FromOrCreate() This is both clearer and more consistent with other classes * refactor: add Session::FromOrCreate(content::BrowserContext*) * refactor: reimplement api::WebRequest::FromOrCreate() using api::Session::FromOrCreate() * refactor: use base::PassKey to ensure WebRequest is only instantiated by Session * refactor: remove WebRequest::From() no longer needed; Session already guarantees uniqueness * refactor: remove unused isolate arg from WebRequest ctor * refactor: do not attach WebRequest to BrowserContext no longer needed now that access goes through Session
nilayarya
added a commit
to nilayarya/electron
that referenced
this pull request
Nov 21, 2025
…tron#48848) * refactor: rename api::Session::CreateFrom() to api::Session::FromOrCreate() This is both clearer and more consistent with other classes * refactor: add Session::FromOrCreate(content::BrowserContext*) * refactor: reimplement api::WebRequest::FromOrCreate() using api::Session::FromOrCreate() * refactor: use base::PassKey to ensure WebRequest is only instantiated by Session * refactor: remove WebRequest::From() no longer needed; Session already guarantees uniqueness * refactor: remove unused isolate arg from WebRequest ctor * refactor: do not attach WebRequest to BrowserContext no longer needed now that access goes through Session
This was referenced Nov 24, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description of Change
Followup of #48792.
Prerequisite of #48762.
Simplify the lifecycle of
api::WebRequest.tldr:
api::WebRequestis created and owned by anapi::Sessionin a 1:1 relationship.base::PassKey<>to ensureapi::WebRequestcan only be instantiated byapi::SessionSession::CreateFrom()toSession::FromOrCreate()for clarity & symmetry with other Electron classesapi::WebRequest::FromOrCreate()to just callapi::Session::FromOrCreate()->WebRequest()api::WebRequestpointers tocontent::BrowserContextviabase::UserDataapi::WebRequest::From()api::WebRequest::browser_context_CC @codebytere, @deepak1556
Checklist
npm testpassesRelease Notes
Notes: none.