mirror of
https://github.com/lightpanda-io/browser.git
synced 2025-10-30 15:41:48 +00:00
move intercept_state and extra_headers from CDP instance to BrowserContext
This commit is contained in:
@@ -74,11 +74,6 @@ pub fn CDPT(comptime TypeProvider: type) type {
|
||||
// Used for processing notifications within a browser context.
|
||||
notification_arena: std.heap.ArenaAllocator,
|
||||
|
||||
// Extra headers to add to all requests. TBD under which conditions this should be reset.
|
||||
extra_headers: std.ArrayListUnmanaged([*c]const u8) = .empty,
|
||||
|
||||
intercept_state: InterceptState,
|
||||
|
||||
const Self = @This();
|
||||
|
||||
pub fn init(app: *App, client: TypeProvider.Client) !Self {
|
||||
@@ -93,7 +88,6 @@ pub fn CDPT(comptime TypeProvider: type) type {
|
||||
.browser_context = null,
|
||||
.message_arena = std.heap.ArenaAllocator.init(allocator),
|
||||
.notification_arena = std.heap.ArenaAllocator.init(allocator),
|
||||
.intercept_state = try InterceptState.init(allocator), // TBD or browser session arena?
|
||||
};
|
||||
}
|
||||
|
||||
@@ -101,7 +95,6 @@ pub fn CDPT(comptime TypeProvider: type) type {
|
||||
if (self.browser_context) |*bc| {
|
||||
bc.deinit();
|
||||
}
|
||||
self.intercept_state.deinit(); // TBD Should this live in BC?
|
||||
self.browser.deinit();
|
||||
self.message_arena.deinit();
|
||||
self.notification_arena.deinit();
|
||||
@@ -346,6 +339,11 @@ pub fn BrowserContext(comptime CDP_T: type) type {
|
||||
|
||||
http_proxy_changed: bool = false,
|
||||
|
||||
// Extra headers to add to all requests.
|
||||
extra_headers: std.ArrayListUnmanaged([*c]const u8) = .empty,
|
||||
|
||||
intercept_state: InterceptState,
|
||||
|
||||
const Self = @This();
|
||||
|
||||
fn init(self: *Self, id: []const u8, cdp: *CDP_T) !void {
|
||||
@@ -375,6 +373,7 @@ pub fn BrowserContext(comptime CDP_T: type) type {
|
||||
.isolated_world = null,
|
||||
.inspector = inspector,
|
||||
.notification_arena = cdp.notification_arena.allocator(),
|
||||
.intercept_state = try InterceptState.init(allocator),
|
||||
};
|
||||
self.node_search_list = Node.Search.List.init(allocator, &self.node_registry);
|
||||
errdefer self.deinit();
|
||||
@@ -407,6 +406,11 @@ pub fn BrowserContext(comptime CDP_T: type) type {
|
||||
log.warn(.http, "restoreOriginalProxy", .{ .err = err });
|
||||
};
|
||||
}
|
||||
|
||||
for (self.intercept_state.pendingTransfers()) |transfer| {
|
||||
transfer.abort();
|
||||
}
|
||||
self.intercept_state.deinit();
|
||||
}
|
||||
|
||||
pub fn reset(self: *Self) void {
|
||||
|
||||
Reference in New Issue
Block a user