summaryrefslogtreecommitdiffstats
path: root/chromium/third_party/WebKit/Source/core/dom/WeakNodeMap.h
blob: 44cdf59fb47ab290b05c5e802597f0fa337d64c2 (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
// 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 WeakNodeMap_h
#define WeakNodeMap_h

#include "wtf/HashMap.h"

namespace WebCore {

class Node;
class NodeToWeakNodeMaps;

class WeakNodeMap {
public:
    ~WeakNodeMap();

    void put(Node*, int value);
    int value(Node*);
    Node* node(int value);

private:
    // FIXME: This should not be friends with Node, we should expose a proper API and not
    // let the map directly set flags.
    friend class Node;
    static void notifyNodeDestroyed(Node*);

    friend class NodeToWeakNodeMaps;
    void nodeDestroyed(Node*);

    typedef HashMap<Node*, int> NodeToValue;
    NodeToValue m_nodeToValue;
    typedef HashMap<int, Node*> ValueToNode;
    ValueToNode m_valueToNode;
};

}

#endif