OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 30 matching lines...) Expand all Loading... |
41 | 41 |
42 V0CustomElementUpgradeCandidateMap::~V0CustomElementUpgradeCandidateMap() {} | 42 V0CustomElementUpgradeCandidateMap::~V0CustomElementUpgradeCandidateMap() {} |
43 | 43 |
44 void V0CustomElementUpgradeCandidateMap::add( | 44 void V0CustomElementUpgradeCandidateMap::add( |
45 const V0CustomElementDescriptor& descriptor, | 45 const V0CustomElementDescriptor& descriptor, |
46 Element* element) { | 46 Element* element) { |
47 observe(element); | 47 observe(element); |
48 | 48 |
49 UpgradeCandidateMap::AddResult result = | 49 UpgradeCandidateMap::AddResult result = |
50 m_upgradeCandidates.add(element, descriptor); | 50 m_upgradeCandidates.add(element, descriptor); |
51 ASSERT_UNUSED(result, result.isNewEntry); | 51 DCHECK(result.isNewEntry); |
52 | 52 |
53 UnresolvedDefinitionMap::iterator it = | 53 UnresolvedDefinitionMap::iterator it = |
54 m_unresolvedDefinitions.find(descriptor); | 54 m_unresolvedDefinitions.find(descriptor); |
55 ElementSet* elements; | 55 ElementSet* elements; |
56 if (it == m_unresolvedDefinitions.end()) | 56 if (it == m_unresolvedDefinitions.end()) |
57 elements = m_unresolvedDefinitions.add(descriptor, new ElementSet()) | 57 elements = m_unresolvedDefinitions.add(descriptor, new ElementSet()) |
58 .storedValue->value.get(); | 58 .storedValue->value.get(); |
59 else | 59 else |
60 elements = it->value.get(); | 60 elements = it->value.get(); |
61 elements->add(element); | 61 elements->add(element); |
62 } | 62 } |
63 | 63 |
64 void V0CustomElementUpgradeCandidateMap::elementWasDestroyed(Element* element) { | 64 void V0CustomElementUpgradeCandidateMap::elementWasDestroyed(Element* element) { |
65 V0CustomElementObserver::elementWasDestroyed(element); | 65 V0CustomElementObserver::elementWasDestroyed(element); |
66 UpgradeCandidateMap::iterator candidate = m_upgradeCandidates.find(element); | 66 UpgradeCandidateMap::iterator candidate = m_upgradeCandidates.find(element); |
67 ASSERT_WITH_SECURITY_IMPLICATION(candidate != m_upgradeCandidates.end()); | 67 SECURITY_DCHECK(candidate != m_upgradeCandidates.end()); |
68 | 68 |
69 UnresolvedDefinitionMap::iterator elements = | 69 UnresolvedDefinitionMap::iterator elements = |
70 m_unresolvedDefinitions.find(candidate->value); | 70 m_unresolvedDefinitions.find(candidate->value); |
71 ASSERT_WITH_SECURITY_IMPLICATION(elements != m_unresolvedDefinitions.end()); | 71 SECURITY_DCHECK(elements != m_unresolvedDefinitions.end()); |
72 elements->value->remove(element); | 72 elements->value->remove(element); |
73 m_upgradeCandidates.remove(candidate); | 73 m_upgradeCandidates.remove(candidate); |
74 } | 74 } |
75 | 75 |
76 V0CustomElementUpgradeCandidateMap::ElementSet* | 76 V0CustomElementUpgradeCandidateMap::ElementSet* |
77 V0CustomElementUpgradeCandidateMap::takeUpgradeCandidatesFor( | 77 V0CustomElementUpgradeCandidateMap::takeUpgradeCandidatesFor( |
78 const V0CustomElementDescriptor& descriptor) { | 78 const V0CustomElementDescriptor& descriptor) { |
79 ElementSet* candidates = m_unresolvedDefinitions.take(descriptor); | 79 ElementSet* candidates = m_unresolvedDefinitions.take(descriptor); |
80 | 80 |
81 if (!candidates) | 81 if (!candidates) |
82 return nullptr; | 82 return nullptr; |
83 | 83 |
84 for (const auto& candidate : *candidates) { | 84 for (const auto& candidate : *candidates) { |
85 unobserve(candidate); | 85 unobserve(candidate); |
86 m_upgradeCandidates.remove(candidate); | 86 m_upgradeCandidates.remove(candidate); |
87 } | 87 } |
88 return candidates; | 88 return candidates; |
89 } | 89 } |
90 | 90 |
91 DEFINE_TRACE(V0CustomElementUpgradeCandidateMap) { | 91 DEFINE_TRACE(V0CustomElementUpgradeCandidateMap) { |
92 visitor->trace(m_upgradeCandidates); | 92 visitor->trace(m_upgradeCandidates); |
93 visitor->trace(m_unresolvedDefinitions); | 93 visitor->trace(m_unresolvedDefinitions); |
94 V0CustomElementObserver::trace(visitor); | 94 V0CustomElementObserver::trace(visitor); |
95 } | 95 } |
96 | 96 |
97 } // namespace blink | 97 } // namespace blink |
OLD | NEW |