VirtualBox

Changeset 1472

Show
Ignore:
Timestamp:
03/14/07 15:59:26 (2 years ago)
Author:
vboxsync
Message:

Main: XPCOM: Initial implementation of auto-startable "out-of-proc" VirtualBox component (VBoxSVC).

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/include/VBox/com/ptr.h

    r1 r1472  
    251251     *  manage a reference to the created object in case of success. 
    252252     */ 
    253     HRESULT createInprocObject (const CLSID &clsid) { 
     253    HRESULT createInprocObject (const CLSID &clsid) 
     254    { 
    254255        HRESULT rc; 
    255256        I *obj = NULL; 
     
    274275     *  to manage a reference to the created object in case of success. 
    275276     * 
    276      *  @param serverName 
    277      *      name of the server to create the object within (Linux only) 
     277     *  Note: In XPCOM, the out-of-process functionality is currently emulated 
     278     *  through in-process wrapper objects (that start a dedicated process and 
     279     *  redirect all object requests to that process). For this reason, this 
     280     *  method is fully equivalent to #createInprocObject() for now. 
    278281     */ 
    279     HRESULT createLocalObject (const CLSID &clsid, const char *serverName) { 
     282    HRESULT createLocalObject (const CLSID &clsid) 
     283    { 
     284#if defined (__WIN__) 
    280285        HRESULT rc; 
    281286        I *obj = NULL; 
    282 #if defined (__WIN__) 
    283287        rc = CoCreateInstance (clsid, NULL, CLSCTX_LOCAL_SERVER, _ATL_IIDOF (I), 
    284288                               (void **) &obj); 
     289        *this = obj; 
     290        if (SUCCEEDED (rc)) 
     291            obj->Release(); 
     292        return rc; 
    285293#else 
     294        return createInprocObject (clsid); 
     295#endif 
     296    } 
     297 
     298#ifdef VBOX_WITH_XPCOM 
     299    /** 
     300     *  Createas an object of the given class ID on the specified server and 
     301     *  starts to manage a reference to the created object in case of success. 
     302     * 
     303     *  @param serverName   Name of the server to create an object within. 
     304     */ 
     305    HRESULT createObjectOnServer (const CLSID &clsid, const char *serverName) 
     306    { 
     307        HRESULT rc; 
     308        I *obj = NULL; 
    286309        nsCOMPtr <ipcIService> ipcServ = do_GetService (IPC_SERVICE_CONTRACTID, &rc); 
    287         if (SUCCEEDED (rc)) { 
     310        if (SUCCEEDED (rc)) 
     311        { 
    288312            PRUint32 serverID = 0; 
    289313            rc = ipcServ->ResolveClientName (serverName, &serverID); 
     
    296320            } 
    297321        } 
    298 #endif 
    299322        *this = obj; 
    300323        if (SUCCEEDED (rc)) 
     
    302325        return rc; 
    303326    } 
     327#endif 
    304328}; 
    305329 

© 2008 Sun Microsystems, Inc.
ContactPrivacy policy