From ac7ea6f3f61d2aae8307a01b24aaa0e3277b2bb2 Mon Sep 17 00:00:00 2001 From: Ben Kelly Date: Mon, 4 Jun 2018 09:26:51 -0700 Subject: [PATCH] Bug 1441932 P4 Treat same-value assignments to the LoadInfo reserved and initial ClientInfo values as no-op changes. r=mayhemer --- dom/clients/manager/ClientInfo.cpp | 6 ++++++ dom/clients/manager/ClientInfo.h | 3 +++ netwerk/base/LoadInfo.cpp | 10 ++++++++++ 3 files changed, 19 insertions(+) diff --git a/dom/clients/manager/ClientInfo.cpp b/dom/clients/manager/ClientInfo.cpp index 3dfd77cf06cc..436fe3125503 100644 --- a/dom/clients/manager/ClientInfo.cpp +++ b/dom/clients/manager/ClientInfo.cpp @@ -60,6 +60,12 @@ ClientInfo::~ClientInfo() { } +bool +ClientInfo::operator==(const ClientInfo& aRight) const +{ + return *mData == *aRight.mData; +} + const nsID& ClientInfo::Id() const { diff --git a/dom/clients/manager/ClientInfo.h b/dom/clients/manager/ClientInfo.h index 1a983600df08..7642d92e08d5 100644 --- a/dom/clients/manager/ClientInfo.h +++ b/dom/clients/manager/ClientInfo.h @@ -47,6 +47,9 @@ public: ~ClientInfo(); + bool + operator==(const ClientInfo& aRight) const; + // Get the unique identifier chosen at the time of the global's creation. const nsID& Id() const; diff --git a/netwerk/base/LoadInfo.cpp b/netwerk/base/LoadInfo.cpp index 58b6c1df4b9a..6a6814bd9884 100644 --- a/netwerk/base/LoadInfo.cpp +++ b/netwerk/base/LoadInfo.cpp @@ -1317,6 +1317,11 @@ void LoadInfo::SetReservedClientInfo(const ClientInfo& aClientInfo) { MOZ_DIAGNOSTIC_ASSERT(mInitialClientInfo.isNothing()); + // Treat assignments of the same value as a no-op. The emplace below + // will normally assert when overwriting an existing value. + if (mReservedClientInfo.isSome() && mReservedClientInfo.ref() == aClientInfo) { + return; + } mReservedClientInfo.emplace(aClientInfo); } @@ -1331,6 +1336,11 @@ LoadInfo::SetInitialClientInfo(const ClientInfo& aClientInfo) { MOZ_DIAGNOSTIC_ASSERT(!mReservedClientSource); MOZ_DIAGNOSTIC_ASSERT(mReservedClientInfo.isNothing()); + // Treat assignments of the same value as a no-op. The emplace below + // will normally assert when overwriting an existing value. + if (mInitialClientInfo.isSome() && mInitialClientInfo.ref() == aClientInfo) { + return; + } mInitialClientInfo.emplace(aClientInfo); }