Changeset 56587 in vbox for trunk/src/VBox/Main/src-server
- Timestamp:
- Jun 22, 2015 7:31:59 PM (9 years ago)
- Location:
- trunk/src/VBox/Main/src-server
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/src-server/Performance.cpp
r55988 r56587 1333 1333 } 1334 1334 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>()); 1335 Filter::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>()); 1400 1344 } 1401 1345 else … … 1404 1348 else 1405 1349 { 1406 for (size_t i = 0; i < object Array.size(); ++i)1407 switch ( nameArray.size())1350 for (size_t i = 0; i < objects.size(); ++i) 1351 switch (metricNames.size()) 1408 1352 { 1409 1353 case 0: 1410 processMetricList("*", object Array[i]);1354 processMetricList("*", objects[i]); 1411 1355 break; 1412 1356 case 1: 1413 processMetricList( com::Utf8Str(nameArray[0]), objectArray[i]);1357 processMetricList(metricNames[0], objects[i]); 1414 1358 break; 1415 1359 default: 1416 processMetricList( com::Utf8Str(nameArray[i]), objectArray[i]);1360 processMetricList(metricNames[i], objects[i]); 1417 1361 break; 1418 1362 } 1419 1363 } 1364 } 1365 1366 Filter::Filter(const com::Utf8Str &name, const ComPtr<IUnknown> &aObject) 1367 { 1368 processMetricList(name, aObject); 1420 1369 } 1421 1370 -
trunk/src/VBox/Main/src-server/PerformanceImpl.cpp
r55988 r56587 7 7 8 8 /* 9 * Copyright (C) 2008-201 2Oracle Corporation9 * Copyright (C) 2008-2015 Oracle Corporation 10 10 * 11 11 * This file is part of VirtualBox Open Source Edition (OSE), as … … 190 190 191 191 /* 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)); 196 195 if (RT_FAILURE(vrc)) 197 196 rc = E_FAIL; … … 244 243 245 244 /* 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)); 249 247 m.sampler = NULL; 250 248 … … 263 261 //////////////////////////////////////////////////////////////////////////////// 264 262 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 263 HRESULT PerformanceCollector::getMetricNames(std::vector<com::Utf8Str> &aMetricNames) 264 { 273 265 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 274 266 275 com::SafeArray<BSTR> metricNames(RT_ELEMENTS(g_papcszMetricNames));267 aMetricNames.resize(RT_ELEMENTS(g_papcszMetricNames)); 276 268 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]; 283 270 284 271 return S_OK; … … 288 275 //////////////////////////////////////////////////////////////////////////////// 289 276 290 HRESULT PerformanceCollector::toIPerformanceMetric(pm::Metric *src, IPerformanceMetric **dst)277 HRESULT PerformanceCollector::toIPerformanceMetric(pm::Metric *src, ComPtr<IPerformanceMetric> &dst) 291 278 { 292 279 ComObjPtr<PerformanceMetric> metric; 293 280 HRESULT rc = metric.createObject(); 294 281 if (SUCCEEDED(rc)) 295 rc = metric->init 282 rc = metric->init(src); 296 283 AssertComRCReturnRC(rc); 297 metric.queryInterfaceTo(dst);284 dst = metric; 298 285 return rc; 299 286 } 300 287 301 HRESULT PerformanceCollector::toIPerformanceMetric(pm::BaseMetric *src, IPerformanceMetric **dst)288 HRESULT PerformanceCollector::toIPerformanceMetric(pm::BaseMetric *src, ComPtr<IPerformanceMetric> &dst) 302 289 { 303 290 ComObjPtr<PerformanceMetric> metric; 304 291 HRESULT rc = metric.createObject(); 305 292 if (SUCCEEDED(rc)) 306 rc = metric->init 293 rc = metric->init(src); 307 294 AssertComRCReturnRC(rc); 308 metric.queryInterfaceTo(dst);295 dst = metric; 309 296 return rc; 310 297 } … … 318 305 } 319 306 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 307 HRESULT PerformanceCollector::getMetrics(const std::vector<com::Utf8Str> &aMetricNames, 308 const std::vector<ComPtr<IUnknown> > &aObjects, 309 std::vector<ComPtr<IPerformanceMetric> > &aMetrics) 310 { 327 311 HRESULT rc = S_OK; 328 312 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); 334 314 335 315 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); … … 338 318 MetricList::iterator it; 339 319 for (it = m.metrics.begin(); it != m.metrics.end(); ++it) 340 if (filter.match 341 filteredMetrics.push_back 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()); 344 324 int i = 0; 345 325 for (it = filteredMetrics.begin(); it != filteredMetrics.end(); ++it) … … 348 328 rc = metric.createObject(); 349 329 if (SUCCEEDED(rc)) 350 rc = metric->init 330 rc = metric->init(*it); 351 331 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; 355 334 } 356 retMetrics.detachTo(ComSafeArrayOutArg(outMetrics));357 LogFlowThisFuncLeave();358 335 return rc; 359 336 } 360 337 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)); 338 HRESULT 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); 372 345 373 346 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); … … 379 352 if (filter.match((*it)->getObject(), (*it)->getName())) 380 353 { 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())); 383 356 (*it)->init(aPeriod, aCount); 384 357 if (aPeriod == 0 || aCount == 0) 385 358 { 386 LogFlow 387 359 LogFlow(("PerformanceCollector::SetupMetrics() disabling %s\n", 360 (*it)->getName())); 388 361 rc = (*it)->disable(); 389 362 if (FAILED(rc)) … … 392 365 else 393 366 { 394 LogFlow 395 367 LogFlow(("PerformanceCollector::SetupMetrics() enabling %s\n", 368 (*it)->getName())); 396 369 rc = (*it)->enable(); 397 370 if (FAILED(rc)) … … 401 374 } 402 375 403 com::SafeIfaceArray<IPerformanceMetric> retMetrics(filteredMetrics.size());376 aAffectedMetrics.resize(filteredMetrics.size()); 404 377 int i = 0; 405 378 for (it = filteredMetrics.begin(); 406 379 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++]); 411 381 412 382 if (FAILED(rc)) … … 416 386 } 417 387 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)); 388 HRESULT 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); 427 393 428 394 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); /* Write lock is not needed atm since we are */ … … 442 408 } 443 409 444 com::SafeIfaceArray<IPerformanceMetric> retMetrics(filteredMetrics.size());410 aAffectedMetrics.resize(filteredMetrics.size()); 445 411 int i = 0; 446 412 for (it = filteredMetrics.begin(); 447 413 it != filteredMetrics.end() && SUCCEEDED(rc); ++it) 448 rc = toIPerformanceMetric(*it, &retMetrics[i++]); 449 retMetrics.detachTo(ComSafeArrayOutArg(outMetrics)); 414 rc = toIPerformanceMetric(*it, aAffectedMetrics[i++]); 450 415 451 416 LogFlowThisFuncLeave(); … … 457 422 } 458 423 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)); 424 HRESULT 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); 468 429 469 430 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); /* Write lock is not needed atm since we are */ … … 483 444 } 484 445 485 com::SafeIfaceArray<IPerformanceMetric> retMetrics(filteredMetrics.size());446 aAffectedMetrics.resize(filteredMetrics.size()); 486 447 int i = 0; 487 448 for (it = filteredMetrics.begin(); 488 449 it != filteredMetrics.end() && SUCCEEDED(rc); ++it) 489 rc = toIPerformanceMetric(*it, &retMetrics[i++]); 490 retMetrics.detachTo(ComSafeArrayOutArg(outMetrics)); 450 rc = toIPerformanceMetric(*it, aAffectedMetrics[i++]); 491 451 492 452 LogFlowThisFuncLeave(); … … 498 458 } 499 459 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)); 460 HRESULT 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); 516 472 517 473 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); … … 522 478 MetricList::iterator it; 523 479 for (it = m.metrics.begin(); it != m.metrics.end(); ++it) 524 if (filter.match 480 if (filter.match((*it)->getObject(), (*it)->getName())) 525 481 { 526 filteredMetrics.push_back 482 filteredMetrics.push_back(*it); 527 483 flatSize += (*it)->getLength(); 528 484 } … … 531 487 size_t flatIndex = 0; 532 488 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); 541 497 542 498 for (it = filteredMetrics.begin(); it != filteredMetrics.end(); ++it, ++i) … … 545 501 /* @todo We may want to revise the query method to get rid of excessive alloc/memcpy calls. */ 546 502 (*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)); 550 506 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; 560 514 flatIndex += length; 561 515 } 562 516 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));571 517 return S_OK; 572 518 } … … 584 530 Log7(("{%p} " LOG_FN_FMT ": obj=%p name=%s\n", this, __PRETTY_FUNCTION__, 585 531 (void *)baseMetric->getObject(), baseMetric->getName())); 586 m.baseMetrics.push_back 532 m.baseMetrics.push_back(baseMetric); 587 533 //LogFlowThisFuncLeave(); 588 534 } … … 596 542 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 597 543 Log7(("{%p} " LOG_FN_FMT ": obj=%p name=%s\n", this, __PRETTY_FUNCTION__, (void *)metric->getObject(), metric->getName())); 598 m.metrics.push_back 544 m.metrics.push_back(metric); 599 545 //LogFlowThisFuncLeave(); 600 546 } … … 692 638 uint64_t iTick) 693 639 { 694 AssertReturnVoid 640 AssertReturnVoid(pvUser != NULL); 695 641 PerformanceCollector *collector = static_cast <PerformanceCollector *> (pvUser); 696 642 Assert(collector->mMagic == MAGIC); … … 698 644 collector->samplerCallback(iTick); 699 645 700 NOREF 646 NOREF(hTimerLR); 701 647 } 702 648 … … 775 721 776 722 /* Finally, collect the data */ 777 std::for_each 778 std::mem_fun(&pm::BaseMetric::collect));723 std::for_each(toBeCollected.begin(), toBeCollected.end(), 724 std::mem_fun(&pm::BaseMetric::collect)); 779 725 Log4(("{%p} " LOG_FN_FMT ": LEAVE\n", this, __PRETTY_FUNCTION__)); 780 726 } … … 806 752 LogFlowThisFunc(("\n")); 807 753 808 uninit 754 uninit(); 809 755 810 756 BaseFinalRelease(); … … 816 762 HRESULT PerformanceMetric::init(pm::Metric *aMetric) 817 763 { 764 /* Enclose the state transition NotReady->InInit->Ready */ 765 AutoInitSpan autoInitSpan(this); 766 AssertReturn(autoInitSpan.isOk(), E_FAIL); 767 818 768 m.name = aMetric->getName(); 819 769 m.object = aMetric->getObject(); … … 824 774 m.min = aMetric->getMinValue(); 825 775 m.max = aMetric->getMaxValue(); 776 777 autoInitSpan.setSucceeded(); 826 778 return S_OK; 827 779 } … … 829 781 HRESULT PerformanceMetric::init(pm::BaseMetric *aMetric) 830 782 { 783 /* Enclose the state transition NotReady->InInit->Ready */ 784 AutoInitSpan autoInitSpan(this); 785 AssertReturn(autoInitSpan.isOk(), E_FAIL); 786 831 787 m.name = aMetric->getName(); 832 788 m.object = aMetric->getObject(); … … 837 793 m.min = aMetric->getMinValue(); 838 794 m.max = aMetric->getMaxValue(); 795 796 autoInitSpan.setSucceeded(); 839 797 return S_OK; 840 798 } … … 842 800 void PerformanceMetric::uninit() 843 801 { 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 812 HRESULT PerformanceMetric::getMetricName(com::Utf8Str &aMetricName) 813 { 814 /* this is const, no need to lock */ 815 aMetricName = m.name; 816 return S_OK; 817 } 818 819 HRESULT PerformanceMetric::getObject(ComPtr<IUnknown> &aObject) 820 { 821 /* this is const, no need to lock */ 822 aObject = m.object; 823 return S_OK; 824 } 825 826 HRESULT PerformanceMetric::getDescription(com::Utf8Str &aDescription) 827 { 828 /* this is const, no need to lock */ 829 aDescription = m.description; 830 return S_OK; 831 } 832 833 HRESULT PerformanceMetric::getPeriod(ULONG *aPeriod) 834 { 835 /* this is const, no need to lock */ 869 836 *aPeriod = m.period; 870 837 return S_OK; 871 838 } 872 839 873 STDMETHODIMP PerformanceMetric::COMGETTER(Count)(ULONG *aCount) 874 { 840 HRESULT PerformanceMetric::getCount(ULONG *aCount) 841 { 842 /* this is const, no need to lock */ 875 843 *aCount = m.count; 876 844 return S_OK; 877 845 } 878 846 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; 847 HRESULT PerformanceMetric::getUnit(com::Utf8Str &aUnit) 848 { 849 /* this is const, no need to lock */ 850 aUnit = m.unit; 851 return S_OK; 852 } 853 854 HRESULT PerformanceMetric::getMinimumValue(LONG *aMinimumValue) 855 { 856 /* this is const, no need to lock */ 857 *aMinimumValue = m.min; 858 return S_OK; 859 } 860 861 HRESULT PerformanceMetric::getMaximumValue(LONG *aMaximumValue) 862 { 863 /* this is const, no need to lock */ 864 *aMaximumValue = m.max; 894 865 return S_OK; 895 866 } -
trunk/src/VBox/Main/src-server/xpcom/server.cpp
r55458 r56587 5 5 6 6 /* 7 * Copyright (C) 2004-201 4Oracle Corporation7 * Copyright (C) 2004-2015 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 114 114 NS_IMPL_THREADSAFE_ISUPPORTS1_CI(ProgressProxy, IProgress) 115 115 116 #ifdef VBOX_WITH_USB117 118 #endif119 120 #ifdef VBOX_WITH_RESOURCE_USAGE_API121 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 127 116 //////////////////////////////////////////////////////////////////////////////// 128 117
Note:
See TracChangeset
for help on using the changeset viewer.