summaryrefslogtreecommitdiffstats
path: root/chromium/third_party/WebKit/Source/web/OpenedFrameTracker.h
blob: 79beaa2c291331c96217ecd5d8eb5f353cb11eb5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef OpenedFrameTracker_h
#define OpenedFrameTracker_h

#include "wtf/HashSet.h"
#include "wtf/Noncopyable.h"

namespace blink {

class Visitor;
class InlinedGlobalMarkingVisitor;
class WebFrame;

// Small helper class to track the set of frames that a WebFrame has opened.
// Due to layering restrictions, we need to hide the implementation, since
// public/web/ cannot depend on wtf/.
class OpenedFrameTracker {
    WTF_MAKE_NONCOPYABLE(OpenedFrameTracker);
public:
    OpenedFrameTracker();
    ~OpenedFrameTracker();

    bool isEmpty() const;
    void add(WebFrame*);
    void remove(WebFrame*);

    // Helper used when swapping a frame into the frame tree: this updates the
    // opener for opened frames to point to the new frame being swapped in.
    void transferTo(WebFrame*);

    void traceFrames(Visitor*);
    void traceFrames(InlinedGlobalMarkingVisitor);

private:
    template <typename VisitorDispatcher>
    void traceFramesImpl(VisitorDispatcher);

    WTF::HashSet<WebFrame*> m_openedFrames;
};

} // namespace blink

#endif // WebFramePrivate_h