VirtualBox

Changeset 56587 in vbox for trunk/src/VBox/Main/src-server


Ignore:
Timestamp:
Jun 22, 2015 7:31:59 PM (9 years ago)
Author:
vboxsync
Message:

Main/Performance: convert to API wrapper usage, and quite a bit of cleanup

Location:
trunk/src/VBox/Main/src-server
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/src-server/Performance.cpp

    r55988 r56587  
    13331333}
    13341334
    1335 Filter::Filter(ComSafeArrayIn(IN_BSTR, metricNames),
    1336                ComSafeArrayIn(IUnknown *, objects))
    1337 {
    1338     /*
    1339      * Let's work around null/empty safe array mess. I am not sure there is
    1340      * a way to pass null arrays via webservice, I haven't found one. So I
    1341      * guess the users will be forced to use empty arrays instead. Constructing
    1342      * an empty SafeArray is a bit awkward, so what we do in this method is
    1343      * actually convert null arrays to empty arrays and pass them down to
    1344      * init() method. If someone knows how to do it better, please be my guest,
    1345      * fix it.
    1346      */
    1347     if (ComSafeArrayInIsNull(metricNames))
    1348     {
    1349         com::SafeArray<BSTR> nameArray;
    1350         if (ComSafeArrayInIsNull(objects))
    1351         {
    1352             com::SafeIfaceArray<IUnknown> objectArray;
    1353             objectArray.reset(0);
    1354             init(ComSafeArrayAsInParam(nameArray),
    1355                  ComSafeArrayAsInParam(objectArray));
    1356         }
    1357         else
    1358         {
    1359             com::SafeIfaceArray<IUnknown> objectArray(ComSafeArrayInArg(objects));
    1360             init(ComSafeArrayAsInParam(nameArray),
    1361                  ComSafeArrayAsInParam(objectArray));
    1362         }
    1363     }
    1364     else
    1365     {
    1366         com::SafeArray<IN_BSTR> nameArray(ComSafeArrayInArg(metricNames));
    1367         if (ComSafeArrayInIsNull(objects))
    1368         {
    1369             com::SafeIfaceArray<IUnknown> objectArray;
    1370             objectArray.reset(0);
    1371             init(ComSafeArrayAsInParam(nameArray),
    1372                  ComSafeArrayAsInParam(objectArray));
    1373         }
    1374         else
    1375         {
    1376             com::SafeIfaceArray<IUnknown> objectArray(ComSafeArrayInArg(objects));
    1377             init(ComSafeArrayAsInParam(nameArray),
    1378                  ComSafeArrayAsInParam(objectArray));
    1379         }
    1380     }
    1381 }
    1382 
    1383 Filter::Filter(const com::Utf8Str name, const ComPtr<IUnknown> &aObject)
    1384 {
    1385     processMetricList(name, aObject);
    1386 }
    1387 
    1388 void Filter::init(ComSafeArrayIn(IN_BSTR, metricNames),
    1389                   ComSafeArrayIn(IUnknown *, objects))
    1390 {
    1391     com::SafeArray<IN_BSTR> nameArray(ComSafeArrayInArg(metricNames));
    1392     com::SafeIfaceArray<IUnknown> objectArray(ComSafeArrayInArg(objects));
    1393 
    1394     if (!objectArray.size())
    1395     {
    1396         if (nameArray.size())
    1397         {
    1398             for (size_t i = 0; i < nameArray.size(); ++i)
    1399                 processMetricList(com::Utf8Str(nameArray[i]), ComPtr<IUnknown>());
     1335Filter::Filter(const std::vector<com::Utf8Str> &metricNames,
     1336               const std::vector<ComPtr<IUnknown> > &objects)
     1337{
     1338    if (!objects.size())
     1339    {
     1340        if (metricNames.size())
     1341        {
     1342            for (size_t i = 0; i < metricNames.size(); ++i)
     1343                processMetricList(metricNames[i], ComPtr<IUnknown>());
    14001344        }
    14011345        else
     
    14041348    else
    14051349    {
    1406         for (size_t i = 0; i < objectArray.size(); ++i)
    1407             switch (nameArray.size())
     1350        for (size_t i = 0; i < objects.size(); ++i)
     1351            switch (metricNames.size())
    14081352            {
    14091353                case 0:
    1410                     processMetricList("*", objectArray[i]);
     1354                    processMetricList("*", objects[i]);
    14111355                    break;
    14121356                case 1:
    1413                     processMetricList(com::Utf8Str(nameArray[0]), objectArray[i]);
     1357                    processMetricList(metricNames[0], objects[i]);
    14141358                    break;
    14151359                default:
    1416                     processMetricList(com::Utf8Str(nameArray[i]), objectArray[i]);
     1360                    processMetricList(metricNames[i], objects[i]);
    14171361                    break;
    14181362            }
    14191363    }
     1364}
     1365
     1366Filter::Filter(const com::Utf8Str &name, const ComPtr<IUnknown> &aObject)
     1367{
     1368    processMetricList(name, aObject);
    14201369}
    14211370
  • trunk/src/VBox/Main/src-server/PerformanceImpl.cpp

    r55988 r56587  
    77
    88/*
    9  * Copyright (C) 2008-2012 Oracle Corporation
     9 * Copyright (C) 2008-2015 Oracle Corporation
    1010 *
    1111 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    190190
    191191    /* Start resource usage sampler */
    192     int vrc = RTTimerLRCreate (&m.sampler, VBOX_USAGE_SAMPLER_MIN_INTERVAL,
    193                                &PerformanceCollector::staticSamplerCallback, this);
    194     AssertMsgRC (vrc, ("Failed to create resource usage "
    195                        "sampling timer(%Rra)\n", vrc));
     192    int vrc = RTTimerLRCreate(&m.sampler, VBOX_USAGE_SAMPLER_MIN_INTERVAL,
     193                              &PerformanceCollector::staticSamplerCallback, this);
     194    AssertMsgRC(vrc, ("Failed to create resource usage sampling timer(%Rra)\n", vrc));
    196195    if (RT_FAILURE(vrc))
    197196        rc = E_FAIL;
     
    244243
    245244    /* Destroy resource usage sampler */
    246     int vrc = RTTimerLRDestroy (m.sampler);
    247     AssertMsgRC (vrc, ("Failed to destroy resource usage "
    248                        "sampling timer (%Rra)\n", vrc));
     245    int vrc = RTTimerLRDestroy(m.sampler);
     246    AssertMsgRC(vrc, ("Failed to destroy resource usage sampling timer (%Rra)\n", vrc));
    249247    m.sampler = NULL;
    250248
     
    263261////////////////////////////////////////////////////////////////////////////////
    264262
    265 STDMETHODIMP PerformanceCollector::COMGETTER(MetricNames)(ComSafeArrayOut(BSTR, theMetricNames))
    266 {
    267     if (ComSafeArrayOutIsNull(theMetricNames))
    268         return E_POINTER;
    269 
    270     AutoCaller autoCaller(this);
    271     if (FAILED(autoCaller.rc())) return autoCaller.rc();
    272 
     263HRESULT PerformanceCollector::getMetricNames(std::vector<com::Utf8Str> &aMetricNames)
     264{
    273265    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    274266
    275     com::SafeArray<BSTR> metricNames(RT_ELEMENTS(g_papcszMetricNames));
     267    aMetricNames.resize(RT_ELEMENTS(g_papcszMetricNames));
    276268    for (size_t i = 0; i < RT_ELEMENTS(g_papcszMetricNames); i++)
    277     {
    278         Bstr tmp(g_papcszMetricNames[i]); /* gcc-3.3 cruft */
    279         tmp.cloneTo(&metricNames[i]);
    280     }
    281     //gMetricNames.detachTo(ComSafeArrayOutArg(theMetricNames));
    282     metricNames.detachTo(ComSafeArrayOutArg(theMetricNames));
     269        aMetricNames[i] = g_papcszMetricNames[i];
    283270
    284271    return S_OK;
     
    288275////////////////////////////////////////////////////////////////////////////////
    289276
    290 HRESULT PerformanceCollector::toIPerformanceMetric(pm::Metric *src, IPerformanceMetric **dst)
     277HRESULT PerformanceCollector::toIPerformanceMetric(pm::Metric *src, ComPtr<IPerformanceMetric> &dst)
    291278{
    292279    ComObjPtr<PerformanceMetric> metric;
    293280    HRESULT rc = metric.createObject();
    294281    if (SUCCEEDED(rc))
    295         rc = metric->init (src);
     282        rc = metric->init(src);
    296283    AssertComRCReturnRC(rc);
    297     metric.queryInterfaceTo(dst);
     284    dst = metric;
    298285    return rc;
    299286}
    300287
    301 HRESULT PerformanceCollector::toIPerformanceMetric(pm::BaseMetric *src, IPerformanceMetric **dst)
     288HRESULT PerformanceCollector::toIPerformanceMetric(pm::BaseMetric *src, ComPtr<IPerformanceMetric> &dst)
    302289{
    303290    ComObjPtr<PerformanceMetric> metric;
    304291    HRESULT rc = metric.createObject();
    305292    if (SUCCEEDED(rc))
    306         rc = metric->init (src);
     293        rc = metric->init(src);
    307294    AssertComRCReturnRC(rc);
    308     metric.queryInterfaceTo(dst);
     295    dst = metric;
    309296    return rc;
    310297}
     
    318305}
    319306
    320 STDMETHODIMP PerformanceCollector::GetMetrics(ComSafeArrayIn(IN_BSTR, metricNames),
    321                                               ComSafeArrayIn(IUnknown *, objects),
    322                                               ComSafeArrayOut(IPerformanceMetric *, outMetrics))
    323 {
    324     LogFlowThisFuncEnter();
    325     //LogFlowThisFunc(("mState=%d, mType=%d\n", mState, mType));
    326 
     307HRESULT PerformanceCollector::getMetrics(const std::vector<com::Utf8Str> &aMetricNames,
     308                                         const std::vector<ComPtr<IUnknown> > &aObjects,
     309                                         std::vector<ComPtr<IPerformanceMetric> > &aMetrics)
     310{
    327311    HRESULT rc = S_OK;
    328312
    329     AutoCaller autoCaller(this);
    330     if (FAILED(autoCaller.rc())) return autoCaller.rc();
    331 
    332     pm::Filter filter (ComSafeArrayInArg (metricNames),
    333                        ComSafeArrayInArg (objects));
     313    pm::Filter filter(aMetricNames, aObjects);
    334314
    335315    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
     
    338318    MetricList::iterator it;
    339319    for (it = m.metrics.begin(); it != m.metrics.end(); ++it)
    340         if (filter.match ((*it)->getObject(), (*it)->getName()))
    341             filteredMetrics.push_back (*it);
    342 
    343     com::SafeIfaceArray<IPerformanceMetric> retMetrics (filteredMetrics.size());
     320        if (filter.match((*it)->getObject(), (*it)->getName()))
     321            filteredMetrics.push_back(*it);
     322
     323    aMetrics.resize(filteredMetrics.size());
    344324    int i = 0;
    345325    for (it = filteredMetrics.begin(); it != filteredMetrics.end(); ++it)
     
    348328        rc = metric.createObject();
    349329        if (SUCCEEDED(rc))
    350             rc = metric->init (*it);
     330            rc = metric->init(*it);
    351331        AssertComRCReturnRC(rc);
    352         LogFlow (("PerformanceCollector::GetMetrics() store a metric at "
    353                   "retMetrics[%d]...\n", i));
    354         metric.queryInterfaceTo(&retMetrics[i++]);
     332        LogFlow(("PerformanceCollector::GetMetrics() store a metric at retMetrics[%d]...\n", i));
     333        aMetrics[i++] = metric;
    355334    }
    356     retMetrics.detachTo(ComSafeArrayOutArg(outMetrics));
    357     LogFlowThisFuncLeave();
    358335    return rc;
    359336}
    360337
    361 STDMETHODIMP PerformanceCollector::SetupMetrics(ComSafeArrayIn(IN_BSTR, metricNames),
    362                                                 ComSafeArrayIn(IUnknown *, objects),
    363                                                 ULONG aPeriod,
    364                                                 ULONG aCount,
    365                                                 ComSafeArrayOut(IPerformanceMetric *, outMetrics))
    366 {
    367     AutoCaller autoCaller(this);
    368     if (FAILED(autoCaller.rc())) return autoCaller.rc();
    369 
    370     pm::Filter filter(ComSafeArrayInArg (metricNames),
    371                       ComSafeArrayInArg (objects));
     338HRESULT PerformanceCollector::setupMetrics(const std::vector<com::Utf8Str> &aMetricNames,
     339                                           const std::vector<ComPtr<IUnknown> > &aObjects,
     340                                           ULONG aPeriod,
     341                                           ULONG aCount,
     342                                           std::vector<ComPtr<IPerformanceMetric> > &aAffectedMetrics)
     343{
     344    pm::Filter filter(aMetricNames, aObjects);
    372345
    373346    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
     
    379352        if (filter.match((*it)->getObject(), (*it)->getName()))
    380353        {
    381             LogFlow (("PerformanceCollector::SetupMetrics() setting period to %u,"
    382                       " count to %u for %s\n", aPeriod, aCount, (*it)->getName()));
     354            LogFlow(("PerformanceCollector::SetupMetrics() setting period to %u, count to %u for %s\n",
     355                     aPeriod, aCount, (*it)->getName()));
    383356            (*it)->init(aPeriod, aCount);
    384357            if (aPeriod == 0 || aCount == 0)
    385358            {
    386                 LogFlow (("PerformanceCollector::SetupMetrics() disabling %s\n",
    387                           (*it)->getName()));
     359                LogFlow(("PerformanceCollector::SetupMetrics() disabling %s\n",
     360                         (*it)->getName()));
    388361                rc = (*it)->disable();
    389362                if (FAILED(rc))
     
    392365            else
    393366            {
    394                 LogFlow (("PerformanceCollector::SetupMetrics() enabling %s\n",
    395                           (*it)->getName()));
     367                LogFlow(("PerformanceCollector::SetupMetrics() enabling %s\n",
     368                         (*it)->getName()));
    396369                rc = (*it)->enable();
    397370                if (FAILED(rc))
     
    401374        }
    402375
    403     com::SafeIfaceArray<IPerformanceMetric> retMetrics(filteredMetrics.size());
     376    aAffectedMetrics.resize(filteredMetrics.size());
    404377    int i = 0;
    405378    for (it = filteredMetrics.begin();
    406379         it != filteredMetrics.end() && SUCCEEDED(rc); ++it)
    407         rc = toIPerformanceMetric(*it, &retMetrics[i++]);
    408     retMetrics.detachTo(ComSafeArrayOutArg(outMetrics));
    409 
    410     LogFlowThisFuncLeave();
     380        rc = toIPerformanceMetric(*it, aAffectedMetrics[i++]);
    411381
    412382    if (FAILED(rc))
     
    416386}
    417387
    418 STDMETHODIMP PerformanceCollector::EnableMetrics(ComSafeArrayIn(IN_BSTR, metricNames),
    419                                                  ComSafeArrayIn(IUnknown *, objects),
    420                                                  ComSafeArrayOut(IPerformanceMetric *, outMetrics))
    421 {
    422     AutoCaller autoCaller(this);
    423     if (FAILED(autoCaller.rc())) return autoCaller.rc();
    424 
    425     pm::Filter filter(ComSafeArrayInArg(metricNames),
    426                       ComSafeArrayInArg(objects));
     388HRESULT PerformanceCollector::enableMetrics(const std::vector<com::Utf8Str> &aMetricNames,
     389                                            const std::vector<ComPtr<IUnknown> > &aObjects,
     390                                            std::vector<ComPtr<IPerformanceMetric> > &aAffectedMetrics)
     391{
     392    pm::Filter filter(aMetricNames, aObjects);
    427393
    428394    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); /* Write lock is not needed atm since we are */
     
    442408        }
    443409
    444     com::SafeIfaceArray<IPerformanceMetric> retMetrics(filteredMetrics.size());
     410    aAffectedMetrics.resize(filteredMetrics.size());
    445411    int i = 0;
    446412    for (it = filteredMetrics.begin();
    447413         it != filteredMetrics.end() && SUCCEEDED(rc); ++it)
    448         rc = toIPerformanceMetric(*it, &retMetrics[i++]);
    449     retMetrics.detachTo(ComSafeArrayOutArg(outMetrics));
     414        rc = toIPerformanceMetric(*it, aAffectedMetrics[i++]);
    450415
    451416    LogFlowThisFuncLeave();
     
    457422}
    458423
    459 STDMETHODIMP PerformanceCollector::DisableMetrics(ComSafeArrayIn(IN_BSTR, metricNames),
    460                                                   ComSafeArrayIn(IUnknown *, objects),
    461                                                   ComSafeArrayOut(IPerformanceMetric *, outMetrics))
    462 {
    463     AutoCaller autoCaller(this);
    464     if (FAILED(autoCaller.rc())) return autoCaller.rc();
    465 
    466     pm::Filter filter(ComSafeArrayInArg(metricNames),
    467                       ComSafeArrayInArg(objects));
     424HRESULT PerformanceCollector::disableMetrics(const std::vector<com::Utf8Str> &aMetricNames,
     425                                             const std::vector<ComPtr<IUnknown> > &aObjects,
     426                                             std::vector<ComPtr<IPerformanceMetric> > &aAffectedMetrics)
     427{
     428    pm::Filter filter(aMetricNames, aObjects);
    468429
    469430    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); /* Write lock is not needed atm since we are */
     
    483444        }
    484445
    485     com::SafeIfaceArray<IPerformanceMetric> retMetrics(filteredMetrics.size());
     446    aAffectedMetrics.resize(filteredMetrics.size());
    486447    int i = 0;
    487448    for (it = filteredMetrics.begin();
    488449         it != filteredMetrics.end() && SUCCEEDED(rc); ++it)
    489         rc = toIPerformanceMetric(*it, &retMetrics[i++]);
    490     retMetrics.detachTo(ComSafeArrayOutArg(outMetrics));
     450        rc = toIPerformanceMetric(*it, aAffectedMetrics[i++]);
    491451
    492452    LogFlowThisFuncLeave();
     
    498458}
    499459
    500 STDMETHODIMP PerformanceCollector::QueryMetricsData(ComSafeArrayIn (IN_BSTR, metricNames),
    501                                                     ComSafeArrayIn (IUnknown *, objects),
    502                                                     ComSafeArrayOut(BSTR, outMetricNames),
    503                                                     ComSafeArrayOut(IUnknown *, outObjects),
    504                                                     ComSafeArrayOut(BSTR, outUnits),
    505                                                     ComSafeArrayOut(ULONG, outScales),
    506                                                     ComSafeArrayOut(ULONG, outSequenceNumbers),
    507                                                     ComSafeArrayOut(ULONG, outDataIndices),
    508                                                     ComSafeArrayOut(ULONG, outDataLengths),
    509                                                     ComSafeArrayOut(LONG, outData))
    510 {
    511     AutoCaller autoCaller(this);
    512     if (FAILED(autoCaller.rc())) return autoCaller.rc();
    513 
    514     pm::Filter filter(ComSafeArrayInArg(metricNames),
    515                       ComSafeArrayInArg(objects));
     460HRESULT PerformanceCollector::queryMetricsData(const std::vector<com::Utf8Str> &aMetricNames,
     461                                               const std::vector<ComPtr<IUnknown> > &aObjects,
     462                                               std::vector<com::Utf8Str> &aReturnMetricNames,
     463                                               std::vector<ComPtr<IUnknown> > &aReturnObjects,
     464                                               std::vector<com::Utf8Str> &aReturnUnits,
     465                                               std::vector<ULONG> &aReturnScales,
     466                                               std::vector<ULONG> &aReturnSequenceNumbers,
     467                                               std::vector<ULONG> &aReturnDataIndices,
     468                                               std::vector<ULONG> &aReturnDataLengths,
     469                                               std::vector<LONG> &aReturnData)
     470{
     471    pm::Filter filter(aMetricNames, aObjects);
    516472
    517473    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
     
    522478    MetricList::iterator it;
    523479    for (it = m.metrics.begin(); it != m.metrics.end(); ++it)
    524         if (filter.match ((*it)->getObject(), (*it)->getName()))
     480        if (filter.match((*it)->getObject(), (*it)->getName()))
    525481        {
    526             filteredMetrics.push_back (*it);
     482            filteredMetrics.push_back(*it);
    527483            flatSize += (*it)->getLength();
    528484        }
     
    531487    size_t flatIndex = 0;
    532488    size_t numberOfMetrics = filteredMetrics.size();
    533     com::SafeArray<BSTR> retNames(numberOfMetrics);
    534     com::SafeIfaceArray<IUnknown> retObjects(numberOfMetrics);
    535     com::SafeArray<BSTR> retUnits(numberOfMetrics);
    536     com::SafeArray<ULONG> retScales(numberOfMetrics);
    537     com::SafeArray<ULONG> retSequenceNumbers(numberOfMetrics);
    538     com::SafeArray<ULONG> retIndices(numberOfMetrics);
    539     com::SafeArray<ULONG> retLengths(numberOfMetrics);
    540     com::SafeArray<LONG> retData(flatSize);
     489    aReturnMetricNames.resize(numberOfMetrics);
     490    aReturnObjects.resize(numberOfMetrics);
     491    aReturnUnits.resize(numberOfMetrics);
     492    aReturnScales.resize(numberOfMetrics);
     493    aReturnSequenceNumbers.resize(numberOfMetrics);
     494    aReturnDataIndices.resize(numberOfMetrics);
     495    aReturnDataLengths.resize(numberOfMetrics);
     496    aReturnData.resize(flatSize);
    541497
    542498    for (it = filteredMetrics.begin(); it != filteredMetrics.end(); ++it, ++i)
     
    545501        /* @todo We may want to revise the query method to get rid of excessive alloc/memcpy calls. */
    546502        (*it)->query(&values, &length, &sequenceNumber);
    547         LogFlow (("PerformanceCollector::QueryMetricsData() querying metric %s "
    548                   "returned %d values.\n", (*it)->getName(), length));
    549         memcpy(retData.raw() + flatIndex, values, length * sizeof(*values));
     503        LogFlow(("PerformanceCollector::QueryMetricsData() querying metric %s returned %d values.\n",
     504                 (*it)->getName(), length));
     505        memcpy(&aReturnData[flatIndex], values, length * sizeof(*values));
    550506        RTMemFree(values);
    551         Bstr tmp((*it)->getName());
    552         tmp.detachTo(&retNames[i]);
    553         (*it)->getObject().queryInterfaceTo(&retObjects[i]);
    554         tmp = (*it)->getUnit();
    555         tmp.detachTo(&retUnits[i]);
    556         retScales[i] = (*it)->getScale();
    557         retSequenceNumbers[i] = sequenceNumber;
    558         retLengths[i] = length;
    559         retIndices[i] = (ULONG)flatIndex;
     507        aReturnMetricNames[i] = (*it)->getName();
     508        aReturnObjects[i] = (*it)->getObject();
     509        aReturnUnits[i] = (*it)->getUnit();
     510        aReturnScales[i] = (*it)->getScale();
     511        aReturnSequenceNumbers[i] = sequenceNumber;
     512        aReturnDataIndices[i] = (ULONG)flatIndex;
     513        aReturnDataLengths[i] = length;
    560514        flatIndex += length;
    561515    }
    562516
    563     retNames.detachTo(ComSafeArrayOutArg(outMetricNames));
    564     retObjects.detachTo(ComSafeArrayOutArg(outObjects));
    565     retUnits.detachTo(ComSafeArrayOutArg(outUnits));
    566     retScales.detachTo(ComSafeArrayOutArg(outScales));
    567     retSequenceNumbers.detachTo(ComSafeArrayOutArg(outSequenceNumbers));
    568     retIndices.detachTo(ComSafeArrayOutArg(outDataIndices));
    569     retLengths.detachTo(ComSafeArrayOutArg(outDataLengths));
    570     retData.detachTo(ComSafeArrayOutArg(outData));
    571517    return S_OK;
    572518}
     
    584530    Log7(("{%p} " LOG_FN_FMT ": obj=%p name=%s\n", this, __PRETTY_FUNCTION__,
    585531          (void *)baseMetric->getObject(), baseMetric->getName()));
    586     m.baseMetrics.push_back (baseMetric);
     532    m.baseMetrics.push_back(baseMetric);
    587533    //LogFlowThisFuncLeave();
    588534}
     
    596542    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    597543    Log7(("{%p} " LOG_FN_FMT ": obj=%p name=%s\n", this, __PRETTY_FUNCTION__, (void *)metric->getObject(), metric->getName()));
    598     m.metrics.push_back (metric);
     544    m.metrics.push_back(metric);
    599545    //LogFlowThisFuncLeave();
    600546}
     
    692638                                                 uint64_t iTick)
    693639{
    694     AssertReturnVoid (pvUser != NULL);
     640    AssertReturnVoid(pvUser != NULL);
    695641    PerformanceCollector *collector = static_cast <PerformanceCollector *> (pvUser);
    696642    Assert(collector->mMagic == MAGIC);
     
    698644        collector->samplerCallback(iTick);
    699645
    700     NOREF (hTimerLR);
     646    NOREF(hTimerLR);
    701647}
    702648
     
    775721
    776722    /* Finally, collect the data */
    777     std::for_each (toBeCollected.begin(), toBeCollected.end(),
    778                    std::mem_fun (&pm::BaseMetric::collect));
     723    std::for_each(toBeCollected.begin(), toBeCollected.end(),
     724                  std::mem_fun(&pm::BaseMetric::collect));
    779725    Log4(("{%p} " LOG_FN_FMT ": LEAVE\n", this, __PRETTY_FUNCTION__));
    780726}
     
    806752    LogFlowThisFunc(("\n"));
    807753
    808     uninit ();
     754    uninit();
    809755
    810756    BaseFinalRelease();
     
    816762HRESULT PerformanceMetric::init(pm::Metric *aMetric)
    817763{
     764    /* Enclose the state transition NotReady->InInit->Ready */
     765    AutoInitSpan autoInitSpan(this);
     766    AssertReturn(autoInitSpan.isOk(), E_FAIL);
     767
    818768    m.name        = aMetric->getName();
    819769    m.object      = aMetric->getObject();
     
    824774    m.min         = aMetric->getMinValue();
    825775    m.max         = aMetric->getMaxValue();
     776
     777    autoInitSpan.setSucceeded();
    826778    return S_OK;
    827779}
     
    829781HRESULT PerformanceMetric::init(pm::BaseMetric *aMetric)
    830782{
     783    /* Enclose the state transition NotReady->InInit->Ready */
     784    AutoInitSpan autoInitSpan(this);
     785    AssertReturn(autoInitSpan.isOk(), E_FAIL);
     786
    831787    m.name        = aMetric->getName();
    832788    m.object      = aMetric->getObject();
     
    837793    m.min         = aMetric->getMinValue();
    838794    m.max         = aMetric->getMaxValue();
     795
     796    autoInitSpan.setSucceeded();
    839797    return S_OK;
    840798}
     
    842800void PerformanceMetric::uninit()
    843801{
    844 }
    845 
    846 STDMETHODIMP PerformanceMetric::COMGETTER(MetricName)(BSTR *aMetricName)
    847 {
    848     /// @todo (r=dmik) why do all these getters not do AutoCaller and
    849     /// AutoReadLock? Is the underlying metric a constant object?
    850 
    851     m.name.cloneTo(aMetricName);
    852     return S_OK;
    853 }
    854 
    855 STDMETHODIMP PerformanceMetric::COMGETTER(Object)(IUnknown **anObject)
    856 {
    857     m.object.queryInterfaceTo(anObject);
    858     return S_OK;
    859 }
    860 
    861 STDMETHODIMP PerformanceMetric::COMGETTER(Description)(BSTR *aDescription)
    862 {
    863     m.description.cloneTo(aDescription);
    864     return S_OK;
    865 }
    866 
    867 STDMETHODIMP PerformanceMetric::COMGETTER(Period)(ULONG *aPeriod)
    868 {
     802    /* Enclose the state transition Ready->InUninit->NotReady */
     803    AutoUninitSpan autoUninitSpan(this);
     804    if (autoUninitSpan.uninitDone())
     805    {
     806        LogFlowThisFunc(("Already uninitialized.\n"));
     807        LogFlowThisFuncLeave();
     808        return;
     809    }
     810}
     811
     812HRESULT PerformanceMetric::getMetricName(com::Utf8Str &aMetricName)
     813{
     814    /* this is const, no need to lock */
     815    aMetricName = m.name;
     816    return S_OK;
     817}
     818
     819HRESULT PerformanceMetric::getObject(ComPtr<IUnknown> &aObject)
     820{
     821    /* this is const, no need to lock */
     822    aObject = m.object;
     823    return S_OK;
     824}
     825
     826HRESULT PerformanceMetric::getDescription(com::Utf8Str &aDescription)
     827{
     828    /* this is const, no need to lock */
     829    aDescription = m.description;
     830    return S_OK;
     831}
     832
     833HRESULT PerformanceMetric::getPeriod(ULONG *aPeriod)
     834{
     835    /* this is const, no need to lock */
    869836    *aPeriod = m.period;
    870837    return S_OK;
    871838}
    872839
    873 STDMETHODIMP PerformanceMetric::COMGETTER(Count)(ULONG *aCount)
    874 {
     840HRESULT PerformanceMetric::getCount(ULONG *aCount)
     841{
     842    /* this is const, no need to lock */
    875843    *aCount = m.count;
    876844    return S_OK;
    877845}
    878846
    879 STDMETHODIMP PerformanceMetric::COMGETTER(Unit)(BSTR *aUnit)
    880 {
    881     m.unit.cloneTo(aUnit);
    882     return S_OK;
    883 }
    884 
    885 STDMETHODIMP PerformanceMetric::COMGETTER(MinimumValue)(LONG *aMinValue)
    886 {
    887     *aMinValue = m.min;
    888     return S_OK;
    889 }
    890 
    891 STDMETHODIMP PerformanceMetric::COMGETTER(MaximumValue)(LONG *aMaxValue)
    892 {
    893     *aMaxValue = m.max;
     847HRESULT PerformanceMetric::getUnit(com::Utf8Str &aUnit)
     848{
     849    /* this is const, no need to lock */
     850    aUnit = m.unit;
     851    return S_OK;
     852}
     853
     854HRESULT PerformanceMetric::getMinimumValue(LONG *aMinimumValue)
     855{
     856    /* this is const, no need to lock */
     857    *aMinimumValue = m.min;
     858    return S_OK;
     859}
     860
     861HRESULT PerformanceMetric::getMaximumValue(LONG *aMaximumValue)
     862{
     863    /* this is const, no need to lock */
     864    *aMaximumValue = m.max;
    894865    return S_OK;
    895866}
  • trunk/src/VBox/Main/src-server/xpcom/server.cpp

    r55458 r56587  
    55
    66/*
    7  * Copyright (C) 2004-2014 Oracle Corporation
     7 * Copyright (C) 2004-2015 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    114114NS_IMPL_THREADSAFE_ISUPPORTS1_CI(ProgressProxy, IProgress)
    115115
    116 #ifdef VBOX_WITH_USB
    117 
    118 #endif
    119 
    120 #ifdef VBOX_WITH_RESOURCE_USAGE_API
    121 NS_DECL_CLASSINFO(PerformanceCollector)
    122 NS_IMPL_THREADSAFE_ISUPPORTS1_CI(PerformanceCollector, IPerformanceCollector)
    123 NS_DECL_CLASSINFO(PerformanceMetric)
    124 NS_IMPL_THREADSAFE_ISUPPORTS1_CI(PerformanceMetric, IPerformanceMetric)
    125 #endif /* VBOX_WITH_RESOURCE_USAGE_API */
    126 
    127116////////////////////////////////////////////////////////////////////////////////
    128117
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