VirtualBox

Changeset 92878 in vbox


Ignore:
Timestamp:
Dec 13, 2021 9:47:14 AM (3 years ago)
Author:
vboxsync
Message:

Guest Control/Main: Resolved @todos: Renamed (plus removed) SESSIONOBJECTTYPE_ANONYMOUS -> SESSIONOBJECTTYPE_INVALID, use the internal guest object pointer directly to avoid a second lookup based on the object type.

Location:
trunk/src/VBox/Main
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/include/GuestSessionImpl.h

    r92876 r92878  
    242242    enum SESSIONOBJECTTYPE
    243243    {
    244         /** @todo r=bird: The tradition is to start at = 1, leaving 0 for invalid or
    245          * unused to catch uninitialized data.  You do not number the other enum values.
    246          * The 32BIT_HACK is only needed for externally visible stuff that might be used
    247          * by with different compiler options.
    248          *
    249          * As noted elsewhere already, SESSIONOBJECTTYPE_ANONYMOUS isn't used
    250          * anywhere can be removed till such time as it is needed.  Try to not think
    251          * too far ahead but if you do, please leave some more useful clues that
    252          * "Anonymous object" about the intent. */
    253         /** Anonymous object. */
    254         SESSIONOBJECTTYPE_ANONYMOUS  = 0,
     244        /** Invalid session object type. */
     245        SESSIONOBJECTTYPE_INVALID    = 0,
    255246        /** Session object. */
    256247        SESSIONOBJECTTYPE_SESSION    = 1,
     
    260251        SESSIONOBJECTTYPE_FILE       = 3,
    261252        /** Process object. */
    262         SESSIONOBJECTTYPE_PROCESS    = 4,
    263         /** The usual 32-bit hack. */
    264         SESSIONOBJECTTYPE_32BIT_HACK = 0x7fffffff
     253        SESSIONOBJECTTYPE_PROCESS    = 4
    265254    };
    266255
  • trunk/src/VBox/Main/src-client/GuestSessionImpl.cpp

    r92876 r92878  
    12431243    int rc = VERR_NOT_FOUND;
    12441244    const uint32_t idObject = VBOX_GUESTCTRL_CONTEXTID_GET_OBJECT(pCtxCb->uContextID);
    1245     SessionObjects::const_iterator itObjs = mData.mObjects.find(idObject);
    1246     if (itObjs != mData.mObjects.end())
     1245    SessionObjects::const_iterator itObj = mData.mObjects.find(idObject);
     1246    if (itObj != mData.mObjects.end())
    12471247    {
    12481248        /* Set protocol version so that pSvcCb can be interpreted right. */
    12491249        pCtxCb->uProtocol = mData.mProtocolVersion;
    12501250
    1251         /** @todo r=bird: What is the meaning of this secondary lookup?  You've got the
    1252          * object pointer (except for SESSION where it's NULL because GuestSession
    1253          * doesn't inherit from GuestObject), and can just use the type to upcast it to
    1254          * grab a reference then call i_callbackDispatcher.
    1255          *
    1256          * Also, SESSIONOBJECTTYPE_ANONYMOUS is not used to remove it till needed.
    1257          * Don't think too far ahead, and when you do, please express why you think it
    1258          * is needed (the documentation of SESSIONOBJECTTYPE_ANONYMOUS is only repeating
    1259          * the obvious and not enlightening as to why you though it might come in
    1260          * useful).
    1261          */
    1262         switch (itObjs->second.enmType)
    1263         {
    1264             case SESSIONOBJECTTYPE_ANONYMOUS:
    1265                 rc = VERR_NOT_SUPPORTED;
    1266                 break;
    1267 
     1251        switch (itObj->second.enmType)
     1252        {
     1253            /* Note: The session object is special, as it does not inherit from GuestObject we could call
     1254             *       its dispatcher for -- so treat this separately and call it directly. */
    12681255            case SESSIONOBJECTTYPE_SESSION:
    12691256            {
     
    12751262            case SESSIONOBJECTTYPE_DIRECTORY:
    12761263            {
    1277                 SessionDirectories::const_iterator itDir = mData.mDirectories.find(idObject);
    1278                 if (itDir != mData.mDirectories.end())
    1279                 {
    1280                     ComObjPtr<GuestDirectory> pDirectory(itDir->second);
    1281                     Assert(!pDirectory.isNull());
    1282 
    1283                     alock.release();
    1284 
    1285                     rc = pDirectory->i_callbackDispatcher(pCtxCb, pSvcCb);
    1286                 }
     1264                ComObjPtr<GuestDirectory> pObj((GuestDirectory *)itObj->second.pObject);
     1265                AssertReturn(!pObj.isNull(), VERR_INVALID_POINTER);
     1266
     1267                alock.release();
     1268
     1269                rc = pObj->i_callbackDispatcher(pCtxCb, pSvcCb);
    12871270                break;
    12881271            }
    12891272            case SESSIONOBJECTTYPE_FILE:
    12901273            {
    1291                 SessionFiles::const_iterator itFile = mData.mFiles.find(idObject);
    1292                 if (itFile != mData.mFiles.end())
    1293                 {
    1294                     ComObjPtr<GuestFile> pFile(itFile->second);
    1295                     Assert(!pFile.isNull());
    1296 
    1297                     alock.release();
    1298 
    1299                     rc = pFile->i_callbackDispatcher(pCtxCb, pSvcCb);
    1300                 }
     1274                ComObjPtr<GuestFile> pObj((GuestFile *)itObj->second.pObject);
     1275                AssertReturn(!pObj.isNull(), VERR_INVALID_POINTER);
     1276
     1277                alock.release();
     1278
     1279                rc = pObj->i_callbackDispatcher(pCtxCb, pSvcCb);
    13011280                break;
    13021281            }
    13031282            case SESSIONOBJECTTYPE_PROCESS:
    13041283            {
    1305                 SessionProcesses::const_iterator itProc = mData.mProcesses.find(idObject);
    1306                 if (itProc != mData.mProcesses.end())
    1307                 {
    1308                     ComObjPtr<GuestProcess> pProcess(itProc->second);
    1309                     Assert(!pProcess.isNull());
    1310 
    1311                     alock.release();
    1312 
    1313                     rc = pProcess->i_callbackDispatcher(pCtxCb, pSvcCb);
    1314                 }
     1284                ComObjPtr<GuestProcess> pObj((GuestProcess *)itObj->second.pObject);
     1285                AssertReturn(!pObj.isNull(), VERR_INVALID_POINTER);
     1286
     1287                alock.release();
     1288
     1289                rc = pObj->i_callbackDispatcher(pCtxCb, pSvcCb);
    13151290                break;
    13161291            }
    13171292            default:
    1318                 AssertMsgFailed(("%d\n", itObjs->second.enmType));
     1293                AssertMsgFailed(("%d\n", itObj->second.enmType));
    13191294                rc = VERR_INTERNAL_ERROR_4;
    13201295                break;
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette