Skip to content

refactor: make api::WebRequest inherit from gin::Wrappable - #48762

Merged
ckerr merged 9 commits into
mainfrom
refactor/oilpan-api-web-request
Nov 12, 2025
Merged

ckerr merged 9 commits into
mainfrom
refactor/oilpan-api-web-request

Conversation

@ckerr

@ckerr ckerr commented Nov 3, 2025 •

Copy link
Copy Markdown
Member

Description of Change

Part of #47922

  • Refactor electron::api::WebRequest to inherit from gin::Wrappable instead of gin_helper::DeprecatedWrappable
  • Refactor electron::api::Session::web_request_ to be a cppgc::Member<WebRequest> instead of a v8::TracedReference<v8::Value>
  • Remove unused v8::Isolate* argument from electron::api::WebRequest constructor
  • Modify WebRequest::Create(), WebRequest::Find(), and WebRequest::FindOrCreate() to return an api::WebRequest*

CC @deepak1556 as a #47922 stakeholder. All reviews welcomed.

Checklist

Release Notes

Notes: none

@ckerr
ckerr requested a review from a team as a code owner November 3, 2025 22:07
@electron-cation electron-cation Bot added the new-pr 🌱 PR opened recently label Nov 3, 2025
@ckerr ckerr changed the title refactor: make api::WebRequest inherit from gin::Wrappable refactor: make api::WebRequest inherit from gin::Wrappable Nov 3, 2025
@ckerr
ckerr marked this pull request as draft November 4, 2025 03:29
@ckerr
ckerr force-pushed the refactor/oilpan-api-web-request branch from 83582f4 to ecb3eef Compare November 4, 2025 16:11
@electron-cation electron-cation Bot removed the new-pr 🌱 PR opened recently label Nov 4, 2025
@ckerr
ckerr force-pushed the refactor/oilpan-api-web-request branch from ecb3eef to 5638291 Compare November 5, 2025 03:44
ckerr added a commit that referenced this pull request Nov 5, 2025
Remove the |electron::WebRequestAPI| interface class.
Use handles to the concrete class |electron::api::WebRequest| instead.

Prerequisite for #48762.

Two classes (electron::ProxyingURLLoaderFactory and electron::ProxyingWebSocket)
hold a handle to a WebRequest via |raw_ptr<electron::WebRequestAPI>|.
|electron::WebRequestAPI| is a pure virtual interface whose concrete impl is
|electron::api::WebRequest|.

This is a problem when migrating |electron::api::WebRequest| to cppgc:
we need to change those |raw_ptr<>|s to |cppgc::WeakPersistent<>| but
can't instantiate |cppgc::WeakPersistent<electron::WebRequestAPI>| as-is.
We also can't change it to inherit from |cppgc::GarbageCollectedMixin|,
since that causes problems when |electron::api::WebRequest| inherits from
both |electron::WebRequestAPI| and |cppgc::GarbageCollected|.
deepak1556 pushed a commit that referenced this pull request Nov 6, 2025
* refactor: remove electron::WebRequestAPI interface

Remove the |electron::WebRequestAPI| interface class.
Use handles to the concrete class |electron::api::WebRequest| instead.

Prerequisite for #48762.

Two classes (electron::ProxyingURLLoaderFactory and electron::ProxyingWebSocket)
hold a handle to a WebRequest via |raw_ptr<electron::WebRequestAPI>|.
|electron::WebRequestAPI| is a pure virtual interface whose concrete impl is
|electron::api::WebRequest|.

This is a problem when migrating |electron::api::WebRequest| to cppgc:
we need to change those |raw_ptr<>|s to |cppgc::WeakPersistent<>| but
can't instantiate |cppgc::WeakPersistent<electron::WebRequestAPI>| as-is.
We also can't change it to inherit from |cppgc::GarbageCollectedMixin|,
since that causes problems when |electron::api::WebRequest| inherits from
both |electron::WebRequestAPI| and |cppgc::GarbageCollected|.

* refactor: use name web_request, not web_request_api

* refactor: make ProxyingURLLoaderFactory::web_request() private

* chore: make linter happy by fixing whitespace
@ckerr
ckerr force-pushed the refactor/oilpan-api-web-request branch from 5638291 to ec51a34 Compare November 6, 2025 19:56
@ckerr

ckerr commented Nov 6, 2025

Copy link
Copy Markdown
Member Author

I've addressed the current code feedback but I'm going to leave it in draft form for now. TODO:

  1. ProxyingWebSocket needs to use a WeakPersistent<> instead of raw_ptr<>
  2. ProxyingWebSocket and ProxyingURLLoaderFactory need to fail gracefully when the weak reference is empty

@ckerr
ckerr force-pushed the refactor/oilpan-api-web-request branch from 97cde6c to 7add606 Compare November 9, 2025 15:38
@ckerr ckerr mentioned this pull request Nov 10, 2025
2 tasks done
@ckerr
ckerr marked this pull request as ready for review November 10, 2025 22:38
@ckerr

ckerr commented Nov 10, 2025

Copy link
Copy Markdown
Member Author

@deepak1556 @codebytere this is finally ready for review; I've rebased it + updated it after #48848.

@electron-cation electron-cation Bot added the new-pr 🌱 PR opened recently label Nov 10, 2025

@deepak1556 deepak1556 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs another rebase to adjust for #48512, particularly around gin::weakcell adoption for the auth result callback.

@electron-cation electron-cation Bot removed the new-pr 🌱 PR opened recently label Nov 11, 2025
@ckerr
ckerr force-pushed the refactor/oilpan-api-web-request branch from 50eee73 to 9a7930a Compare November 12, 2025 00:59
refactor: remove unused v8::Isolate* arg from WebRequest ctor

refactor: make electron::api::Session::web_request_ a cppgc::Member<api::WebRequest>

refactor: allocate api::WebRequest on cpp heap

refactor: modify Create(), Find(), and FindOrCreate() to return a WebRequest*
…nstead of a WebRequestAPI

Experimental commit to ensure `ProxyingURLLoaderFactory::web_request_api_`
won't be a dangling pointer.
@ckerr
ckerr force-pushed the refactor/oilpan-api-web-request branch from 9a7930a to a4a12e3 Compare November 12, 2025 15:57

@deepak1556 deepak1556 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@ckerr
ckerr merged commit 3c55130 into main Nov 12, 2025
@ckerr
ckerr deleted the refactor/oilpan-api-web-request branch November 12, 2025 18:53
@release-clerk

release-clerk Bot commented Nov 12, 2025

Copy link
Copy Markdown

No Release Notes

nilayarya pushed a commit to nilayarya/electron that referenced this pull request Nov 21, 2025
* refactor: remove electron::WebRequestAPI interface

Remove the |electron::WebRequestAPI| interface class.
Use handles to the concrete class |electron::api::WebRequest| instead.

Prerequisite for electron#48762.

Two classes (electron::ProxyingURLLoaderFactory and electron::ProxyingWebSocket)
hold a handle to a WebRequest via |raw_ptr<electron::WebRequestAPI>|.
|electron::WebRequestAPI| is a pure virtual interface whose concrete impl is
|electron::api::WebRequest|.

This is a problem when migrating |electron::api::WebRequest| to cppgc:
we need to change those |raw_ptr<>|s to |cppgc::WeakPersistent<>| but
can't instantiate |cppgc::WeakPersistent<electron::WebRequestAPI>| as-is.
We also can't change it to inherit from |cppgc::GarbageCollectedMixin|,
since that causes problems when |electron::api::WebRequest| inherits from
both |electron::WebRequestAPI| and |cppgc::GarbageCollected|.

* refactor: use name web_request, not web_request_api

* refactor: make ProxyingURLLoaderFactory::web_request() private

* chore: make linter happy by fixing whitespace
nilayarya pushed a commit to nilayarya/electron that referenced this pull request Nov 21, 2025
…ron#48762)

* refactor: make api::WebRequest inherit from gin::Wrappable

refactor: remove unused v8::Isolate* arg from WebRequest ctor

refactor: make electron::api::Session::web_request_ a cppgc::Member<api::WebRequest>

refactor: allocate api::WebRequest on cpp heap

refactor: modify Create(), Find(), and FindOrCreate() to return a WebRequest*

* refactor: ProxyingURLLoaderFactory takes a concrete api::WebRequest instead of a WebRequestAPI

Experimental commit to ensure `ProxyingURLLoaderFactory::web_request_api_`
won't be a dangling pointer.

* chore: fix doc shear

* refactor: use cppgc::WeakPersistent<> in ProxyingURLLoaderFactory

* refactor: make ProxyingURLLoaderFactory::web_request_ const

* refactor: make ProxyingWebSocket::web_request_ a cppgc::WeakPersistent<>

* add a gin::WeakCellFactory to api::WebRequest

* refactor: use a gin::WeakCell for the bound WebRequest argument in HandleOnBeforeRequestResponseEvent()

* chore: update patches
nilayarya added a commit to nilayarya/electron that referenced this pull request Nov 21, 2025
* refactor: remove electron::WebRequestAPI interface

Remove the |electron::WebRequestAPI| interface class.
Use handles to the concrete class |electron::api::WebRequest| instead.

Prerequisite for electron#48762.

Two classes (electron::ProxyingURLLoaderFactory and electron::ProxyingWebSocket)
hold a handle to a WebRequest via |raw_ptr<electron::WebRequestAPI>|.
|electron::WebRequestAPI| is a pure virtual interface whose concrete impl is
|electron::api::WebRequest|.

This is a problem when migrating |electron::api::WebRequest| to cppgc:
we need to change those |raw_ptr<>|s to |cppgc::WeakPersistent<>| but
can't instantiate |cppgc::WeakPersistent<electron::WebRequestAPI>| as-is.
We also can't change it to inherit from |cppgc::GarbageCollectedMixin|,
since that causes problems when |electron::api::WebRequest| inherits from
both |electron::WebRequestAPI| and |cppgc::GarbageCollected|.

* refactor: use name web_request, not web_request_api

* refactor: make ProxyingURLLoaderFactory::web_request() private

* chore: make linter happy by fixing whitespace
nilayarya added a commit to nilayarya/electron that referenced this pull request Nov 21, 2025
…ron#48762)

* refactor: make api::WebRequest inherit from gin::Wrappable

refactor: remove unused v8::Isolate* arg from WebRequest ctor

refactor: make electron::api::Session::web_request_ a cppgc::Member<api::WebRequest>

refactor: allocate api::WebRequest on cpp heap

refactor: modify Create(), Find(), and FindOrCreate() to return a WebRequest*

* refactor: ProxyingURLLoaderFactory takes a concrete api::WebRequest instead of a WebRequestAPI

Experimental commit to ensure `ProxyingURLLoaderFactory::web_request_api_`
won't be a dangling pointer.

* chore: fix doc shear

* refactor: use cppgc::WeakPersistent<> in ProxyingURLLoaderFactory

* refactor: make ProxyingURLLoaderFactory::web_request_ const

* refactor: make ProxyingWebSocket::web_request_ a cppgc::WeakPersistent<>

* add a gin::WeakCellFactory to api::WebRequest

* refactor: use a gin::WeakCell for the bound WebRequest argument in HandleOnBeforeRequestResponseEvent()

* chore: update patches
nilayarya added a commit to nilayarya/electron that referenced this pull request Nov 21, 2025
* refactor: remove electron::WebRequestAPI interface

Remove the |electron::WebRequestAPI| interface class.
Use handles to the concrete class |electron::api::WebRequest| instead.

Prerequisite for electron#48762.

Two classes (electron::ProxyingURLLoaderFactory and electron::ProxyingWebSocket)
hold a handle to a WebRequest via |raw_ptr<electron::WebRequestAPI>|.
|electron::WebRequestAPI| is a pure virtual interface whose concrete impl is
|electron::api::WebRequest|.

This is a problem when migrating |electron::api::WebRequest| to cppgc:
we need to change those |raw_ptr<>|s to |cppgc::WeakPersistent<>| but
can't instantiate |cppgc::WeakPersistent<electron::WebRequestAPI>| as-is.
We also can't change it to inherit from |cppgc::GarbageCollectedMixin|,
since that causes problems when |electron::api::WebRequest| inherits from
both |electron::WebRequestAPI| and |cppgc::GarbageCollected|.

* refactor: use name web_request, not web_request_api

* refactor: make ProxyingURLLoaderFactory::web_request() private

* chore: make linter happy by fixing whitespace
nilayarya added a commit to nilayarya/electron that referenced this pull request Nov 21, 2025
…ron#48762)

* refactor: make api::WebRequest inherit from gin::Wrappable

refactor: remove unused v8::Isolate* arg from WebRequest ctor

refactor: make electron::api::Session::web_request_ a cppgc::Member<api::WebRequest>

refactor: allocate api::WebRequest on cpp heap

refactor: modify Create(), Find(), and FindOrCreate() to return a WebRequest*

* refactor: ProxyingURLLoaderFactory takes a concrete api::WebRequest instead of a WebRequestAPI

Experimental commit to ensure `ProxyingURLLoaderFactory::web_request_api_`
won't be a dangling pointer.

* chore: fix doc shear

* refactor: use cppgc::WeakPersistent<> in ProxyingURLLoaderFactory

* refactor: make ProxyingURLLoaderFactory::web_request_ const

* refactor: make ProxyingWebSocket::web_request_ a cppgc::WeakPersistent<>

* add a gin::WeakCellFactory to api::WebRequest

* refactor: use a gin::WeakCell for the bound WebRequest argument in HandleOnBeforeRequestResponseEvent()

* chore: update patches
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants