Fixing 42107, a=gagan. Documenting some APIs in the process as well.

This commit is contained in:
ruslan%netscape.com 2000-06-13 03:00:53 +00:00
Родитель 8fea867053
Коммит 4eac345a41
5 изменённых файлов: 84 добавлений и 14 удалений

Просмотреть файл

@ -44,6 +44,9 @@ interface nsIIOService : nsISupports
{
/**
* Returns a protocol handler for a given URI scheme.
*
* @param scheme URI scheme
* @return reference to nsIProtcolHandler
*/
nsIProtocolHandler getProtocolHandler(in string scheme);
@ -52,6 +55,10 @@ interface nsIIOService : nsISupports
* of the URI spec, and then delegating the construction of the URI
* to the protocol handler for that scheme. QueryInterface can be used
* on the resulting URI object to obtain a more specific type of URI.
*
* @param aSpec URI spec (http, ftp, etc)
* @param aBaseURI nsIURI to construct the actual URI from
* @return reference to a new nsIURI object
*/
nsIURI newURI(in string aSpec, in nsIURI aBaseURI);
@ -66,6 +73,9 @@ interface nsIIOService : nsISupports
* (e.g. a file: channel), or if a redirect occurs, causing the current
* URL to become different from the original URL. If NULL, the aURI parameter
* will be used as the originalURI instead.
*
* @param aURI - nsIURI to make a channel from
* @return a reference to the new nsIChannel object
*/
nsIChannel newChannelFromURI(in nsIURI aURI);
@ -79,6 +89,10 @@ interface nsIIOService : nsISupports
* (e.g. a file: channel), or if a redirect occurs, causing the current
* URL to become different from the original URL. If NULL, the aURI parameter
* will be used as the originalURI instead.
*
* @param aSpec URI spec to select the appropriate protocol handler
* @param aBaseURI a base URI to create a channel to
* @return a reference to the new nsIChannel object
*/
nsIChannel newChannel(in string aSpec, in nsIURI aBaseURI);
@ -130,16 +144,26 @@ interface nsIIOService : nsISupports
/**
* Encode characters into % escaped hexcodes.
*
* @param str a string to convert from
* @param mask a mask of flags to tell the converter which part of the url to escape
* @return escaped string
*/
string escape(in string str, in short mask);
/**
* Decode % escaped hex codes into character values.
*
* @param str a string to unescape from
* @return resulted unescaped string
*/
string unescape(in string str);
/**
* Get port from string.
*
* @param str URI-style string
* @return port number
*/
long extractPort(in string str);
@ -150,6 +174,10 @@ interface nsIIOService : nsISupports
* "/a/b/c/d/e/" yields "/a/b/c/foo/baz.html". Attempting to
* ascend above the base results in the NS_ERROR_MALFORMED_URI
* exception. If basePath is null, it treats it as "/".
*
* @param relativePath a relative URI
* @param basePath a base URI
* @return a new string, representing canonical uri
*/
string resolveRelativePath(in string relativePath,
in string basePath);

Просмотреть файл

@ -60,6 +60,7 @@ interface nsISocketTransportService : nsISupports
boolean reuseTransport(in nsIChannel i_Transport);
void init ();
void lateInit();
void shutdown();
void wakeup (in nsIChannel i_Transport);

Просмотреть файл

@ -58,6 +58,7 @@ nsIOService::Init()
getter_AddRefs(mSocketTransportService));
if (NS_FAILED(rv)) return rv;
rv = nsServiceManager::GetService(kFileTransportService,
NS_GET_IID(nsIFileTransportService),
getter_AddRefs(mFileTransportService));
@ -65,6 +66,16 @@ nsIOService::Init()
rv = nsServiceManager::GetService(kDNSServiceCID,
NS_GET_IID(nsIDNSService),
getter_AddRefs(mDNSService));
return rv;
}
nsresult
nsIOService::LateInit()
{
nsresult rv;
rv = mSocketTransportService -> LateInit ();
return rv;
}
@ -76,20 +87,42 @@ nsIOService::~nsIOService()
NS_METHOD
nsIOService::Create(nsISupports *aOuter, REFNSIID aIID, void **aResult)
{
static nsISupports *_rValue = nsnull;
nsresult rv;
NS_ENSURE_NO_AGGREGATION(aOuter);
if (_rValue)
{
NS_ADDREF (_rValue);
*aResult = _rValue;
return NS_OK;
}
nsIOService* _ios = new nsIOService();
if (_ios == nsnull)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(_ios);
rv = _ios->Init();
if (NS_FAILED(rv)) {
if (NS_FAILED(rv))
{
delete _ios;
return rv;
}
rv = _ios->QueryInterface(aIID, aResult);
NS_RELEASE(_ios);
if (NS_FAILED(rv))
{
delete _ios;
return rv;
}
_rValue = NS_STATIC_CAST (nsISupports*, *aResult);
_ios -> LateInit ();
NS_RELEASE (_rValue);
_rValue = nsnull;
return rv;
}

Просмотреть файл

@ -47,6 +47,7 @@ public:
Create(nsISupports *aOuter, REFNSIID aIID, void **aResult);
nsresult Init();
nsresult LateInit();
nsresult NewURI(const char* aSpec, nsIURI* aBaseURI,
nsIURI* *result, nsIProtocolHandler* *hdlrResult);

Просмотреть файл

@ -166,6 +166,25 @@ nsSocketTransportService::Init(void)
return rv;
}
NS_IMETHODIMP
nsSocketTransportService::LateInit(void)
{
nsresult res;
if (!m_stringBundle)
{
char* propertyURL = NECKO_MSGS_URL;
NS_WITH_SERVICE(nsIStringBundleService, sBundleService, kStringBundleServiceCID, &res);
if (NS_SUCCEEDED (res) && (nsnull != sBundleService))
{
nsILocale *locale = nsnull;
res = sBundleService->CreateBundle(propertyURL, locale, getter_AddRefs(m_stringBundle));
}
}
return NS_OK;
}
nsresult nsSocketTransportService::AddToWorkQ(nsSocketTransport* aTransport)
{
@ -659,18 +678,6 @@ nsSocketTransportService::GetNeckoStringByName (const char *aName, PRUnichar **a
nsresult res;
nsAutoString resultString; resultString.AssignWithConversion(aName);
if (!m_stringBundle)
{
char* propertyURL = NECKO_MSGS_URL;
NS_WITH_SERVICE(nsIStringBundleService, sBundleService, kStringBundleServiceCID, &res);
if (NS_SUCCEEDED (res) && (nsnull != sBundleService))
{
nsILocale *locale = nsnull;
res = sBundleService->CreateBundle(propertyURL, locale, getter_AddRefs(m_stringBundle));
}
}
if (m_stringBundle)
{
nsAutoString unicodeName; unicodeName.AssignWithConversion(aName);