☠☠ backed out by ea3b20b96fe7 ☠ ☠ | |
author | Anuj Agarwal <anujagarwal464@gmail.com> |
Wed, 22 Oct 2014 08:55:00 +0200 | |
changeset 213161 | 83f801de85fb149e27f1978f5e14aad1a86d2389 |
parent 213160 | 3333c226a1d870d99729d1e3c428a51a549361c8 |
child 213162 | fedce15e6ea22db45b0febcb8decce9ca200db80 |
push id | 27742 |
push user | ryanvm@gmail.com |
push date | Thu, 30 Oct 2014 20:15:35 +0000 |
treeherder | mozilla-central@e0b505a37b1c [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | nfroyd |
bugs | 792989 |
milestone | 36.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
--- a/netwerk/base/src/Dashboard.cpp +++ b/netwerk/base/src/Dashboard.cpp @@ -1,14 +1,15 @@ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http:mozilla.org/MPL/2.0/. */ #include "mozilla/dom/NetDashboardBinding.h" #include "mozilla/dom/ToJSValue.h" +#include "mozilla/ErrorNames.h" #include "mozilla/net/Dashboard.h" #include "mozilla/net/HttpInfo.h" #include "nsHttp.h" #include "nsICancelable.h" #include "nsIDNSService.h" #include "nsIDNSRecord.h" #include "nsIInputStream.h" #include "nsISocketTransport.h" @@ -45,16 +46,18 @@ public: nsIThread *mThread; private: virtual ~SocketData() { } }; +static void GetErrorString(nsresult rv, nsAString& errorString); + NS_IMPL_ISUPPORTS0(SocketData) class HttpData : public nsISupports { virtual ~HttpData() { @@ -166,17 +169,17 @@ NS_IMPL_ISUPPORTS(ConnectionData, nsITra NS_IMETHODIMP ConnectionData::OnTransportStatus(nsITransport *aTransport, nsresult aStatus, uint64_t aProgress, uint64_t aProgressMax) { if (aStatus == NS_NET_STATUS_CONNECTED_TO) { StopTimer(); } - CopyASCIItoUTF16(Dashboard::GetErrorString(aStatus), mStatus); + GetErrorString(aStatus, mStatus); nsCOMPtr<nsIRunnable> event = NS_NewRunnableMethodWithArg<nsRefPtr<ConnectionData> > (mDashboard, &Dashboard::GetConnectionStatus, this); mThread->Dispatch(event, NS_DISPATCH_NORMAL); return NS_OK; } @@ -311,17 +314,17 @@ LookupHelper::ConstructAnswer(LookupArgu while (hasMore) { nsCString nextAddress; aRecord->GetNextAddrAsString(nextAddress); CopyASCIItoUTF16(nextAddress, *addresses.AppendElement()); aRecord->HasMore(&hasMore); } } else { dict.mAnswer = false; - CopyASCIItoUTF16(Dashboard::GetErrorString(mStatus), dict.mError); + GetErrorString(mStatus, dict.mError); } JS::RootedValue val(cx); if (!ToJSValue(cx, dict, &val)) { return NS_ERROR_FAILURE; } this->mCallback->OnDashboardDataAvailable(val); @@ -801,17 +804,17 @@ Dashboard::RequestConnection(const nsACS connectionData->mTimeout = aTimeout; connectionData->mCallback = new nsMainThreadPtrHolder<NetDashboardCallback>(aCallback, true); connectionData->mThread = NS_GetCurrentThread(); rv = TestNewConnection(connectionData); if (NS_FAILED(rv)) { - CopyASCIItoUTF16(GetErrorString(rv), connectionData->mStatus); + mozilla::net::GetErrorString(rv, connectionData->mStatus); nsCOMPtr<nsIRunnable> event = NS_NewRunnableMethodWithArg<nsRefPtr<ConnectionData> > (this, &Dashboard::GetConnectionStatus, connectionData); connectionData->mThread->Dispatch(event, NS_DISPATCH_NORMAL); return rv; } return NS_OK; @@ -884,42 +887,35 @@ typedef struct { nsresult key; const char *error; } ErrorEntry; #undef ERROR #define ERROR(key, val) {key, #key} -ErrorEntry errors[] = { - #include "ErrorList.h" -}; - ErrorEntry socketTransportStatuses[] = { 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) + +static void +GetErrorString(nsresult rv, nsAString& errorString) { - int length = sizeof(socketTransportStatuses) / sizeof(ErrorEntry); - for (int i = 0;i < length;i++) + for (size_t i = 0; i < ArrayLength(socketTransportStatuses); ++i) { if (socketTransportStatuses[i].key == rv) { - return socketTransportStatuses[i].error; + errorString.AssignASCII(socketTransportStatuses[i].error); + return; } - - length = sizeof(errors) / sizeof(ErrorEntry); - for (int i = 0;i < length;i++) - if (errors[i].key == rv) { - return errors[i].error; - } - - return nullptr; + } + nsAutoCString errorCString; + mozilla::GetErrorName(rv, errorCString); + CopyUTF8toUTF16(errorCString, errorString); } } } // namespace mozilla::net