Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / Source / web / OpenedFrameTracker.cpp
blobbd0181391b5d3058672a7cb313c2cc45e90f8d1b
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.
5 #include "config.h"
6 #include "web/OpenedFrameTracker.h"
8 #include "platform/heap/Handle.h"
9 #include "public/web/WebFrame.h"
11 namespace blink {
13 OpenedFrameTracker::OpenedFrameTracker()
17 OpenedFrameTracker::~OpenedFrameTracker()
19 #if !ENABLE(OILPAN)
20 // Oilpan takes care of clearing weak m_opener fields during GC.
21 updateOpener(0);
22 #endif
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)
50 #if ENABLE(OILPAN)
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);
54 #endif
57 void OpenedFrameTracker::traceFrames(Visitor* visitor) { traceFramesImpl(visitor); }
58 void OpenedFrameTracker::traceFrames(InlinedGlobalMarkingVisitor visitor) { traceFramesImpl(visitor); }
60 } // namespace blink