Skip to content

Commit

Permalink
Replace base::hash_map with std::unordered_map
Browse files Browse the repository at this point in the history
base::hash_map is alias of std::unordered_map now.

I applied following command to make this CL.

$ git grep -l 'base::hash_map' | fgrep -v base/ | xargs sed -i -e 's/base::hash_map/std::unordered_set/g' -e 's/\(#include <[a-z_]*>\)/\1\n#include <unordered_map>/' -e 's/BASE_HASH_NAMESPACE/std/'
$ git cl format
$ # Added IntPairHash and replaced BASE_HASH_NAMESPACE with std in some places.

TBR: dcheng@chromium.org
Bug: 576864
Change-Id: I38941d9f9bcb05ec474b8dee5230c4c5dcd2211f
Reviewed-on: https://chromium-review.googlesource.com/c/1390892
Commit-Queue: Takuto Ikuta <tikuta@chromium.org>
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Cr-Commit-Position: refs/heads/master@{#620124}
  • Loading branch information
Takuto Ikuta authored and Commit Bot committed Jan 5, 2019
1 parent 00267b2 commit adf31eb
Show file tree
Hide file tree
Showing 108 changed files with 259 additions and 155 deletions.
3 changes: 2 additions & 1 deletion android_webview/browser/aw_permission_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

#include <memory>
#include <string>
#include <unordered_map>
#include <utility>

#include "android_webview/browser/aw_browser_permission_request_delegate.h"
Expand Down Expand Up @@ -142,7 +143,7 @@ class LastRequestResultCache {
return requesting + "," + embedding;
}

using StatusMap = base::hash_map<std::string, PermissionStatus>;
using StatusMap = std::unordered_map<std::string, PermissionStatus>;
StatusMap pmi_result_cache_;

DISALLOW_COPY_AND_ASSIGN(LastRequestResultCache);
Expand Down
4 changes: 2 additions & 2 deletions chromeos/cryptohome/async_method_caller.cc
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,8 @@ class AsyncMethodCallerImpl : public AsyncMethodCaller,
scoped_refptr<base::SingleThreadTaskRunner> task_runner;
};

typedef base::hash_map<int, CallbackElement> CallbackMap;
typedef base::hash_map<int, DataCallbackElement> DataCallbackMap;
typedef std::unordered_map<int, CallbackElement> CallbackMap;
typedef std::unordered_map<int, DataCallbackElement> DataCallbackMap;

// Handles the response for async calls.
// Below is described how async calls work.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <stdint.h>

#include <memory>
#include <unordered_map>
#include <vector>

#include "base/callback.h"
Expand Down Expand Up @@ -163,7 +164,7 @@ class DISCARDABLE_MEMORY_EXPORT DiscardableSharedMemoryHeap {
std::vector<std::unique_ptr<ScopedMemorySegment>> memory_segments_;

// Mapping from first/last block of span to Span instance.
typedef base::hash_map<size_t, Span*> SpanMap;
typedef std::unordered_map<size_t, Span*> SpanMap;
SpanMap spans_;

// Array of linked-lists with free discardable memory regions. For i < 256,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <stdint.h>

#include <memory>
#include <unordered_map>
#include <vector>

#include "base/callback.h"
Expand Down Expand Up @@ -141,8 +142,8 @@ class DISCARDABLE_MEMORY_EXPORT DiscardableSharedMemoryManager

base::Lock lock_;
using MemorySegmentMap =
base::hash_map<int32_t, scoped_refptr<MemorySegment>>;
using ClientMap = base::hash_map<int, MemorySegmentMap>;
std::unordered_map<int32_t, scoped_refptr<MemorySegment>>;
using ClientMap = std::unordered_map<int, MemorySegmentMap>;
ClientMap clients_;
// Note: The elements in |segments_| are arranged in such a way that they form
// a heap. The LRU memory segment always first.
Expand Down
3 changes: 2 additions & 1 deletion components/dom_distiller/core/distilled_content_store.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

#include <memory>
#include <string>
#include <unordered_map>

#include "base/bind.h"
#include "base/containers/hash_tables.h"
Expand Down Expand Up @@ -81,7 +82,7 @@ class InMemoryContentStore : public DistilledContentStore {
std::unique_ptr<DistilledArticleProto, CacheDeletor>>

ContentMap;
typedef base::hash_map<std::string, std::string> UrlMap;
typedef std::unordered_map<std::string, std::string> UrlMap;

ContentMap cache_;
UrlMap url_to_id_;
Expand Down
3 changes: 2 additions & 1 deletion components/dom_distiller/core/distiller.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <map>
#include <memory>
#include <string>
#include <unordered_map>
#include <vector>

#include "base/callback.h"
Expand Down Expand Up @@ -172,7 +173,7 @@ class DistillerImpl : public Distiller {
// Maps page numbers of pages under distillation to the indices in |pages_|.
// If a page is |started_pages_| that means it is still waiting for an action
// (distillation or image fetch) to finish.
base::hash_map<int, size_t> started_pages_index_;
std::unordered_map<int, size_t> started_pages_index_;

// The list of pages that are still waiting for distillation to start.
// This is a map, to make distiller prefer distilling lower page numbers
Expand Down
5 changes: 3 additions & 2 deletions components/dom_distiller/core/dom_distiller_model.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <stdint.h>

#include <string>
#include <unordered_map>
#include <vector>

#include "base/containers/hash_tables.h"
Expand Down Expand Up @@ -62,8 +63,8 @@ class DomDistillerModel {

private:
typedef int32_t KeyType;
typedef base::hash_map<KeyType, ArticleEntry> EntryMap;
typedef base::hash_map<std::string, KeyType> StringToKeyMap;
typedef std::unordered_map<KeyType, ArticleEntry> EntryMap;
typedef std::unordered_map<std::string, KeyType> StringToKeyMap;

void AddEntry(const ArticleEntry& entry);
void RemoveEntry(const ArticleEntry& entry);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#include <stddef.h>
#include <sstream>
#include <unordered_map>
#include <utility>

#include "base/command_line.h"
Expand Down Expand Up @@ -48,8 +49,7 @@ namespace dom_distiller {

namespace {

typedef base::hash_map<std::string, std::string> FileToUrlMap;

typedef std::unordered_map<std::string, std::string> FileToUrlMap;
}

// Factory for creating a Distiller that creates different DomDistillerOptions
Expand Down
3 changes: 2 additions & 1 deletion components/drive/resource_metadata_storage.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#include <map>
#include <set>
#include <unordered_map>
#include <utility>

#include "base/bind.h"
Expand Down Expand Up @@ -1124,7 +1125,7 @@ bool ResourceMetadataStorage::CheckValidity() {
}

// First scan. Remember relationships between IDs.
typedef base::hash_map<std::string, std::string> KeyToIdMapping;
typedef std::unordered_map<std::string, std::string> KeyToIdMapping;
KeyToIdMapping local_id_to_resource_id_map;
KeyToIdMapping child_key_to_local_id_map;
std::set<std::string> resource_entries;
Expand Down
3 changes: 2 additions & 1 deletion components/omnibox/browser/in_memory_url_index_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <stddef.h>

#include <map>
#include <unordered_map>
#include <vector>

#include "base/containers/flat_set.h"
Expand Down Expand Up @@ -167,7 +168,7 @@ struct HistoryInfoMapValue {
};

// A map from history_id to the history's URL and title.
typedef base::hash_map<HistoryID, HistoryInfoMapValue> HistoryInfoMap;
typedef std::unordered_map<HistoryID, HistoryInfoMapValue> HistoryInfoMap;

// A map from history_id to URL and page title word start metrics.
struct RowWordStarts {
Expand Down
3 changes: 2 additions & 1 deletion components/prefs/pref_notifier_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <list>
#include <memory>
#include <string>
#include <unordered_map>

#include "base/callback.h"
#include "base/compiler_specific.h"
Expand Down Expand Up @@ -58,7 +59,7 @@ class COMPONENTS_PREFS_EXPORT PrefNotifierImpl : public PrefNotifier {
// order they are added. These should only be accessed externally for unit
// testing.
typedef base::ObserverList<PrefObserver>::Unchecked PrefObserverList;
typedef base::hash_map<std::string, std::unique_ptr<PrefObserverList>>
typedef std::unordered_map<std::string, std::unique_ptr<PrefObserverList>>
PrefObserverMap;

typedef std::list<base::OnceCallback<void(bool)>> PrefInitObserverList;
Expand Down
3 changes: 2 additions & 1 deletion components/prefs/pref_registry.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

#include <memory>
#include <set>
#include <unordered_map>

#include "base/containers/hash_tables.h"
#include "base/macros.h"
Expand Down Expand Up @@ -54,7 +55,7 @@ class COMPONENTS_PREFS_EXPORT PrefRegistry
};

typedef PrefValueMap::const_iterator const_iterator;
typedef base::hash_map<std::string, uint32_t> PrefRegistrationFlagsMap;
typedef std::unordered_map<std::string, uint32_t> PrefRegistrationFlagsMap;

PrefRegistry();

Expand Down
3 changes: 2 additions & 1 deletion components/prefs/pref_service.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include <memory>
#include <set>
#include <string>
#include <unordered_map>
#include <vector>

#include "base/callback.h"
Expand Down Expand Up @@ -390,7 +391,7 @@ class COMPONENTS_PREFS_EXPORT PrefService {
// string comparisons. Order is unimportant, and deletions are rare.
// Confirmed on Android where this speeded Chrome startup by roughly 50ms
// vs. std::map, and by roughly 180ms vs. std::set of Preference pointers.
typedef base::hash_map<std::string, Preference> PreferenceMap;
typedef std::unordered_map<std::string, Preference> PreferenceMap;

// Give access to ReportUserPrefChanged() and GetMutableUserPref().
friend class subtle::ScopedUserPrefUpdateBase;
Expand Down
15 changes: 9 additions & 6 deletions components/safe_browsing/browser/threat_details.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

#include <memory>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

Expand Down Expand Up @@ -45,23 +46,25 @@ class ThreatDetailsCacheCollector;
class ThreatDetailsRedirectsCollector;
class ThreatDetailsFactory;

using ResourceMap =
base::hash_map<std::string,
std::unique_ptr<ClientSafeBrowsingReportRequest::Resource>>;
using ResourceMap = std::unordered_map<
std::string,
std::unique_ptr<ClientSafeBrowsingReportRequest::Resource>>;

// Maps a key of an HTML element to its corresponding HTMLElement proto message.
// HTML Element keys have the form "<frame_id>-<node_id>", where |frame_id| is
// the FrameTreeNode ID of the frame containing the element, and
// |node_id| is a sequential ID for the element generated by the renderer.
using ElementMap = base::hash_map<std::string, std::unique_ptr<HTMLElement>>;
using ElementMap =
std::unordered_map<std::string, std::unique_ptr<HTMLElement>>;

// Maps the key of an iframe element to the FrameTreeNode ID of the frame that
// rendered the contents of the iframe.
using KeyToFrameTreeIdMap = base::hash_map<std::string, int>;
using KeyToFrameTreeIdMap = std::unordered_map<std::string, int>;

// Maps a FrameTreeNode ID of a frame to a set of child IDs. The child IDs are
// the Element IDs of the top-level HTML Elements in this frame.
using FrameTreeIdToChildIdsMap = base::hash_map<int, std::unordered_set<int>>;
using FrameTreeIdToChildIdsMap =
std::unordered_map<int, std::unordered_set<int>>;

// Callback used to notify a caller that ThreatDetails has finished creating and
// sending a report.
Expand Down
3 changes: 2 additions & 1 deletion components/safe_browsing/browser/threat_details_cache.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
// An instance of this class is generated by ThreatDetails.

#include <string>
#include <unordered_map>
#include <vector>

#include "base/callback.h"
Expand All @@ -24,7 +25,7 @@ class SharedURLLoaderFactory;
namespace safe_browsing {

// Maps a URL to its Resource.
typedef base::hash_map<
typedef std::unordered_map<
std::string,
std::unique_ptr<ClientSafeBrowsingReportRequest::Resource>>
ResourceMap;
Expand Down
3 changes: 2 additions & 1 deletion components/safe_browsing/db/v4_database_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include <unordered_map>
#include <utility>

#include "base/bind.h"
Expand Down Expand Up @@ -210,7 +211,7 @@ class V4DatabaseTest : public PlatformTest {
DatabaseUpdatedCallback callback_db_updated_;
NewDatabaseReadyCallback callback_db_ready_;
StoreStateMap expected_store_state_map_;
base::hash_map<ListIdentifier, V4Store*> old_stores_map_;
std::unordered_map<ListIdentifier, V4Store*> old_stores_map_;
const ListIdentifier linux_malware_id_, win_malware_id_;
};

Expand Down
2 changes: 1 addition & 1 deletion components/services/font/public/cpp/font_loader.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ class FontLoader : public SkFontConfigInterface,
base::Lock lock_;

// Maps font identity ID to the memory-mapped file with font data.
base::hash_map<uint32_t, internal::MappedFontFile*> mapped_font_files_;
std::unordered_map<uint32_t, internal::MappedFontFile*> mapped_font_files_;

DISALLOW_COPY_AND_ASSIGN(FontLoader);
};
Expand Down
3 changes: 2 additions & 1 deletion components/sync_preferences/pref_model_associator.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <memory>
#include <set>
#include <string>
#include <unordered_map>
#include <vector>

#include "base/callback.h"
Expand Down Expand Up @@ -197,7 +198,7 @@ class PrefModelAssociator : public syncer::SyncableService {
// from sync.
using SyncedPrefObserverList =
base::ObserverList<SyncedPrefObserver>::Unchecked;
base::hash_map<std::string, std::unique_ptr<SyncedPrefObserverList>>
std::unordered_map<std::string, std::unique_ptr<SyncedPrefObserverList>>
synced_pref_observers_;

const PrefModelAssociatorClient* client_; // Weak.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <memory>
#include <set>
#include <string>
#include <unordered_map>
#include <vector>

#include "base/compiler_specific.h"
Expand Down Expand Up @@ -174,7 +175,7 @@ class VariationsFieldTrialCreator {

// Caches the UI strings which need to be overridden in the resource bundle.
// These strings are cached before the resource bundle is initialized.
base::hash_map<int, base::string16> overridden_strings_map_;
std::unordered_map<int, base::string16> overridden_strings_map_;

SEQUENCE_CHECKER(sequence_checker_);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ BrowserAccessibility* BrowserAccessibility::Create() {
return new BrowserAccessibilityAndroid();
}

using UniqueIdMap = base::hash_map<int32_t, BrowserAccessibilityAndroid*>;
using UniqueIdMap = std::unordered_map<int32_t, BrowserAccessibilityAndroid*>;
// Map from each AXPlatformNode's unique id to its instance.
base::LazyInstance<UniqueIdMap>::Leaky g_unique_id_map =
LAZY_INSTANCE_INITIALIZER;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

#include <memory>
#include <string>
#include <unordered_map>
#include <vector>

#include "base/callback_forward.h"
Expand Down Expand Up @@ -416,7 +417,7 @@ class CONTENT_EXPORT BrowserAccessibilityManager : public ui::AXTreeObserver {
std::unique_ptr<ui::AXSerializableTree> tree_;

// A mapping from a node id to its wrapper of type BrowserAccessibility.
base::hash_map<int32_t, BrowserAccessibility*> id_wrapper_map_;
std::unordered_map<int32_t, BrowserAccessibility*> id_wrapper_map_;

// True if the user has initiated a navigation to another page.
bool user_is_navigating_away_;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ enum {
UMA_ACCESSIBILITYSERVICEINFO_MAX)

using SearchKeyToPredicateMap =
base::hash_map<base::string16, AccessibilityMatchPredicate>;
std::unordered_map<base::string16, AccessibilityMatchPredicate>;
base::LazyInstance<SearchKeyToPredicateMap>::Leaky
g_search_key_to_predicate_map = LAZY_INSTANCE_INITIALIZER;
base::LazyInstance<base::string16>::Leaky g_all_search_keys =
Expand Down
2 changes: 1 addition & 1 deletion content/browser/appcache/appcache_backend_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class CONTENT_EXPORT AppCacheBackendImpl {
return (it != hosts_.end()) ? (it->second.get()) : nullptr;
}

using HostMap = base::hash_map<int, std::unique_ptr<AppCacheHost>>;
using HostMap = std::unordered_map<int, std::unique_ptr<AppCacheHost>>;
const HostMap& hosts() { return hosts_; }

// The AppCacheHost is precreated by the AppCacheNavigationHandleCore class
Expand Down
Loading

0 comments on commit adf31eb

Please sign in to comment.