From cbb956e0c35e055e6203819793bffc1cf11db0aa Mon Sep 17 00:00:00 2001 From: Geoff Brown Date: Fri, 10 Nov 2017 07:03:36 -0700 Subject: [PATCH] Bug 1407679 - Merge nsIIOService and nsIIOService2; r=nwgh --- dom/events/test/test_bug336682.js | 2 +- dom/workers/test/test_onLine.html | 2 +- layout/tools/reftest/bootstrap.js | 2 +- .../tests/browser/robocop/robocop_head.js | 2 +- netwerk/base/moz.build | 1 - netwerk/base/nsIIOService.idl | 46 +++++++++++ netwerk/base/nsIIOService2.idl | 82 ------------------- netwerk/base/nsIOService.cpp | 41 ---------- netwerk/base/nsIOService.h | 5 +- netwerk/build/nsNetCID.h | 2 +- .../protocol/websocket/WebSocketChannel.cpp | 10 +-- netwerk/test/unit/test_bug1177909.js | 4 +- .../extensions/tps/components/tps-cmdline.js | 2 +- testing/mochitest/server.js | 2 +- testing/xpcshell/head.js | 2 +- toolkit/modules/Services.jsm | 2 +- .../modules/tests/xpcshell/test_Services.js | 1 - .../mozapps/update/tests/chrome/update.sjs | 2 +- toolkit/xre/nsAppRunner.cpp | 4 +- .../lib/rules/use-services.js | 1 - 20 files changed, 64 insertions(+), 151 deletions(-) delete mode 100644 netwerk/base/nsIIOService2.idl diff --git a/dom/events/test/test_bug336682.js b/dom/events/test/test_bug336682.js index 7f4ecfdf7768..a3bf0cb3eefe 100644 --- a/dom/events/test/test_bug336682.js +++ b/dom/events/test/test_bug336682.js @@ -65,7 +65,7 @@ function makeHandler(nameTemplate, eventName, expectedStates) { function doTest() { var iosvc = SpecialPowers.Cc["@mozilla.org/network/io-service;1"] - .getService(SpecialPowers.Ci.nsIIOService2); + .getService(SpecialPowers.Ci.nsIIOService); iosvc.manageOfflineStatus = false; iosvc.offline = false; ok(navigator.onLine, "navigator.onLine should be true, since we've just " + diff --git a/dom/workers/test/test_onLine.html b/dom/workers/test/test_onLine.html index f490f279c913..c76b42a052bc 100644 --- a/dom/workers/test/test_onLine.html +++ b/dom/workers/test/test_onLine.html @@ -45,7 +45,7 @@ addLoadEvent(function() { function doTest() { var iosvc = SpecialPowers.Cc["@mozilla.org/network/io-service;1"] - .getService(SpecialPowers.Ci.nsIIOService2); + .getService(SpecialPowers.Ci.nsIIOService); iosvc.manageOfflineStatus = false; info("setting iosvc.offline = true"); diff --git a/layout/tools/reftest/bootstrap.js b/layout/tools/reftest/bootstrap.js index 1328a8eb054d..f8312e4b850c 100644 --- a/layout/tools/reftest/bootstrap.js +++ b/layout/tools/reftest/bootstrap.js @@ -39,7 +39,7 @@ function startup(data, reason) { let orig = Services.wm.getMostRecentWindow("navigator:browser"); let ios = Cc["@mozilla.org/network/io-service;1"] - .getService(Ci.nsIIOService2); + .getService(Ci.nsIIOService); ios.manageOfflineStatus = false; ios.offline = false; diff --git a/mobile/android/tests/browser/robocop/robocop_head.js b/mobile/android/tests/browser/robocop/robocop_head.js index d2650f2f93b6..fd0614b619a2 100644 --- a/mobile/android/tests/browser/robocop/robocop_head.js +++ b/mobile/android/tests/browser/robocop/robocop_head.js @@ -38,7 +38,7 @@ function _dump(str) { // not connected to a network. { let ios = Components.classes["@mozilla.org/network/io-service;1"] - .getService(Components.interfaces.nsIIOService2); + .getService(Components.interfaces.nsIIOService); ios.manageOfflineStatus = false; ios.offline = false; } diff --git a/netwerk/base/moz.build b/netwerk/base/moz.build index e0695e72a524..d7abc3c5bf36 100644 --- a/netwerk/base/moz.build +++ b/netwerk/base/moz.build @@ -53,7 +53,6 @@ XPIDL_SOURCES += [ 'nsIInputStreamChannel.idl', 'nsIInputStreamPump.idl', 'nsIIOService.idl', - 'nsIIOService2.idl', 'nsILoadContextInfo.idl', 'nsILoadGroup.idl', 'nsILoadGroupChild.idl', diff --git a/netwerk/base/nsIIOService.idl b/netwerk/base/nsIIOService.idl index b332b29fd49e..bf6f037af5a3 100644 --- a/netwerk/base/nsIIOService.idl +++ b/netwerk/base/nsIIOService.idl @@ -184,6 +184,52 @@ interface nsIIOService : nsISupports * @return true if the URI hostname is a local IP address */ boolean hostnameIsLocalIPAddress(in nsIURI aURI); + + /** + * While this is set, IOService will monitor an nsINetworkLinkService + * (if available) and set its offline status to "true" whenever + * isLinkUp is false. + * + * Applications that want to control changes to the IOService's offline + * status should set this to false, watch for network:link-status-changed + * broadcasts, and change nsIIOService::offline as they see fit. Note + * that this means during application startup, IOService may be offline + * if there is no link, until application code runs and can turn off + * this management. + */ + attribute boolean manageOfflineStatus; + + /** + * Creates a channel for a given URI. + * + * @param aURI + * nsIURI from which to make a channel + * @param aProxyURI + * nsIURI to use for proxy resolution. Can be null in which + * case aURI is used + * @param aProxyFlags flags from nsIProtocolProxyService to use + * when resolving proxies for this new channel + * @param aLoadingNode + * @param aLoadingPrincipal + * @param aTriggeringPrincipal + * @param aSecurityFlags + * @param aContentPolicyType + * These will be used as values for the nsILoadInfo object on the + * created channel. For details, see nsILoadInfo in nsILoadInfo.idl + * @return reference to the new nsIChannel object + * + * Please note, if you provide both a loadingNode and a loadingPrincipal, + * then loadingPrincipal must be equal to loadingNode->NodePrincipal(). + * But less error prone is to just supply a loadingNode. + */ + nsIChannel newChannelFromURIWithProxyFlags2(in nsIURI aURI, + in nsIURI aProxyURI, + in unsigned long aProxyFlags, + in nsIDOMNode aLoadingNode, + in nsIPrincipal aLoadingPrincipal, + in nsIPrincipal aTriggeringPrincipal, + in unsigned long aSecurityFlags, + in unsigned long aContentPolicyType); }; %{C++ diff --git a/netwerk/base/nsIIOService2.idl b/netwerk/base/nsIIOService2.idl deleted file mode 100644 index d7b434d170b5..000000000000 --- a/netwerk/base/nsIIOService2.idl +++ /dev/null @@ -1,82 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* vim:expandtab:shiftwidth=4:tabstop=4: - */ -/* 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 "nsIIOService.idl" - -interface nsIDOMNode; -interface nsIPrincipal; - -/** - * nsIIOService2 extends nsIIOService - */ -[scriptable, uuid(52c5804b-0d3c-4d4f-8654-1c36fd310e69)] -interface nsIIOService2 : nsIIOService -{ - /** - * While this is set, IOService will monitor an nsINetworkLinkService - * (if available) and set its offline status to "true" whenever - * isLinkUp is false. - * - * Applications that want to control changes to the IOService's offline - * status should set this to false, watch for network:link-status-changed - * broadcasts, and change nsIIOService::offline as they see fit. Note - * that this means during application startup, IOService may be offline - * if there is no link, until application code runs and can turn off - * this management. - */ - attribute boolean manageOfflineStatus; - - /** - * Creates a channel for a given URI. - * - * @param aURI - * nsIURI from which to make a channel - * @param aProxyURI - * nsIURI to use for proxy resolution. Can be null in which - * case aURI is used - * @param aProxyFlags flags from nsIProtocolProxyService to use - * when resolving proxies for this new channel - * @param aLoadingNode - * @param aLoadingPrincipal - * @param aTriggeringPrincipal - * @param aSecurityFlags - * @param aContentPolicyType - * These will be used as values for the nsILoadInfo object on the - * created channel. For details, see nsILoadInfo in nsILoadInfo.idl - * @return reference to the new nsIChannel object - * - * Please note, if you provide both a loadingNode and a loadingPrincipal, - * then loadingPrincipal must be equal to loadingNode->NodePrincipal(). - * But less error prone is to just supply a loadingNode. - */ - nsIChannel newChannelFromURIWithProxyFlags2(in nsIURI aURI, - in nsIURI aProxyURI, - in unsigned long aProxyFlags, - in nsIDOMNode aLoadingNode, - in nsIPrincipal aLoadingPrincipal, - in nsIPrincipal aTriggeringPrincipal, - in unsigned long aSecurityFlags, - in unsigned long aContentPolicyType); - - /** - * ***** DEPRECATED ***** - * Please use newChannelFromURIWithProxyFlags2() - * - * Creates a channel for a given URI. - * - * @param aURI nsIURI from which to make a channel - * @param aProxyURI nsIURI to use for proxy resolution. Can be null in which - * case aURI is used - * @param aProxyFlags flags from nsIProtocolProxyService to use - * when resolving proxies for this new channel - * @return reference to the new nsIChannel object - */ - nsIChannel newChannelFromURIWithProxyFlags(in nsIURI aURI, - in nsIURI aProxyURI, - in unsigned long aProxyFlags); - -}; diff --git a/netwerk/base/nsIOService.cpp b/netwerk/base/nsIOService.cpp index 1f05c22554ae..6308dc376bbf 100644 --- a/netwerk/base/nsIOService.cpp +++ b/netwerk/base/nsIOService.cpp @@ -368,7 +368,6 @@ nsIOService::GetInstance() { NS_IMPL_ISUPPORTS(nsIOService, nsIIOService, - nsIIOService2, nsINetUtil, nsISpeculativeConnect, nsIObserver, @@ -941,46 +940,6 @@ nsIOService::NewChannelFromURIWithProxyFlags2(nsIURI* aURI, result); } -/* ***** DEPRECATED ***** - * please use NewChannelFromURIWithProxyFlags2 providing the right arguments for: - * * aLoadingNode - * * aLoadingPrincipal - * * aTriggeringPrincipal - * * aSecurityFlags - * * aContentPolicyType - * - * See nsIIoService.idl for a detailed description of those arguments - */ -NS_IMETHODIMP -nsIOService::NewChannelFromURIWithProxyFlags(nsIURI *aURI, - nsIURI *aProxyURI, - uint32_t aProxyFlags, - nsIChannel **result) -{ - NS_ASSERTION(false, "Deprecated, use NewChannelFromURIWithProxyFlags2 providing loadInfo arguments!"); - - const char16_t* params[] = { - u"nsIOService::NewChannelFromURIWithProxyFlags()", - u"nsIOService::NewChannelFromURIWithProxyFlags2()" - }; - nsContentUtils::ReportToConsole(nsIScriptError::warningFlag, - NS_LITERAL_CSTRING("Security by Default"), - nullptr, // aDocument - nsContentUtils::eNECKO_PROPERTIES, - "APIDeprecationWarning", - params, ArrayLength(params)); - - return NewChannelFromURIWithProxyFlags2(aURI, - aProxyURI, - aProxyFlags, - nullptr, // aLoadingNode - nsContentUtils::GetSystemPrincipal(), - nullptr, // aTriggeringPrincipal - nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL, - nsIContentPolicy::TYPE_OTHER, - result); -} - NS_IMETHODIMP nsIOService::NewChannel2(const nsACString& aSpec, const char* aCharset, diff --git a/netwerk/base/nsIOService.h b/netwerk/base/nsIOService.h index 3447e9626250..068b81da895a 100644 --- a/netwerk/base/nsIOService.h +++ b/netwerk/base/nsIOService.h @@ -7,7 +7,7 @@ #define nsIOService_h__ #include "nsStringFwd.h" -#include "nsIIOService2.h" +#include "nsIIOService.h" #include "nsTArray.h" #include "nsCOMPtr.h" #include "nsWeakPtr.h" @@ -46,7 +46,7 @@ namespace net { class NeckoChild; class nsAsyncRedirectVerifyHelper; -class nsIOService final : public nsIIOService2 +class nsIOService final : public nsIIOService , public nsIObserver , public nsINetUtil , public nsISpeculativeConnect @@ -56,7 +56,6 @@ class nsIOService final : public nsIIOService2 public: NS_DECL_THREADSAFE_ISUPPORTS NS_DECL_NSIIOSERVICE - NS_DECL_NSIIOSERVICE2 NS_DECL_NSIOBSERVER NS_DECL_NSINETUTIL NS_DECL_NSISPECULATIVECONNECT diff --git a/netwerk/build/nsNetCID.h b/netwerk/build/nsNetCID.h index 11ad735b26a5..d50d26ac60ab 100644 --- a/netwerk/build/nsNetCID.h +++ b/netwerk/build/nsNetCID.h @@ -11,7 +11,7 @@ * netwerk/base/ classes */ -// service implementing nsIIOService and nsIIOService2. +// service implementing nsIIOService #define NS_IOSERVICE_CONTRACTID \ "@mozilla.org/network/io-service;1" #define NS_IOSERVICE_CID \ diff --git a/netwerk/protocol/websocket/WebSocketChannel.cpp b/netwerk/protocol/websocket/WebSocketChannel.cpp index dfbcd66de9cd..a7f6bbe733ac 100644 --- a/netwerk/protocol/websocket/WebSocketChannel.cpp +++ b/netwerk/protocol/websocket/WebSocketChannel.cpp @@ -25,7 +25,7 @@ #include "nsIDNSRecord.h" #include "nsIDNSService.h" #include "nsIStreamConverterService.h" -#include "nsIIOService2.h" +#include "nsIIOService.h" #include "nsIProtocolProxyService.h" #include "nsIProxyInfo.h" #include "nsIProxiedChannel.h" @@ -3468,15 +3468,9 @@ WebSocketChannel::AsyncOpen(nsIURI *aURI, return rv; } - nsCOMPtr io2 = do_QueryInterface(ioService, &rv); - if (NS_FAILED(rv)) { - NS_WARNING("WebSocketChannel: unable to continue without ioservice2"); - return rv; - } - // Ideally we'd call newChannelFromURIWithLoadInfo here, but that doesn't // allow setting proxy uri/flags - rv = io2->NewChannelFromURIWithProxyFlags2( + rv = ioService->NewChannelFromURIWithProxyFlags2( localURI, mURI, nsIProtocolProxyService::RESOLVE_PREFER_HTTPS_PROXY | diff --git a/netwerk/test/unit/test_bug1177909.js b/netwerk/test/unit/test_bug1177909.js index 547aaffee579..7929d4615584 100644 --- a/netwerk/test/unit/test_bug1177909.js +++ b/netwerk/test/unit/test_bug1177909.js @@ -105,7 +105,7 @@ add_task(async function testDirectProxy() { uri.scheme = "https"; let ioService = Cc["@mozilla.org/network/io-service;1"]. - getService(Ci.nsIIOService2); + getService(Ci.nsIIOService); let chan = ioService. newChannelFromURIWithProxyFlags2(uri, proxyURI, @@ -131,7 +131,7 @@ add_task(async function testWebSocketProxy() { Ci.nsIProtocolProxyService.RESOLVE_ALWAYS_TUNNEL; let ioService = Cc["@mozilla.org/network/io-service;1"]. - getService(Ci.nsIIOService2); + getService(Ci.nsIIOService); let chan = ioService. newChannelFromURIWithProxyFlags2(uri, proxyURI, diff --git a/services/sync/tps/extensions/tps/components/tps-cmdline.js b/services/sync/tps/extensions/tps/components/tps-cmdline.js index 1c7f11dc7379..6f3498f434fb 100644 --- a/services/sync/tps/extensions/tps/components/tps-cmdline.js +++ b/services/sync/tps/extensions/tps/components/tps-cmdline.js @@ -64,7 +64,7 @@ TPSCmdLineHandler.prototype = { Services.obs.removeObserver(onStartupFinished, "browser-delayed-startup-finished"); /* Ignore the platform's online/offline status while running tests. */ var ios = Components.classes["@mozilla.org/network/io-service;1"] - .getService(Components.interfaces.nsIIOService2); + .getService(Components.interfaces.nsIIOService); ios.manageOfflineStatus = false; ios.offline = false; Components.utils.import("resource://tps/tps.jsm"); diff --git a/testing/mochitest/server.js b/testing/mochitest/server.js index 331e28ea51a0..630148f1a3bc 100644 --- a/testing/mochitest/server.js +++ b/testing/mochitest/server.js @@ -11,7 +11,7 @@ // Disable automatic network detection, so tests work correctly when // not connected to a network. var ios = Cc["@mozilla.org/network/io-service;1"] - .getService(Ci.nsIIOService2); + .getService(Ci.nsIIOService); ios.manageOfflineStatus = false; ios.offline = false; diff --git a/testing/xpcshell/head.js b/testing/xpcshell/head.js index 3d2ac6863134..bff09566434f 100644 --- a/testing/xpcshell/head.js +++ b/testing/xpcshell/head.js @@ -73,7 +73,7 @@ var _testLogger = new _LoggerClass("xpcshell/head.js", _dumpLog, [_add_params]); // not connected to a network. { let ios = Components.classes["@mozilla.org/network/io-service;1"] - .getService(Components.interfaces.nsIIOService2); + .getService(Components.interfaces.nsIIOService); ios.manageOfflineStatus = false; ios.offline = false; } diff --git a/toolkit/modules/Services.jsm b/toolkit/modules/Services.jsm index 5a362d1f3151..23066384252d 100644 --- a/toolkit/modules/Services.jsm +++ b/toolkit/modules/Services.jsm @@ -69,7 +69,7 @@ XPCOMUtils.defineLazyGetter(Services, "ppmm", () => { XPCOMUtils.defineLazyGetter(Services, "io", () => { return Cc["@mozilla.org/network/io-service;1"] - .getService(Ci.nsIIOService2) + .getService(Ci.nsIIOService) .QueryInterface(Ci.nsISpeculativeConnect); }); diff --git a/toolkit/modules/tests/xpcshell/test_Services.js b/toolkit/modules/tests/xpcshell/test_Services.js index c1d27f04c03d..6aefbddcb240 100644 --- a/toolkit/modules/tests/xpcshell/test_Services.js +++ b/toolkit/modules/tests/xpcshell/test_Services.js @@ -43,7 +43,6 @@ function run_test() { checkService("eTLD", Ci.nsIEffectiveTLDService); checkService("focus", Ci.nsIFocusManager); checkService("io", Ci.nsIIOService); - checkService("io", Ci.nsIIOService2); checkService("intl", Ci.mozIMozIntl); checkService("locale", Ci.mozILocaleService); checkService("logins", Ci.nsILoginManager); diff --git a/toolkit/mozapps/update/tests/chrome/update.sjs b/toolkit/mozapps/update/tests/chrome/update.sjs index f4bee4e414b0..33dfa3ee4b8d 100644 --- a/toolkit/mozapps/update/tests/chrome/update.sjs +++ b/toolkit/mozapps/update/tests/chrome/update.sjs @@ -22,7 +22,7 @@ function getTestDataFile(aFilename) { } function loadHelperScript(aScriptFile) { - let io = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService2); + let io = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService); let scriptSpec = io.newFileURI(aScriptFile).spec; let scriptloader = Cc["@mozilla.org/moz/jssubscript-loader;1"]. getService(Ci.mozIJSSubScriptLoader); diff --git a/toolkit/xre/nsAppRunner.cpp b/toolkit/xre/nsAppRunner.cpp index b6feceb809b1..9402ef8f0c75 100644 --- a/toolkit/xre/nsAppRunner.cpp +++ b/toolkit/xre/nsAppRunner.cpp @@ -63,7 +63,7 @@ #include "nsIDialogParamBlock.h" #include "nsIDOMWindow.h" #include "mozilla/ModuleUtils.h" -#include "nsIIOService2.h" +#include "nsIIOService.h" #include "nsIObserverService.h" #include "nsINativeAppSupport.h" #include "nsIPlatformInfo.h" @@ -4368,7 +4368,7 @@ XREMain::XRE_mainRun() #endif if (mStartOffline) { - nsCOMPtr io (do_GetService("@mozilla.org/network/io-service;1")); + nsCOMPtr io(do_GetService("@mozilla.org/network/io-service;1")); NS_ENSURE_TRUE(io, NS_ERROR_FAILURE); io->SetManageOfflineStatus(false); io->SetOffline(true); diff --git a/tools/lint/eslint/eslint-plugin-mozilla/lib/rules/use-services.js b/tools/lint/eslint/eslint-plugin-mozilla/lib/rules/use-services.js index 814e34d92c36..c763216fc654 100644 --- a/tools/lint/eslint/eslint-plugin-mozilla/lib/rules/use-services.js +++ b/tools/lint/eslint/eslint-plugin-mozilla/lib/rules/use-services.js @@ -31,7 +31,6 @@ var servicesASTParser = { "nsIFrameScriptLoader": "mm", "nsIProcessScriptLoader": "ppmm", "nsIIOService": "io", - "nsIIOService2": "io", "nsISpeculativeConnect": "io", "nsICookieManager": "cookies" },