Skip to content

Commit

Permalink
Bug 1621395 - Convert mQueue to nsTArray<UniquePtr<nsOpenConn>> r=val…
Browse files Browse the repository at this point in the history
…entin

***
Bug 1621395 - Convert mQueue to nsTArray<UniquePtr<nsOpenConn>>

Differential Revision: https://phabricator.services.mozilla.com/D66563

--HG--
extra : moz-landing-system : lando
  • Loading branch information
EngAlaaEmad committed Mar 12, 2020
1 parent dd4c74e commit e1148a5
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions netwerk/protocol/websocket/WebSocketChannel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -324,9 +324,8 @@ class nsWSAdmissionManager {
bool found = (sManager->IndexOf(ws->mAddress) >= 0);

// Always add ourselves to queue, even if we'll connect immediately
nsOpenConn* newdata = new nsOpenConn(ws->mAddress, ws);
LOG(("Websocket: adding conn %p to the queue", newdata));
sManager->mQueue.AppendElement(newdata);
UniquePtr<nsOpenConn> newdata(new nsOpenConn(ws->mAddress, ws));
sManager->mQueue.AppendElement(std::move(newdata));

if (found) {
LOG(
Expand Down Expand Up @@ -448,10 +447,7 @@ class nsWSAdmissionManager {
MOZ_COUNT_CTOR(nsWSAdmissionManager);
}

~nsWSAdmissionManager() {
MOZ_COUNT_DTOR(nsWSAdmissionManager);
for (uint32_t i = 0; i < mQueue.Length(); i++) delete mQueue[i];
}
~nsWSAdmissionManager() { MOZ_COUNT_DTOR(nsWSAdmissionManager); }

class nsOpenConn {
public:
Expand Down Expand Up @@ -485,10 +481,7 @@ class nsWSAdmissionManager {
int32_t index = IndexOf(aChannel);
MOZ_ASSERT(index >= 0, "connection to remove not in queue");
if (index >= 0) {
nsOpenConn* olddata = mQueue[index];
mQueue.RemoveElementAt(index);
LOG(("Websocket: removing conn %p from the queue", olddata));
delete olddata;
}
}

Expand All @@ -515,7 +508,7 @@ class nsWSAdmissionManager {
//
// We could hash hostnames instead of using a single big vector here, but the
// dataset is expected to be small.
nsTArray<nsOpenConn*> mQueue;
nsTArray<UniquePtr<nsOpenConn>> mQueue;

FailDelayManager mFailures;

Expand Down

0 comments on commit e1148a5

Please sign in to comment.