mirror of
https://github.com/lightpanda-io/browser.git
synced 2025-10-29 15:13:28 +00:00
Add performance.enable
Signed-off-by: Francis Bouvier <francis@lightpanda.io>
This commit is contained in:
@@ -11,6 +11,7 @@ const runtime = @import("runtime.zig").runtime;
|
|||||||
const network = @import("network.zig").network;
|
const network = @import("network.zig").network;
|
||||||
const emulation = @import("emulation.zig").emulation;
|
const emulation = @import("emulation.zig").emulation;
|
||||||
const fetch = @import("fetch.zig").fetch;
|
const fetch = @import("fetch.zig").fetch;
|
||||||
|
const performance = @import("performance.zig").performance;
|
||||||
|
|
||||||
pub const Error = error{
|
pub const Error = error{
|
||||||
UnknonwDomain,
|
UnknonwDomain,
|
||||||
@@ -37,6 +38,7 @@ const Domains = enum {
|
|||||||
Network,
|
Network,
|
||||||
Emulation,
|
Emulation,
|
||||||
Fetch,
|
Fetch,
|
||||||
|
Performance,
|
||||||
};
|
};
|
||||||
|
|
||||||
// The caller is responsible for calling `free` on the returned slice.
|
// The caller is responsible for calling `free` on the returned slice.
|
||||||
@@ -87,6 +89,7 @@ pub fn do(
|
|||||||
.Network => network(alloc, id, iter.next().?, &scanner, ctx),
|
.Network => network(alloc, id, iter.next().?, &scanner, ctx),
|
||||||
.Emulation => emulation(alloc, id, iter.next().?, &scanner, ctx),
|
.Emulation => emulation(alloc, id, iter.next().?, &scanner, ctx),
|
||||||
.Fetch => fetch(alloc, id, iter.next().?, &scanner, ctx),
|
.Fetch => fetch(alloc, id, iter.next().?, &scanner, ctx),
|
||||||
|
.Performance => performance(alloc, id, iter.next().?, &scanner, ctx),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
37
src/cdp/performance.zig
Normal file
37
src/cdp/performance.zig
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
const std = @import("std");
|
||||||
|
|
||||||
|
const server = @import("../server.zig");
|
||||||
|
const Ctx = server.Cmd;
|
||||||
|
const cdp = @import("cdp.zig");
|
||||||
|
const result = cdp.result;
|
||||||
|
const getMsg = cdp.getMsg;
|
||||||
|
|
||||||
|
const PerformanceMethods = enum {
|
||||||
|
enable,
|
||||||
|
};
|
||||||
|
|
||||||
|
pub fn performance(
|
||||||
|
alloc: std.mem.Allocator,
|
||||||
|
id: ?u16,
|
||||||
|
action: []const u8,
|
||||||
|
scanner: *std.json.Scanner,
|
||||||
|
ctx: *Ctx,
|
||||||
|
) ![]const u8 {
|
||||||
|
const method = std.meta.stringToEnum(PerformanceMethods, action) orelse
|
||||||
|
return error.UnknownMethod;
|
||||||
|
|
||||||
|
return switch (method) {
|
||||||
|
.enable => performanceEnable(alloc, id, scanner, ctx),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
fn performanceEnable(
|
||||||
|
alloc: std.mem.Allocator,
|
||||||
|
id: ?u16,
|
||||||
|
scanner: *std.json.Scanner,
|
||||||
|
_: *Ctx,
|
||||||
|
) ![]const u8 {
|
||||||
|
const msg = try getMsg(alloc, void, scanner);
|
||||||
|
|
||||||
|
return result(alloc, id orelse msg.id.?, null, null, msg.sessionID);
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user