Skip to content

Commit 1d05ce0

Browse files
author
Ed Morley
committed
Backed out changeset a7f522902e40 (bug 939318)
1 parent fd5d293 commit 1d05ce0

File tree

4 files changed

+7
-79
lines changed

4 files changed

+7
-79
lines changed

netwerk/protocol/websocket/BaseWebSocketChannel.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ BaseWebSocketChannel::BaseWebSocketChannel()
2424
, mWasOpened(0)
2525
, mClientSetPingInterval(0)
2626
, mClientSetPingTimeout(0)
27-
, mPingForced(0)
2827
, mPingInterval(0)
2928
, mPingResponseTimeout(10000)
3029
{

netwerk/protocol/websocket/BaseWebSocketChannel.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ class BaseWebSocketChannel : public nsIWebSocketChannel,
7272
uint32_t mWasOpened : 1;
7373
uint32_t mClientSetPingInterval : 1;
7474
uint32_t mClientSetPingTimeout : 1;
75-
uint32_t mPingForced : 1;
7675

7776
uint32_t mPingInterval; /* milliseconds */
7877
uint32_t mPingResponseTimeout; /* milliseconds */

netwerk/protocol/websocket/WebSocketChannel.cpp

Lines changed: 6 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@
3535
#include "nsIRandomGenerator.h"
3636
#include "nsISocketTransport.h"
3737
#include "nsThreadUtils.h"
38-
#include "nsINetworkLinkService.h"
39-
#include "nsIObserverService.h"
4038

4139
#include "nsAutoPtr.h"
4240
#include "nsNetCID.h"
@@ -87,8 +85,7 @@ NS_IMPL_ISUPPORTS(WebSocketChannel,
8785
nsIProtocolProxyCallback,
8886
nsIInterfaceRequestor,
8987
nsIChannelEventSink,
90-
nsIThreadRetargetableRequest,
91-
nsIObserver)
88+
nsIThreadRetargetableRequest)
9289

9390
// We implement RFC 6455, which uses Sec-WebSocket-Version: 13 on the wire.
9491
#define SEC_WEBSOCKET_VERSION "13"
@@ -1049,16 +1046,6 @@ WebSocketChannel::WebSocketChannel() :
10491046
LOG(("Failed to initiate dashboard service."));
10501047

10511048
mSerial = sSerialSeed++;
1052-
1053-
// Register for prefs change notifications
1054-
nsCOMPtr<nsIObserverService> observerService =
1055-
mozilla::services::GetObserverService();
1056-
if (observerService) {
1057-
observerService->AddObserver(this, NS_NETWORK_LINK_TOPIC, false);
1058-
} else {
1059-
NS_WARNING("failed to get observer service");
1060-
}
1061-
10621049
}
10631050

10641051
WebSocketChannel::~WebSocketChannel()
@@ -1117,55 +1104,6 @@ WebSocketChannel::~WebSocketChannel()
11171104
}
11181105
}
11191106

1120-
NS_IMETHODIMP
1121-
WebSocketChannel::Observe(nsISupports *subject,
1122-
const char *topic,
1123-
const char16_t *data)
1124-
{
1125-
LOG(("WebSocketChannel::Observe [topic=\"%s\"]\n", topic));
1126-
1127-
if (strcmp(topic, NS_NETWORK_LINK_TOPIC) == 0) {
1128-
nsCString converted = NS_ConvertUTF16toUTF8(data);
1129-
const char *state = converted.get();
1130-
1131-
if (strcmp(state, NS_NETWORK_LINK_DATA_CHANGED) == 0) {
1132-
LOG(("WebSocket: received network CHANGED event"));
1133-
if (mPingOutstanding) {
1134-
// If there's an outstanding ping that's expected to get a pong back
1135-
// we let that do its thing.
1136-
LOG(("WebSocket: pong already pending"));
1137-
} else if (!mSocketThread) {
1138-
// there has not been an asyncopen yet on the object and then we need
1139-
// no ping.
1140-
LOG(("WebSocket: early object, no ping needed"));
1141-
} else {
1142-
LOG(("nsWebSocketChannel:: Generating Ping as network changed\n"));
1143-
1144-
if (mPingForced) {
1145-
// avoid more than one
1146-
return NS_OK;
1147-
}
1148-
if (!mPingTimer) {
1149-
// The ping timer is only conditionally running already. If it
1150-
// wasn't already created do it here.
1151-
nsresult rv;
1152-
mPingTimer = do_CreateInstance("@mozilla.org/timer;1", &rv);
1153-
if (NS_FAILED(rv)) {
1154-
NS_WARNING("unable to create ping timer. Carrying on.");
1155-
} else {
1156-
mPingTimer->SetTarget(mSocketThread);
1157-
}
1158-
}
1159-
// Trigger the ping timeout asap to fire off a new ping. Wait just
1160-
// a little bit to better avoid multi-triggers.
1161-
mPingForced = 1;
1162-
mPingTimer->InitWithCallback(this, 200, nsITimer::TYPE_ONE_SHOT);
1163-
}
1164-
}
1165-
}
1166-
return NS_OK;
1167-
}
1168-
11691107
void
11701108
WebSocketChannel::Shutdown()
11711109
{
@@ -2685,16 +2623,11 @@ WebSocketChannel::Notify(nsITimer *timer)
26852623
}
26862624

26872625
if (!mPingOutstanding) {
2688-
// Allow for the case where a PING was force-sent even though ping
2689-
// interval isn't enabled. Only issue a new PING if it truly is enabled.
2690-
if (mPingInterval || mPingForced) {
2691-
LOG(("nsWebSocketChannel:: Generating Ping\n"));
2692-
mPingOutstanding = 1;
2693-
mPingForced = 0;
2694-
GeneratePing();
2695-
mPingTimer->InitWithCallback(this, mPingResponseTimeout,
2696-
nsITimer::TYPE_ONE_SHOT);
2697-
}
2626+
LOG(("nsWebSocketChannel:: Generating Ping\n"));
2627+
mPingOutstanding = 1;
2628+
GeneratePing();
2629+
mPingTimer->InitWithCallback(this, mPingResponseTimeout,
2630+
nsITimer::TYPE_ONE_SHOT);
26982631
} else {
26992632
LOG(("nsWebSocketChannel:: Timed out Ping\n"));
27002633
mPingTimer = nullptr;

netwerk/protocol/websocket/WebSocketChannel.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
#include "nsIAsyncOutputStream.h"
1515
#include "nsITimer.h"
1616
#include "nsIDNSListener.h"
17-
#include "nsIObserver.h"
1817
#include "nsIProtocolProxyCallback.h"
1918
#include "nsIChannelEventSink.h"
2019
#include "nsIHttpChannelInternal.h"
@@ -63,7 +62,6 @@ class WebSocketChannel : public BaseWebSocketChannel,
6362
public nsIOutputStreamCallback,
6463
public nsITimerCallback,
6564
public nsIDNSListener,
66-
public nsIObserver,
6765
public nsIProtocolProxyCallback,
6866
public nsIInterfaceRequestor,
6967
public nsIChannelEventSink
@@ -80,7 +78,6 @@ class WebSocketChannel : public BaseWebSocketChannel,
8078
NS_DECL_NSIPROTOCOLPROXYCALLBACK
8179
NS_DECL_NSIINTERFACEREQUESTOR
8280
NS_DECL_NSICHANNELEVENTSINK
83-
NS_DECL_NSIOBSERVER
8481

8582
// nsIWebSocketChannel methods BaseWebSocketChannel didn't implement for us
8683
//
@@ -163,8 +160,8 @@ class WebSocketChannel : public BaseWebSocketChannel,
163160

164161
inline void ResetPingTimer()
165162
{
166-
mPingOutstanding = 0;
167163
if (mPingTimer) {
164+
mPingOutstanding = 0;
168165
mPingTimer->SetDelay(mPingInterval);
169166
}
170167
}

0 commit comments

Comments
 (0)