1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
6 #include "web/OpenedFrameTracker.h"
8 #include "platform/heap/Handle.h"
9 #include "public/web/WebFrame.h"
13 OpenedFrameTracker::OpenedFrameTracker()
17 OpenedFrameTracker::~OpenedFrameTracker()
20 // Oilpan takes care of clearing weak m_opener fields during GC.
25 bool OpenedFrameTracker::isEmpty() const
27 return m_openedFrames
.isEmpty();
30 void OpenedFrameTracker::add(WebFrame
* frame
)
32 m_openedFrames
.add(frame
);
35 void OpenedFrameTracker::remove(WebFrame
* frame
)
37 m_openedFrames
.remove(frame
);
40 void OpenedFrameTracker::updateOpener(WebFrame
* frame
)
42 HashSet
<WebFrame
*>::iterator end
= m_openedFrames
.end();
43 for (HashSet
<WebFrame
*>::iterator it
= m_openedFrames
.begin(); it
!= end
; ++it
)
44 (*it
)->m_opener
= frame
;
47 template <typename VisitorDispatcher
>
48 ALWAYS_INLINE
void OpenedFrameTracker::traceFramesImpl(VisitorDispatcher visitor
)
51 HashSet
<WebFrame
*>::iterator end
= m_openedFrames
.end();
52 for (HashSet
<WebFrame
*>::iterator it
= m_openedFrames
.begin(); it
!= end
; ++it
)
53 WebFrame::traceFrame(visitor
, *it
);
57 void OpenedFrameTracker::traceFrames(Visitor
* visitor
) { traceFramesImpl(visitor
); }
58 void OpenedFrameTracker::traceFrames(InlinedGlobalMarkingVisitor visitor
) { traceFramesImpl(visitor
); }