Skip to content

Commit

Permalink
Refactor emit to onLifecycleEvent
Browse files Browse the repository at this point in the history
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
  • Loading branch information
ankur22 committed Nov 8, 2022
1 parent 16a6a8d commit 80e94c4
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 12 deletions.
14 changes: 3 additions & 11 deletions common/frame.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,12 +183,6 @@ func (f *Frame) clearLifecycle() {
f.inflightRequestsMu.Unlock()
}

func (f *Frame) recalculateLifecycle(event LifecycleEvent) {
f.log.Debugf("Frame:recalculateLifecycle", "fid:%s furl:%q", f.ID(), f.URL())

f.emit(EventFrameAddLifecycle, event)
}

func (f *Frame) detach() {
f.log.Debugf("Frame:detach", "fid:%s furl:%q", f.ID(), f.URL())

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

f.lifecycleEventsMu.Lock()
defer f.lifecycleEventsMu.Unlock()

if ok := f.lifecycleEvents[event]; ok {
return
}
f.lifecycleEvents[event] = true
f.lifecycleEventsMu.Unlock()

f.emit(EventFrameAddLifecycle, event)
}

func (f *Frame) onLoadingStarted() {
Expand Down
1 change: 0 additions & 1 deletion common/frame_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,6 @@ func (m *FrameManager) frameLifecycleEvent(frameID cdp.FrameID, event LifecycleE
frame := m.getFrameByID(frameID)
if frame != nil {
frame.onLifecycleEvent(event)
frame.recalculateLifecycle(event)
}
}

Expand Down

0 comments on commit 80e94c4

Please sign in to comment.