From d13713336781a68ee8918b50ad3fe0ae10eed882 Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Wed, 18 Nov 2015 19:38:55 -0800 Subject: [PATCH] Bug 1187115 - Replace nsBaseHashtable::EnumerateRead() calls in dom/{bluetooth,messagechannel}/ with iterators. r=khuey. --HG-- extra : rebase_source : 1c02cc79902eff27686904e8fa139175756446de --- dom/bluetooth/bluez/BluetoothDBusService.cpp | 12 +++--------- dom/messagechannel/MessagePortService.cpp | 19 +++++-------------- 2 files changed, 8 insertions(+), 23 deletions(-) diff --git a/dom/bluetooth/bluez/BluetoothDBusService.cpp b/dom/bluetooth/bluez/BluetoothDBusService.cpp index 6182ef2dd75a..5a7f672c6d9c 100644 --- a/dom/bluetooth/bluez/BluetoothDBusService.cpp +++ b/dom/bluetooth/bluez/BluetoothDBusService.cpp @@ -2281,7 +2281,9 @@ public: } // unref stored DBusMessages before clearing the hashtable - sPairingReqTable->EnumerateRead(UnrefDBusMessage, nullptr); + for (auto iter = sPairingReqTable->Iter(); !iter.Done(); iter.Next()) { + dbus_message_unref(iter.UserData()); + } sPairingReqTable->Clear(); sIsPairing = 0; @@ -2299,14 +2301,6 @@ public: BT_WARNING("Failed to dispatch to BT thread!"); } } - -private: - static PLDHashOperator - UnrefDBusMessage(const BluetoothAddress& key, DBusMessage* value, void* arg) - { - dbus_message_unref(value); - return PL_DHASH_NEXT; - } }; class StopBluetoothRunnable final : public nsRunnable diff --git a/dom/messagechannel/MessagePortService.cpp b/dom/messagechannel/MessagePortService.cpp index 6f95ec340478..311591819afe 100644 --- a/dom/messagechannel/MessagePortService.cpp +++ b/dom/messagechannel/MessagePortService.cpp @@ -1,4 +1,5 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ @@ -263,18 +264,6 @@ MessagePortService::ClosePort(MessagePortParent* aParent) return true; } -#ifdef DEBUG -PLDHashOperator -MessagePortService::CloseAllDebugCheck(const nsID& aID, - MessagePortServiceData* aData, - void* aPtr) -{ - nsID* id = static_cast(aPtr); - MOZ_ASSERT(!id->Equals(aID)); - return PL_DHASH_NEXT; -} -#endif - void MessagePortService::CloseAll(const nsID& aUUID, bool aForced) { @@ -319,7 +308,9 @@ MessagePortService::CloseAll(const nsID& aUUID, bool aForced) } #ifdef DEBUG - mPorts.EnumerateRead(CloseAllDebugCheck, const_cast(&aUUID)); + for (auto iter = mPorts.Iter(); !iter.Done(); iter.Next()) { + MOZ_ASSERT(!aUUID.Equals(iter.Key())); + } #endif MaybeShutdown();