MCPcopy Create free account
hub / github.com/SeleniumHQ/selenium / ClearCache

Method ClearCache

cpp/iedriver/ElementRepository.cpp:112–135  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

110}
111
112void ElementRepository::ClearCache() {
113 // Logic explanation: We can't just remove the elements from the
114 // managed elements map, within the loop as that would invalidate
115 // the iterator. So we add the keys to a vector, and use the vector
116 // to remove the elements from the map.
117 std::vector<std::string> bad_elements;
118 ElementMap::const_iterator managed_iterator = this->managed_elements_.begin();
119 ElementMap::const_iterator last_managed_element = this->managed_elements_.end();
120 for(; managed_iterator != last_managed_element; ++managed_iterator) {
121 if (!managed_iterator->second->IsAttachedToDom()) {
122 bad_elements.push_back(managed_iterator->first);
123 }
124 }
125
126 LOG(DEBUG) << "Refreshing managed element cache. Found "
127 << bad_elements.size()
128 << " to remove from cache.";
129
130 std::vector<std::string>::const_iterator id_iterator = bad_elements.begin();
131 std::vector<std::string>::const_iterator last_id = bad_elements.end();
132 for (; id_iterator != last_id; ++id_iterator) {
133 this->RemoveManagedElement(*id_iterator);
134 }
135}
136
137void ElementRepository::Clear() {
138 this->managed_elements_.clear();

Callers

nothing calls this directly

Calls 5

RemoveManagedElementMethod · 0.95
endMethod · 0.80
IsAttachedToDomMethod · 0.80
LOGClass · 0.50
sizeMethod · 0.45

Tested by

no test coverage detected