VirtualBox

Changeset 106878 in vbox for trunk/src/VBox/Main


Ignore:
Timestamp:
Nov 8, 2024 8:24:40 AM (4 months ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
165799
Message:

Added global gTrackedObjectsCollector. Added into VirtualBoxBase the members mObjectId, mfTracked and the functions getObjectId(), setTracked(), invalidateTracked().

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

Legend:

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

    r106061 r106878  
    675675#endif // !VBOX_WITH_XPCOM
    676676
    677 
    678677/**
    679678 * Abstract base class for all component classes implementing COM
     
    689688#if !defined (VBOX_WITH_XPCOM)
    690689    , public ISupportErrorInfo
     690#else
     691    , public IUnknown
    691692#endif
    692693{
     
    698699     HRESULT BaseFinalConstruct();
    699700     void BaseFinalRelease();
     701
     702     HRESULT getObjectId(com::Guid &aId);
     703     HRESULT setTracked(uint64_t aLifeTime = 0, uint64_t afterLifeTime = 0);
     704     HRESULT invalidateTracked();
    700705
    701706public:
     
    715720    virtual void uninit()
    716721    { }
     722
     723    /**
     724     */
     725    const Guid &getObjectGuid() const
     726    {
     727        return mObjectId;
     728    }
    717729
    718730    /**
     
    805817
    806818private:
     819    /** Unique ID identifying an object */
     820    const Guid mObjectId;
     821
     822    /** Flag shows whether an object trackable or not */
     823    bool mfTracked;
     824
    807825    /** Object for representing object state */
    808826    ObjectState mState;
     
    11171135
    11181136#endif /* !MAIN_INCLUDED_VirtualBoxBase_h */
    1119 
  • trunk/src/VBox/Main/src-all/VirtualBoxBase.cpp

    r106077 r106878  
    3030#include <iprt/asm.h>
    3131#include <iprt/cpp/exception.h>
     32#include <iprt/cpp/utils.h>
    3233
    3334#include <typeinfo>
     
    4748#include "Global.h"
    4849#include "LoggingNew.h"
     50#include "ObjectsTracker.h"
    4951
    5052#include "VBox/com/ErrorInfo.h"
     
    7981    }
    8082    Assert(g_pClassFactoryStatsLock);
     83
     84    RTUUID uuid;
     85    RTUuidCreate(&uuid);
     86    unconst(mObjectId) = uuid;
    8187}
    8288
     
    170176    else
    171177        Assert(g_pClassFactoryStatsLock);
     178}
     179
     180TrackedObjectsCollector gTrackedObjectsCollector;
     181
     182HRESULT VirtualBoxBase::getObjectId(com::Guid &aId)
     183{
     184    aId = mObjectId;
     185    return S_OK;
     186}
     187
     188HRESULT VirtualBoxBase::setTracked(uint64_t aLifeTime, uint64_t afterLifeTime)
     189{
     190    Utf8Str strObjId = mObjectId.toString();
     191    Utf8Str strClassIID = Guid(getClassIID()).toString();
     192    HRESULT hrc = gTrackedObjectsCollector.setObj(strObjId,
     193                                                  strClassIID,
     194                                                  aLifeTime,
     195                                                  afterLifeTime,
     196                                                  /*ptrVirtualBoxBase,*/
     197                                                  this);
     198    Log2(("VirtualBoxBase::setTracked: inserted the Id %s for component %s with IID %s.\n",
     199         strObjId.c_str(), getComponentName(), strClassIID.c_str()));
     200
     201    return hrc;
     202}
     203
     204HRESULT VirtualBoxBase::invalidateTracked()
     205{
     206    Utf8Str strObjId = mObjectId.toString();
     207    HRESULT hrc = gTrackedObjectsCollector.invalidateObj(strObjId);
     208
     209    return hrc;
    172210}
    173211
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