Commit 455dde41 authored by Miyoung Shin's avatar Miyoung Shin Committed by Commit Bot

Replace use of std containers with WTF's equivalents in indexeddb/*

This CL replaces the use of std::unordered_map of std containers
with WTF::HashMap in indexeddb/*.

Bug: 952716
Change-Id: Ic56b442d83f41a141a06002ef050ed35177e798e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1692385Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Commit-Queue: Miyoung Shin <myid.shin@igalia.com>
Cr-Commit-Position: refs/heads/master@{#675597}
parent 426cfcee
......@@ -193,14 +193,14 @@ void IDBDatabase::OnChanges(
}
for (const auto& map_entry : observation_index_map) {
auto observer_lookup_result = observers_.find(map_entry.first);
auto observer_lookup_result = observers_.find(map_entry.key);
if (observer_lookup_result != observers_.end()) {
IDBObserver* observer = observer_lookup_result->value;
auto transactions_lookup_result = transactions.find(map_entry.first);
auto transactions_lookup_result = transactions.find(map_entry.key);
if (transactions_lookup_result != transactions.end()) {
const std::pair<int64_t, Vector<int64_t>>& obs_txn =
transactions_lookup_result->second;
transactions_lookup_result->value;
HashSet<String> stores;
for (int64_t store_id : obs_txn.second) {
stores.insert(metadata_.object_stores.at(store_id)->name);
......@@ -209,7 +209,7 @@ void IDBDatabase::OnChanges(
observer->Callback()->InvokeAndReportException(
observer, MakeGarbageCollected<IDBObserverChanges>(
this, nullptr, observations, map_entry.second));
this, nullptr, observations, map_entry.value));
}
}
}
......
......@@ -4,7 +4,6 @@
#include "third_party/blink/renderer/modules/indexeddb/indexed_db_database_callbacks_impl.h"
#include <unordered_map>
#include <utility>
#include "third_party/blink/public/platform/web_blob_info.h"
......@@ -58,21 +57,20 @@ void IndexedDBDatabaseCallbacksImpl::Changes(
std::move(value)));
}
std::unordered_map<int32_t, Vector<int32_t>> observation_index_map;
HashMap<int32_t, Vector<int32_t>> observation_index_map;
for (const auto& observation_pair : changes->observation_index_map) {
observation_index_map[observation_pair.key] =
Vector<int32_t>(observation_pair.value);
observation_index_map.insert(observation_pair.key,
Vector<int32_t>(observation_pair.value));
}
std::unordered_map<int32_t, std::pair<int64_t, Vector<int64_t>>>
observer_transactions;
HashMap<int32_t, std::pair<int64_t, Vector<int64_t>>> observer_transactions;
for (const auto& transaction_pair : changes->transaction_map) {
// Moving an int64_t is rather silly. Sadly, std::make_pair's overloads
// accept either two rvalue arguments, or none.
observer_transactions[transaction_pair.key] =
std::make_pair<int64_t, Vector<int64_t>>(
std::move(transaction_pair.value->id),
std::move(transaction_pair.value->scope));
observer_transactions.insert(transaction_pair.key,
std::make_pair<int64_t, Vector<int64_t>>(
std::move(transaction_pair.value->id),
std::move(transaction_pair.value->scope)));
}
callbacks_->OnChanges(observation_index_map, std::move(observations),
......
......@@ -26,12 +26,12 @@
#ifndef THIRD_PARTY_BLINK_RENDERER_MODULES_INDEXEDDB_WEB_IDB_DATABASE_CALLBACKS_H_
#define THIRD_PARTY_BLINK_RENDERER_MODULES_INDEXEDDB_WEB_IDB_DATABASE_CALLBACKS_H_
#include <unordered_map>
#include <utility>
#include "third_party/blink/renderer/modules/indexeddb/idb_database_error.h"
#include "third_party/blink/renderer/modules/modules_export.h"
#include "third_party/blink/renderer/platform/heap/persistent.h"
#include "third_party/blink/renderer/platform/wtf/hash_map.h"
namespace blink {
......@@ -39,11 +39,10 @@ class IDBObservation;
class WebIDBDatabaseCallbacks {
public:
using ObservationIndexMap = std::unordered_map<int32_t, Vector<int32_t>>;
using ObservationIndexMap = HashMap<int32_t, Vector<int32_t>>;
// Maps observer to transaction, which needs an id and a scope.
using TransactionMap =
std::unordered_map<int32_t, std::pair<int64_t, Vector<int64_t>>>;
using TransactionMap = HashMap<int32_t, std::pair<int64_t, Vector<int64_t>>>;
virtual ~WebIDBDatabaseCallbacks() = default;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment