Skip to content
This repository was archived by the owner on Jan 30, 2025. It is now read-only.

Commit 641b0c6

Browse files
committed
Refactor emit to onLifecycleEvent
There's no need for recalculateLifecycle since all it is now doing is emitting the event to internal handlers. So refactor/move it to onLifecycleEvent. Closes: #593
1 parent b66da87 commit 641b0c6

File tree

2 files changed

+3
-12
lines changed

2 files changed

+3
-12
lines changed

common/frame.go

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -183,12 +183,6 @@ func (f *Frame) clearLifecycle() {
183183
f.inflightRequestsMu.Unlock()
184184
}
185185

186-
func (f *Frame) recalculateLifecycle(event LifecycleEvent) {
187-
f.log.Debugf("Frame:recalculateLifecycle", "fid:%s furl:%q", f.ID(), f.URL())
188-
189-
f.emit(EventFrameAddLifecycle, event)
190-
}
191-
192186
func (f *Frame) detach() {
193187
f.log.Debugf("Frame:detach", "fid:%s furl:%q", f.ID(), f.URL())
194188

@@ -340,12 +334,10 @@ func (f *Frame) onLifecycleEvent(event LifecycleEvent) {
340334
f.log.Debugf("Frame:onLifecycleEvent", "fid:%s furl:%q event:%s", f.ID(), f.URL(), event)
341335

342336
f.lifecycleEventsMu.Lock()
343-
defer f.lifecycleEventsMu.Unlock()
344-
345-
if ok := f.lifecycleEvents[event]; ok {
346-
return
347-
}
348337
f.lifecycleEvents[event] = true
338+
f.lifecycleEventsMu.Unlock()
339+
340+
f.emit(EventFrameAddLifecycle, event)
349341
}
350342

351343
func (f *Frame) onLoadingStarted() {

common/frame_manager.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,6 @@ func (m *FrameManager) frameLifecycleEvent(frameID cdp.FrameID, event LifecycleE
195195
frame := m.getFrameByID(frameID)
196196
if frame != nil {
197197
frame.onLifecycleEvent(event)
198-
frame.recalculateLifecycle(event)
199198
}
200199
}
201200

0 commit comments

Comments
 (0)