2001-09-28 20:14:13 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-05-21 11:12:37 +00:00
|
|
|
/* 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/. */
|
1999-06-07 21:33:30 +00:00
|
|
|
|
|
|
|
#ifndef nsIOService_h__
|
|
|
|
#define nsIOService_h__
|
|
|
|
|
2003-04-23 03:47:43 +00:00
|
|
|
#include "necko-config.h"
|
|
|
|
|
2000-03-31 09:34:43 +00:00
|
|
|
#include "nsString.h"
|
2006-04-04 21:26:17 +00:00
|
|
|
#include "nsIIOService2.h"
|
2009-02-23 01:05:28 +00:00
|
|
|
#include "nsTArray.h"
|
2005-04-14 23:18:34 +00:00
|
|
|
#include "nsPISocketTransportService.h"
|
2005-04-06 01:33:28 +00:00
|
|
|
#include "nsPIDNSService.h"
|
2006-03-30 17:31:15 +00:00
|
|
|
#include "nsIProtocolProxyService2.h"
|
2000-01-19 07:58:40 +00:00
|
|
|
#include "nsCOMPtr.h"
|
2000-02-03 03:44:22 +00:00
|
|
|
#include "nsURLHelper.h"
|
2000-08-22 06:16:50 +00:00
|
|
|
#include "nsWeakPtr.h"
|
2001-06-21 22:02:47 +00:00
|
|
|
#include "nsIURLParser.h"
|
2001-10-08 22:27:14 +00:00
|
|
|
#include "nsIObserver.h"
|
|
|
|
#include "nsWeakReference.h"
|
2005-07-25 20:27:04 +00:00
|
|
|
#include "nsINetUtil.h"
|
2006-02-22 14:07:21 +00:00
|
|
|
#include "nsIChannelEventSink.h"
|
2006-03-03 21:06:53 +00:00
|
|
|
#include "nsIContentSniffer.h"
|
2006-02-22 14:07:21 +00:00
|
|
|
#include "nsCategoryCache.h"
|
2006-04-04 21:26:17 +00:00
|
|
|
#include "nsINetworkLinkService.h"
|
2010-08-05 02:15:55 +00:00
|
|
|
#include "nsAsyncRedirectVerifyHelper.h"
|
2012-04-25 12:54:42 +00:00
|
|
|
#include "nsISpeculativeConnect.h"
|
2012-06-06 03:18:25 +00:00
|
|
|
#include "mozilla/Attributes.h"
|
2000-08-22 06:16:50 +00:00
|
|
|
|
|
|
|
#define NS_N(x) (sizeof(x)/sizeof(*x))
|
2003-04-23 03:47:43 +00:00
|
|
|
|
2010-05-11 12:44:12 +00:00
|
|
|
// We don't want to expose this observer topic.
|
|
|
|
// Intended internal use only for remoting offline/inline events.
|
|
|
|
// See Bug 552829
|
2010-05-11 17:22:34 +00:00
|
|
|
#define NS_IPC_IOSERVICE_SET_OFFLINE_TOPIC "ipc:network:set-offline"
|
2010-05-11 12:44:12 +00:00
|
|
|
|
2006-02-22 14:07:21 +00:00
|
|
|
static const char gScheme[][sizeof("resource")] =
|
|
|
|
{"chrome", "file", "http", "jar", "resource"};
|
1999-06-07 21:33:30 +00:00
|
|
|
|
2001-10-08 22:27:14 +00:00
|
|
|
class nsIPrefBranch;
|
|
|
|
|
2012-06-06 03:18:25 +00:00
|
|
|
class nsIOService MOZ_FINAL : public nsIIOService2
|
|
|
|
, public nsIObserver
|
|
|
|
, public nsINetUtil
|
|
|
|
, public nsISpeculativeConnect
|
|
|
|
, public nsSupportsWeakReference
|
1999-06-07 21:33:30 +00:00
|
|
|
{
|
|
|
|
public:
|
2013-07-19 02:24:13 +00:00
|
|
|
NS_DECL_THREADSAFE_ISUPPORTS
|
1999-08-22 23:52:07 +00:00
|
|
|
NS_DECL_NSIIOSERVICE
|
2006-04-04 21:26:17 +00:00
|
|
|
NS_DECL_NSIIOSERVICE2
|
2001-10-08 22:27:14 +00:00
|
|
|
NS_DECL_NSIOBSERVER
|
2005-07-25 20:27:04 +00:00
|
|
|
NS_DECL_NSINETUTIL
|
2012-04-25 12:54:42 +00:00
|
|
|
NS_DECL_NSISPECULATIVECONNECT
|
2001-10-08 22:27:14 +00:00
|
|
|
|
2006-03-01 18:45:14 +00:00
|
|
|
// Gets the singleton instance of the IO Service, creating it as needed
|
2012-07-30 14:20:58 +00:00
|
|
|
// Returns nullptr on out of memory or failure to initialize.
|
2006-03-01 18:45:14 +00:00
|
|
|
// Returns an addrefed pointer.
|
|
|
|
static nsIOService* GetInstance();
|
|
|
|
|
2004-07-01 23:31:47 +00:00
|
|
|
NS_HIDDEN_(nsresult) Init();
|
|
|
|
NS_HIDDEN_(nsresult) NewURI(const char* aSpec, nsIURI* aBaseURI,
|
|
|
|
nsIURI* *result,
|
|
|
|
nsIProtocolHandler* *hdlrResult);
|
1999-06-07 21:33:30 +00:00
|
|
|
|
2006-02-22 14:07:21 +00:00
|
|
|
// Called by channels before a redirect happens. This notifies the global
|
|
|
|
// redirect observers.
|
2010-08-05 02:15:55 +00:00
|
|
|
nsresult AsyncOnChannelRedirect(nsIChannel* oldChan, nsIChannel* newChan,
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t flags,
|
2010-08-05 02:15:55 +00:00
|
|
|
nsAsyncRedirectVerifyHelper *helper);
|
2006-02-22 14:07:21 +00:00
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool IsOffline() { return mOffline; }
|
|
|
|
bool IsLinkUp();
|
2007-03-14 01:52:07 +00:00
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool IsComingOnline() const {
|
2010-11-25 05:20:11 +00:00
|
|
|
return mOffline && mSettingOffline && !mSetOfflineValue;
|
|
|
|
}
|
|
|
|
|
2006-03-03 19:34:25 +00:00
|
|
|
private:
|
|
|
|
// These shouldn't be called directly:
|
|
|
|
// - construct using GetInstance
|
|
|
|
// - destroy using Release
|
|
|
|
nsIOService() NS_HIDDEN;
|
|
|
|
~nsIOService() NS_HIDDEN;
|
|
|
|
|
2006-04-04 21:26:17 +00:00
|
|
|
NS_HIDDEN_(nsresult) TrackNetworkLinkStatusForOffline();
|
|
|
|
|
2004-07-01 23:31:47 +00:00
|
|
|
NS_HIDDEN_(nsresult) GetCachedProtocolHandler(const char *scheme,
|
|
|
|
nsIProtocolHandler* *hdlrResult,
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t start=0,
|
|
|
|
uint32_t end=0);
|
2004-07-01 23:31:47 +00:00
|
|
|
NS_HIDDEN_(nsresult) CacheProtocolHandler(const char *scheme,
|
|
|
|
nsIProtocolHandler* hdlr);
|
2000-08-22 06:16:50 +00:00
|
|
|
|
2001-10-08 22:27:14 +00:00
|
|
|
// Prefs wrangling
|
2012-07-30 14:20:58 +00:00
|
|
|
NS_HIDDEN_(void) PrefsChanged(nsIPrefBranch *prefs, const char *pref = nullptr);
|
2012-01-17 01:48:29 +00:00
|
|
|
NS_HIDDEN_(void) GetPrefBranch(nsIPrefBranch **);
|
2011-09-29 06:19:26 +00:00
|
|
|
NS_HIDDEN_(void) ParsePortList(nsIPrefBranch *prefBranch, const char *pref, bool remove);
|
2001-10-08 22:27:14 +00:00
|
|
|
|
2010-11-25 05:20:11 +00:00
|
|
|
nsresult InitializeSocketTransportService();
|
2011-10-18 09:46:59 +00:00
|
|
|
nsresult InitializeNetworkLinkService();
|
2010-11-25 05:20:11 +00:00
|
|
|
|
2012-04-25 12:54:42 +00:00
|
|
|
// consolidated helper function
|
2012-08-22 15:56:38 +00:00
|
|
|
void LookupProxyInfo(nsIURI *aURI, nsIURI *aProxyURI, uint32_t aProxyFlags,
|
2012-04-25 12:54:42 +00:00
|
|
|
nsCString *aScheme, nsIProxyInfo **outPI);
|
|
|
|
|
2006-03-03 19:34:25 +00:00
|
|
|
private:
|
2011-09-29 06:19:26 +00:00
|
|
|
bool mOffline;
|
|
|
|
bool mOfflineForProfileChange;
|
|
|
|
bool mManageOfflineStatus;
|
2009-02-22 19:09:09 +00:00
|
|
|
|
|
|
|
// Used to handle SetOffline() reentrancy. See the comment in
|
|
|
|
// SetOffline() for more details.
|
2011-09-29 06:19:26 +00:00
|
|
|
bool mSettingOffline;
|
|
|
|
bool mSetOfflineValue;
|
2009-02-22 19:09:09 +00:00
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool mShutdown;
|
2009-03-18 14:52:31 +00:00
|
|
|
|
2005-04-14 23:18:34 +00:00
|
|
|
nsCOMPtr<nsPISocketTransportService> mSocketTransportService;
|
|
|
|
nsCOMPtr<nsPIDNSService> mDNSService;
|
2006-03-30 17:31:15 +00:00
|
|
|
nsCOMPtr<nsIProtocolProxyService2> mProxyService;
|
2006-04-04 21:26:17 +00:00
|
|
|
nsCOMPtr<nsINetworkLinkService> mNetworkLinkService;
|
2011-10-18 09:46:59 +00:00
|
|
|
bool mNetworkLinkServiceInitialized;
|
|
|
|
|
2000-08-22 06:16:50 +00:00
|
|
|
// Cached protocol handlers
|
2005-04-14 23:18:34 +00:00
|
|
|
nsWeakPtr mWeakHandler[NS_N(gScheme)];
|
2001-06-06 00:10:09 +00:00
|
|
|
|
2006-02-22 14:07:21 +00:00
|
|
|
// cached categories
|
|
|
|
nsCategoryCache<nsIChannelEventSink> mChannelEventSinks;
|
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
nsTArray<int32_t> mRestrictedPortList;
|
2002-07-02 18:15:19 +00:00
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool mAutoDialEnabled;
|
2002-07-02 18:15:19 +00:00
|
|
|
public:
|
2012-01-10 03:43:52 +00:00
|
|
|
// Used for all default buffer sizes that necko allocates.
|
2012-08-22 15:56:38 +00:00
|
|
|
static uint32_t gDefaultSegmentSize;
|
|
|
|
static uint32_t gDefaultSegmentCount;
|
1999-06-07 21:33:30 +00:00
|
|
|
};
|
|
|
|
|
2006-02-22 14:07:21 +00:00
|
|
|
/**
|
|
|
|
* Reference to the IO service singleton. May be null.
|
|
|
|
*/
|
|
|
|
extern nsIOService* gIOService;
|
|
|
|
|
1999-06-07 21:33:30 +00:00
|
|
|
#endif // nsIOService_h__
|