Skip to content

Commit

Permalink
Bug 1187115 - Replace nsBaseHashtable::EnumerateRead() calls in dom/{…
Browse files Browse the repository at this point in the history
…bluetooth,messagechannel}/ with iterators. r=khuey.
  • Loading branch information
nnethercote committed Nov 19, 2015
1 parent 98d9aa9 commit f20c94b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 23 deletions.
12 changes: 3 additions & 9 deletions dom/bluetooth/bluez/BluetoothDBusService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2281,7 +2281,9 @@ class DeleteDBusConnectionTask final : public Task
}

// 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;
Expand All @@ -2299,14 +2301,6 @@ class DeleteDBusConnectionTask final : public Task
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
Expand Down
19 changes: 5 additions & 14 deletions dom/messagechannel/MessagePortService.cpp
Original file line number Diff line number Diff line change
@@ -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/. */
Expand Down Expand Up @@ -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<nsID*>(aPtr);
MOZ_ASSERT(!id->Equals(aID));
return PL_DHASH_NEXT;
}
#endif

void
MessagePortService::CloseAll(const nsID& aUUID, bool aForced)
{
Expand Down Expand Up @@ -319,7 +308,9 @@ MessagePortService::CloseAll(const nsID& aUUID, bool aForced)
}

#ifdef DEBUG
mPorts.EnumerateRead(CloseAllDebugCheck, const_cast<nsID*>(&aUUID));
for (auto iter = mPorts.Iter(); !iter.Done(); iter.Next()) {
MOZ_ASSERT(!aUUID.Equals(iter.Key()));
}
#endif

MaybeShutdown();
Expand Down

0 comments on commit f20c94b

Please sign in to comment.