| 110 | } |
| 111 | |
| 112 | void 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 | |
| 137 | void ElementRepository::Clear() { |
| 138 | this->managed_elements_.clear(); |
nothing calls this directly
no test coverage detected