From 35bfdc49f6fa3ed84d6aa9b877923490f24b3a79 Mon Sep 17 00:00:00 2001 From: Ryan VanderMeulen Date: Tue, 30 Jul 2013 10:56:00 -0400 Subject: [PATCH] Backed out changeset e9530cf2baed (bug 890597) for Windows Werror bustage. --- dom/webidl/DummyBinding.webidl | 1 - dom/webidl/NetDashboard.webidl | 5 - netwerk/base/public/nsIDashboard.idl | 9 -- netwerk/base/src/Dashboard.cpp | 168 +-------------------------- netwerk/base/src/Dashboard.h | 43 +------ netwerk/base/src/DashboardTypes.h | 5 - 6 files changed, 2 insertions(+), 229 deletions(-) diff --git a/dom/webidl/DummyBinding.webidl b/dom/webidl/DummyBinding.webidl index 48fa8c941f53..7bdfbbe7dd3f 100644 --- a/dom/webidl/DummyBinding.webidl +++ b/dom/webidl/DummyBinding.webidl @@ -16,7 +16,6 @@ interface DummyInterface { void funcHttpConnDict(optional HttpConnDict arg); void funcWebSocketDict(optional WebSocketDict arg); void funcDNSCacheDict(optional DNSCacheDict arg); - void funcConnStatusDict(optional ConnStatusDict arg); void frameRequestCallback(FrameRequestCallback arg); void idbObjectStoreParams(optional IDBObjectStoreParameters arg); void CameraPictureOptions(optional CameraPictureOptions arg); diff --git a/dom/webidl/NetDashboard.webidl b/dom/webidl/NetDashboard.webidl index daf553918ef7..23f200bc7b7a 100644 --- a/dom/webidl/NetDashboard.webidl +++ b/dom/webidl/NetDashboard.webidl @@ -49,8 +49,3 @@ dictionary DNSCacheDict { sequence family; sequence expiration; }; - -dictionary ConnStatusDict { - DOMString status; -}; - diff --git a/netwerk/base/public/nsIDashboard.idl b/netwerk/base/public/nsIDashboard.idl index ac1bae613f38..e04bc2a6e2a1 100644 --- a/netwerk/base/public/nsIDashboard.idl +++ b/netwerk/base/public/nsIDashboard.idl @@ -35,15 +35,6 @@ interface nsIDashboard : nsISupports /* Arrays: hostname, family, hostaddr, expiration */ void requestDNSInfo(in NetDashboardCallback cb); - /* aProtocol: a transport layer protocol: - * ex: "ssl", "tcp", default is "tcp". - * aHost: the host's name - * aPort: the port which the connection will open on - * aTimeout: the timespan before the connection will be timed out */ - void requestConnection(in ACString aHost, in unsigned long aPort, - in string aProtocol, in unsigned long aTimeout, - in NetDashboardCallback cb); - /* When true, the service will log websocket events */ attribute boolean enableLogging; }; diff --git a/netwerk/base/src/Dashboard.cpp b/netwerk/base/src/Dashboard.cpp index 0c86accc23a4..b0f9e8a1c13a 100644 --- a/netwerk/base/src/Dashboard.cpp +++ b/netwerk/base/src/Dashboard.cpp @@ -13,8 +13,7 @@ using mozilla::AutoSafeJSContext; namespace mozilla { namespace net { -NS_IMPL_ISUPPORTS4(Dashboard, nsIDashboard, nsIDashboardEventNotifier, - nsITransportEventSink, nsITimerCallback) +NS_IMPL_ISUPPORTS2(Dashboard, nsIDashboard, nsIDashboardEventNotifier) using mozilla::dom::Sequence; Dashboard::Dashboard() @@ -496,169 +495,4 @@ HttpConnInfo::SetHTTP2ProtocolVersion(uint8_t pv) protocolVersion.Assign(NS_LITERAL_STRING("spdy/3")); } -NS_IMETHODIMP -Dashboard::RequestConnection(const nsACString& aHost, uint32_t aPort, - const char *aProtocol, uint32_t aTimeout, - NetDashboardCallback* cb) -{ - nsresult rv; - mConn.cb = cb; - mConn.thread = NS_GetCurrentThread(); - - rv = TestNewConnection(aHost, aPort, aProtocol, aTimeout); - if (NS_FAILED(rv)) { - ConnStatus status; - CopyASCIItoUTF16(GetErrorString(rv), status.creationSts); - nsCOMPtr event = new DashConnStatusRunnable(this, status); - mConn.thread->Dispatch(event, NS_DISPATCH_NORMAL); - return rv; - } - - return NS_OK; -} - -nsresult -Dashboard::GetConnectionStatus(ConnStatus aStatus) -{ - AutoSafeJSContext cx; - - mozilla::dom::ConnStatusDict dict; - dict.mStatus.Construct(); - nsString &status = dict.mStatus.Value(); - status = aStatus.creationSts; - - JS::RootedValue val(cx); - if (!dict.ToObject(cx, JS::NullPtr(), &val)) { - mConn.cb = nullptr; - return NS_ERROR_FAILURE; - } - mConn.cb->OnDashboardDataAvailable(val); - - return NS_OK; -} - -nsresult -Dashboard::TestNewConnection(const nsACString& aHost, uint32_t aPort, - const char *aProtocol, uint32_t aTimeout) -{ - nsresult rv; - if (!aHost.Length() || !net_IsValidHostName(aHost)) - return NS_ERROR_UNKNOWN_HOST; - - if (aProtocol && NS_LITERAL_STRING("ssl").EqualsASCII(aProtocol)) - rv = gSocketTransportService->CreateTransport(&aProtocol, 1, aHost, - aPort, nullptr, - getter_AddRefs(mConn.socket)); - else - rv = gSocketTransportService->CreateTransport(nullptr, 0, aHost, - aPort, nullptr, - getter_AddRefs(mConn.socket)); - if (NS_FAILED(rv)) - return rv; - - rv = mConn.socket->SetEventSink(this, NS_GetCurrentThread()); - if (NS_FAILED(rv)) - return rv; - - rv = mConn.socket->OpenInputStream(nsITransport::OPEN_BLOCKING, 0, 0, - getter_AddRefs(mConn.streamIn)); - if (NS_FAILED(rv)) - return rv; - - StartTimer(aTimeout); - - return rv; -} - -NS_IMETHODIMP -Dashboard::OnTransportStatus(nsITransport *aTransport, nsresult aStatus, - uint64_t aProgress, uint64_t aProgressMax) -{ - if (aStatus == NS_NET_STATUS_CONNECTED_TO) - StopTimer(); - - ConnStatus status; - CopyASCIItoUTF16(GetErrorString(aStatus), status.creationSts); - nsCOMPtr event = new DashConnStatusRunnable(this, status); - mConn.thread->Dispatch(event, NS_DISPATCH_NORMAL); - - return NS_OK; -} - -NS_IMETHODIMP -Dashboard::Notify(nsITimer *timer) -{ - if (mConn.socket) { - mConn.socket->Close(NS_ERROR_ABORT); - mConn.socket = nullptr; - mConn.streamIn = nullptr; - } - - mConn.timer = nullptr; - - ConnStatus status; - status.creationSts.Assign(NS_LITERAL_STRING("NS_ERROR_NET_TIMEOUT")); - nsCOMPtr event = new DashConnStatusRunnable(this, status); - mConn.thread->Dispatch(event, NS_DISPATCH_NORMAL); - - return NS_OK; -} - -void -Dashboard::StartTimer(uint32_t aTimeout) -{ - if (!mConn.timer) - mConn.timer = do_CreateInstance("@mozilla.org/timer;1"); - mConn.timer->InitWithCallback(this, aTimeout * 1000, nsITimer::TYPE_ONE_SHOT); -} - -void -Dashboard::StopTimer() -{ - if (mConn.timer) { - mConn.timer->Cancel(); - mConn.timer = nullptr; - } -} - -typedef struct -{ - nsresult key; - const char *error; -} ErrorEntry; - -ErrorEntry errors[] = { - #define ERROR(key, val) {key, #key} - #include "ErrorList.h" - #undef ERROR -}; - -ErrorEntry socketTransportStatuses[] = { - #define ERROR(key, val) {key, #key} - ERROR(NS_NET_STATUS_RESOLVING_HOST, FAILURE(3)), - ERROR(NS_NET_STATUS_RESOLVED_HOST, FAILURE(11)), - ERROR(NS_NET_STATUS_CONNECTING_TO, FAILURE(7)), - ERROR(NS_NET_STATUS_CONNECTED_TO, FAILURE(4)), - ERROR(NS_NET_STATUS_SENDING_TO, FAILURE(5)), - ERROR(NS_NET_STATUS_WAITING_FOR, FAILURE(10)), - ERROR(NS_NET_STATUS_RECEIVING_FROM, FAILURE(6)), - #undef ERROR -}; - -const char * -Dashboard::GetErrorString(nsresult rv) -{ - int length = sizeof(socketTransportStatuses) / sizeof(ErrorEntry); - for (int i = 0;i < length;i++) - if (socketTransportStatuses[i].key == rv) - return socketTransportStatuses[i].error; - - length = sizeof(errors) / sizeof(ErrorEntry); - for (int i = 0;i < length;i++) - if (errors[i].key == rv) - return errors[i].error; - - return NULL; -} - } } // namespace mozilla::net diff --git a/netwerk/base/src/Dashboard.h b/netwerk/base/src/Dashboard.h index 08c25394ffb9..eeeb97f6a689 100644 --- a/netwerk/base/src/Dashboard.h +++ b/netwerk/base/src/Dashboard.h @@ -15,45 +15,32 @@ #include "nsSocketTransport2.h" #include "mozilla/net/DashboardTypes.h" #include "nsHttp.h" -#include "nsITransport.h" -#include "nsITimer.h" namespace mozilla { namespace net { class Dashboard: public nsIDashboard, - public nsIDashboardEventNotifier, - public nsITransportEventSink, - public nsITimerCallback + public nsIDashboardEventNotifier { public: NS_DECL_THREADSAFE_ISUPPORTS NS_DECL_NSIDASHBOARD NS_DECL_NSIDASHBOARDEVENTNOTIFIER - NS_DECL_NSITRANSPORTEVENTSINK - NS_DECL_NSITIMERCALLBACK Dashboard(); - friend class DashConnStatusRunnable; - static const char *GetErrorString(nsresult rv); private: virtual ~Dashboard(); void GetSocketsDispatch(); void GetHttpDispatch(); void GetDnsInfoDispatch(); - void StartTimer(uint32_t aTimeout); - void StopTimer(); - nsresult TestNewConnection(const nsACString& aHost, uint32_t aPort, - const char *aProtocol, uint32_t aTimeout); /* Helper methods that pass the JSON to the callback function. */ nsresult GetSockets(); nsresult GetHttpConnections(); nsresult GetWebSocketConnections(); nsresult GetDNSCacheEntries(); - nsresult GetConnectionStatus(struct ConnStatus aStatus); private: struct SocketData @@ -119,41 +106,13 @@ private: nsIThread* thread; }; - struct ConnectionData - { - nsCOMPtr socket; - nsCOMPtr streamIn; - nsCOMPtr timer; - nsCOMPtr cb; - nsIThread* thread; - }; - bool mEnableLogging; struct SocketData mSock; struct HttpData mHttp; struct WebSocketData mWs; struct DnsData mDns; - struct ConnectionData mConn; -}; -class DashConnStatusRunnable: public nsRunnable -{ -public: - DashConnStatusRunnable(Dashboard * aDashboard, ConnStatus aStatus) - : mDashboard(aDashboard) - { - mStatus.creationSts = aStatus.creationSts; - } - - NS_IMETHODIMP Run() - { - return mDashboard->GetConnectionStatus(mStatus); - } - -private: - ConnStatus mStatus; - Dashboard * mDashboard; }; } } // namespace mozilla::net diff --git a/netwerk/base/src/DashboardTypes.h b/netwerk/base/src/DashboardTypes.h index e3506679d7c6..5045150f6e4e 100644 --- a/netwerk/base/src/DashboardTypes.h +++ b/netwerk/base/src/DashboardTypes.h @@ -57,11 +57,6 @@ struct HttpRetParams bool ssl; }; -struct ConnStatus -{ - nsString creationSts; -}; - } } #endif // mozilla_net_DashboardTypes_h_