Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6083)

Unified Diff: chrome/browser/sync_file_system/drive_backend/metadata_database_unittest.cc

Issue 2605433002: Remove base::ScopedPtrHashMap from chrome/browser/sync_file_system/drive_backend/ (Closed)
Patch Set: no crash Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/sync_file_system/drive_backend/metadata_database_unittest.cc
diff --git a/chrome/browser/sync_file_system/drive_backend/metadata_database_unittest.cc b/chrome/browser/sync_file_system/drive_backend/metadata_database_unittest.cc
index 747d18d0773d725ebf7a76fcb73e09b7c09b69fc..e456d4ce74cd8e2903ddc6c2893c2f3d1e6cebad 100644
--- a/chrome/browser/sync_file_system/drive_backend/metadata_database_unittest.cc
+++ b/chrome/browser/sync_file_system/drive_backend/metadata_database_unittest.cc
@@ -6,6 +6,7 @@
#include <stdint.h>
+#include <unordered_map>
#include <utility>
#include "base/bind.h"
@@ -105,16 +106,24 @@ void ExpectEquivalent(const std::map<Key, Value>& left,
template <typename Key, typename Value>
void ExpectEquivalent(const base::hash_map<Key, Value>& left,
const base::hash_map<Key, Value>& right) {
+ // Convert from a hash container to an ordered container for comparison.
ExpectEquivalentMaps(std::map<Key, Value>(left.begin(), left.end()),
std::map<Key, Value>(right.begin(), right.end()));
}
template <typename Key, typename Value>
void ExpectEquivalent(
- const base::ScopedPtrHashMap<Key, std::unique_ptr<Value>>& left,
- const base::ScopedPtrHashMap<Key, std::unique_ptr<Value>>& right) {
- ExpectEquivalentMaps(std::map<Key, Value*>(left.begin(), left.end()),
- std::map<Key, Value*>(right.begin(), right.end()));
+ const std::unordered_map<Key, std::unique_ptr<Value>>& left,
+ const std::unordered_map<Key, std::unique_ptr<Value>>& right) {
+ // Convert from a hash container to an ordered container for comparison.
+ std::map<Key, Value*> left_ordered;
+ std::map<Key, Value*> right_ordered;
+ for (const auto& item : left)
+ left_ordered[item.first] = item.second.get();
+ for (const auto& item : right)
+ right_ordered[item.first] = item.second.get();
+
+ ExpectEquivalentMaps(left_ordered, right_ordered);
}
template <typename Container>
@@ -129,6 +138,7 @@ void ExpectEquivalent(const std::set<Value, Comparator>& left,
template <typename Value>
void ExpectEquivalent(const base::hash_set<Value>& left,
const base::hash_set<Value>& right) {
+ // Convert from a hash container to an ordered container for comparison.
return ExpectEquivalentSets(std::set<Value>(left.begin(), left.end()),
std::set<Value>(right.begin(), right.end()));
}

Powered by Google App Engine
This is Rietveld 408576698