Skip to content

Commit 3fc7ffa

Browse files
committed
rename ts => timestamp, ctx => notify_ctx
1 parent 30fd358 commit 3fc7ffa

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed

src/browser/browser.zig

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ pub const Session = struct {
139139
jstypes: [Types.len]usize = undefined,
140140

141141
// recipient of notification, passed as the first parameter to notify
142-
ctx: *anyopaque,
142+
notify_ctx: *anyopaque,
143143
notify_func: *const fn (ctx: *anyopaque, notification: *const Notification) anyerror!void,
144144

145145
fn init(self: *Session, browser: *Browser, ctx: anytype) !void {
@@ -159,9 +159,9 @@ pub const Session = struct {
159159
const allocator = app.allocator;
160160
self.* = .{
161161
.app = app,
162-
.ctx = any_ctx,
163162
.env = undefined,
164163
.browser = browser,
164+
.notify_ctx = any_ctx,
165165
.inspector = undefined,
166166
.notify_func = ContextStruct.notify,
167167
.http_client = browser.http_client,
@@ -281,7 +281,7 @@ pub const Session = struct {
281281
}
282282

283283
fn notify(self: *const Session, notification: *const Notification) void {
284-
self.notify_func(self.ctx, notification) catch |err| {
284+
self.notify_func(self.notify_ctx, notification) catch |err| {
285285
log.err("notify {}: {}", .{ std.meta.activeTag(notification.*), err });
286286
};
287287
}
@@ -386,7 +386,7 @@ pub const Page = struct {
386386
var request = try self.newHTTPRequest(.GET, url, .{ .navigation = true });
387387
defer request.deinit();
388388

389-
session.notify(&.{ .page_navigate = .{ .url = url, .ts = timestamp() } });
389+
session.notify(&.{ .page_navigate = .{ .url = url, .timestamp = timestamp() } });
390390
var response = try request.sendSync(.{});
391391

392392
// would be different than self.url in the case of a redirect
@@ -428,7 +428,7 @@ pub const Page = struct {
428428
self.raw_data = arr.items;
429429
}
430430

431-
session.notify(&.{ .page_navigated = .{ .url = url, .ts = timestamp() } });
431+
session.notify(&.{ .page_navigated = .{ .url = url, .timestamp = timestamp() } });
432432
}
433433

434434
pub const ClickResult = union(enum) {

src/cdp/domains/page.zig

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ pub fn pageNavigate(bc: anytype, event: *const Notification.PageEvent) !void {
198198
.name = "init",
199199
.frameId = target_id,
200200
.loaderId = loader_id,
201-
.timestamp = event.ts,
201+
.timestamp = event.timestamp,
202202
}, .{ .session_id = session_id });
203203
}
204204

@@ -213,7 +213,7 @@ pub fn pageNavigated(bc: anytype, event: *const Notification.PageEvent) !void {
213213
std.debug.assert(bc.session.page != null);
214214

215215
var cdp = bc.cdp;
216-
const ts = event.ts;
216+
const timestamp = event.timestamp;
217217
const loader_id = bc.loader_id;
218218
const target_id = bc.target_id orelse unreachable;
219219
const session_id = bc.session_id orelse unreachable;
@@ -236,15 +236,15 @@ pub fn pageNavigated(bc: anytype, event: *const Notification.PageEvent) !void {
236236
// TODO: partially hard coded
237237
try cdp.sendEvent(
238238
"Page.domContentEventFired",
239-
.{ .timestamp = ts },
239+
.{ .timestamp = timestamp },
240240
.{ .session_id = session_id },
241241
);
242242

243243
// lifecycle DOMContentLoaded event
244244
// TODO: partially hard coded
245245
if (bc.page_life_cycle_events) {
246246
try cdp.sendEvent("Page.lifecycleEvent", LifecycleEvent{
247-
.timestamp = ts,
247+
.timestamp = timestamp,
248248
.name = "DOMContentLoaded",
249249
.frameId = target_id,
250250
.loaderId = loader_id,
@@ -254,14 +254,14 @@ pub fn pageNavigated(bc: anytype, event: *const Notification.PageEvent) !void {
254254
// loadEventFired event
255255
try cdp.sendEvent(
256256
"Page.loadEventFired",
257-
.{ .timestamp = ts },
257+
.{ .timestamp = timestamp },
258258
.{ .session_id = session_id },
259259
);
260260

261261
// lifecycle DOMContentLoaded event
262262
if (bc.page_life_cycle_events) {
263263
try cdp.sendEvent("Page.lifecycleEvent", LifecycleEvent{
264-
.timestamp = ts,
264+
.timestamp = timestamp,
265265
.name = "load",
266266
.frameId = target_id,
267267
.loaderId = loader_id,

src/notification.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ pub const Notification = union(enum) {
55
page_navigated: PageEvent,
66

77
pub const PageEvent = struct {
8-
ts: u32,
8+
timestamp: u32,
99
url: *const URL,
1010
};
1111
};

0 commit comments

Comments
 (0)