Back to index

lightning-sunbird  0.9+nobinonly
Static Public Member Functions
GeckoProtocolHandler Class Reference

#include <GeckoProtocolHandler.h>

List of all members.

Static Public Member Functions

static nsresult RegisterHandler (const char *aScheme, const char *aDescription, GeckoChannelCallback *aCallback)

Detailed Description

Definition at line 51 of file GeckoProtocolHandler.h.

Member Function Documentation

nsresult GeckoProtocolHandler::RegisterHandler ( const char *  aScheme,
const char *  aDescription,
GeckoChannelCallback aCallback 
) [static]

Definition at line 120 of file GeckoProtocolHandler.cpp.

    if (!aScheme || !aCallback)
        return NS_ERROR_INVALID_ARG;

    if (gUsedCIDs >= kProtocolCIDsSize)
        // We've run out of CIDs. Perhaps this code should be generating them
        // on the fly somehow instead?
        return NS_ERROR_FAILURE;
    for (PRUint32 i = 0; i < gUsedCIDs; i++)
        if (gCallbacks[i].mScheme.EqualsIgnoreCase(aScheme))
            return NS_ERROR_FAILURE;

    nsCID cid = kProtocolCIDs[gUsedCIDs];
    gCallbacks[gUsedCIDs].mScheme = aScheme;
    gCallbacks[gUsedCIDs].mCallback = aCallback;

    nsModuleComponentInfo &ci = gCallbacks[gUsedCIDs].mComponentInfo;
    memset(&ci, 0, sizeof(ci));
    ci.mDescription = strdup(aDescription);
    ci.mCID = cid;
    ci.mContractID = strdup(contractID.get());
    ci.mConstructor = GeckoProtocolHandlerImpl::Create;

    // Create a factory object which will create the protocol handler on demand
    nsCOMPtr<nsIGenericFactory> factory;
    NS_NewGenericFactory(getter_AddRefs(factory), &ci);

    nsCOMPtr<nsIComponentRegistrar> registrar;
    if (registrar)
        registrar->RegisterFactory(cid, aDescription, contractID.get(), factory);

    return NS_OK;

Here is the call graph for this function:

Here is the caller graph for this function:

The documentation for this class was generated from the following files: