Remove variable shadowing in blink/modules/indexeddb and webdatabase
In an effort to reduce (any possibly ban) shadowed variables in blink, this
renames a couple of variables in modules/indexeddb so that there is no
variable shadowing.
I'm interested in turning on the shadowing warning because I think it might
prevent potential jumbo build problems.
This patch fixes these shadowing warnings:
third_party/blink/renderer/modules/indexeddb/idb_database.cc:201:12: error: declaration shadows a local variable [-Werror,-Wshadow]
auto it = transactions.find(map_entry.first);
^
third_party/blink/renderer/modules/indexeddb/idb_database.cc:196:10: note: previous declaration is here
auto it = observers_.find(map_entry.first);
^
third_party/blink/renderer/modules/indexeddb/inspector_indexed_db_agent.cc:490:11: error: declaration shadows a local variable [-Werror,-Wshadow]
auto* array = key->getArray(nullptr);
^
third_party/blink/renderer/modules/indexeddb/inspector_indexed_db_agent.cc:474:31: note: previous declaration is here
DEFINE_STATIC_LOCAL(String, array, ("array"));
^
third_party/blink/renderer/modules/webdatabase/database.cc:845:38: error: declaration shadows a local variable [-Werror,-Wshadow]
SQLTransaction::OnErrorCallback* callback =
^
third_party/blink/renderer/modules/webdatabase/database.cc:824:40: note: previous declaration is here
SQLTransaction::OnProcessCallback* callback,
^
3 errors generated.
Bug: 925310
Change-Id: I5912a18ce0bbfe8bfd15a69110aa396ef216b7d8
Reviewed-on: https://chromium-review.googlesource.com/c/1477051
Commit-Queue: Kentaro Hara <haraken@chromium.org>
Auto-Submit: Daniel Bratell <bratell@opera.com>
Reviewed-by: Kentaro Hara <haraken@chromium.org>
Cr-Commit-Position: refs/heads/master@{#633128}
diff --git a/third_party/blink/renderer/modules/indexeddb/idb_database.cc b/third_party/blink/renderer/modules/indexeddb/idb_database.cc
index fb64c58..5bdf892 100644
--- a/third_party/blink/renderer/modules/indexeddb/idb_database.cc
+++ b/third_party/blink/renderer/modules/indexeddb/idb_database.cc
@@ -193,14 +193,15 @@
}
for (const auto& map_entry : observation_index_map) {
- auto it = observers_.find(map_entry.first);
- if (it != observers_.end()) {
- IDBObserver* observer = it->value;
+ auto observer_lookup_result = observers_.find(map_entry.first);
+ if (observer_lookup_result != observers_.end()) {
+ IDBObserver* observer = observer_lookup_result->value;
IDBTransaction* transaction = nullptr;
- auto it = transactions.find(map_entry.first);
- if (it != transactions.end()) {
- const std::pair<int64_t, Vector<int64_t>>& obs_txn = it->second;
+ auto transactions_lookup_result = transactions.find(map_entry.first);
+ if (transactions_lookup_result != transactions.end()) {
+ const std::pair<int64_t, Vector<int64_t>>& obs_txn =
+ transactions_lookup_result->second;
HashSet<String> stores;
for (int64_t store_id : obs_txn.second) {
stores.insert(metadata_.object_stores.at(store_id)->name);
diff --git a/third_party/blink/renderer/modules/indexeddb/inspector_indexed_db_agent.cc b/third_party/blink/renderer/modules/indexeddb/inspector_indexed_db_agent.cc
index a4edbc6..fbbcd09 100644
--- a/third_party/blink/renderer/modules/indexeddb/inspector_indexed_db_agent.cc
+++ b/third_party/blink/renderer/modules/indexeddb/inspector_indexed_db_agent.cc
@@ -469,24 +469,24 @@
return nullptr;
String type = key->getType();
- DEFINE_STATIC_LOCAL(String, number, ("number"));
- DEFINE_STATIC_LOCAL(String, string, ("string"));
- DEFINE_STATIC_LOCAL(String, date, ("date"));
- DEFINE_STATIC_LOCAL(String, array, ("array"));
+ DEFINE_STATIC_LOCAL(String, number_type, ("number"));
+ DEFINE_STATIC_LOCAL(String, string_type, ("string"));
+ DEFINE_STATIC_LOCAL(String, date_type, ("date"));
+ DEFINE_STATIC_LOCAL(String, array_type, ("array"));
- if (type == number) {
+ if (type == number_type) {
if (!key->hasNumber())
return nullptr;
idb_key = IDBKey::CreateNumber(key->getNumber(0));
- } else if (type == string) {
+ } else if (type == string_type) {
if (!key->hasString())
return nullptr;
idb_key = IDBKey::CreateString(key->getString(String()));
- } else if (type == date) {
+ } else if (type == date_type) {
if (!key->hasDate())
return nullptr;
idb_key = IDBKey::CreateDate(key->getDate(0));
- } else if (type == array) {
+ } else if (type == array_type) {
IDBKey::KeyArray key_array;
auto* array = key->getArray(nullptr);
for (size_t i = 0; array && i < array->length(); ++i)
diff --git a/third_party/blink/renderer/modules/webdatabase/database.cc b/third_party/blink/renderer/modules/webdatabase/database.cc
index 3dd797a..4448256 100644
--- a/third_party/blink/renderer/modules/webdatabase/database.cc
+++ b/third_party/blink/renderer/modules/webdatabase/database.cc
@@ -842,18 +842,18 @@
SQLTransactionBackend* transaction_backend =
RunTransaction(transaction, read_only, change_version_data);
if (!transaction_backend) {
- SQLTransaction::OnErrorCallback* callback =
+ SQLTransaction::OnErrorCallback* transaction_error_callback =
transaction->ReleaseErrorCallback();
#if DCHECK_IS_ON()
- DCHECK_EQ(callback, original_error_callback);
+ DCHECK_EQ(transaction_error_callback, original_error_callback);
#endif
- if (callback) {
+ if (transaction_error_callback) {
std::unique_ptr<SQLErrorData> error = SQLErrorData::Create(
SQLError::kUnknownErr, "database has been closed");
GetDatabaseTaskRunner()->PostTask(
- FROM_HERE,
- WTF::Bind(&CallTransactionErrorCallback, WrapPersistent(callback),
- WTF::Passed(std::move(error))));
+ FROM_HERE, WTF::Bind(&CallTransactionErrorCallback,
+ WrapPersistent(transaction_error_callback),
+ WTF::Passed(std::move(error))));
}
}
}