Bug 840612 - Part 3: refactor the Reset method. r=mayhemer

This commit is contained in:
Hubert Figuière 2013-04-09 20:46:25 -04:00
parent 7fffefb66d
commit 1f5855d289
2 changed files with 20 additions and 17 deletions

View File

@ -685,31 +685,31 @@ nsSocketTransportService::Run()
return NS_OK;
}
void
nsSocketTransportService::DetachSocketWithGuard(bool aGuardLocals,
SocketContext *socketList,
int32_t index)
{
bool isGuarded = false;
if (aGuardLocals) {
socketList[index].mHandler->IsLocal(&isGuarded);
if (!isGuarded)
socketList[index].mHandler->KeepWhenOffline(&isGuarded);
}
if (!isGuarded)
DetachSocket(socketList, &socketList[index]);
}
void
nsSocketTransportService::Reset(bool aGuardLocals)
{
// detach any sockets
int32_t i;
bool isGuarded;
for (i = mActiveCount - 1; i >= 0; --i) {
isGuarded = false;
if (aGuardLocals) {
mActiveList[i].mHandler->IsLocal(&isGuarded);
if (!isGuarded)
mActiveList[i].mHandler->KeepWhenOffline(&isGuarded);
}
if (!isGuarded)
DetachSocket(mActiveList, &mActiveList[i]);
DetachSocketWithGuard(aGuardLocals, mActiveList, i);
}
for (i = mIdleCount - 1; i >= 0; --i) {
isGuarded = false;
if (aGuardLocals) {
mIdleList[i].mHandler->IsLocal(&isGuarded);
if (!isGuarded)
mIdleList[i].mHandler->KeepWhenOffline(&isGuarded);
}
if (!isGuarded)
DetachSocket(mIdleList, &mIdleList[i]);
DetachSocketWithGuard(aGuardLocals, mIdleList, i);
}
}

View File

@ -192,6 +192,9 @@ private:
SocketContext *context, bool aActive);
void ClosePrivateConnections();
void DetachSocketWithGuard(bool aGuardLocals,
SocketContext *socketList,
int32_t index);
};
extern nsSocketTransportService *gSocketTransportService;