VirtualBox

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


Ignore:
Timestamp:
Nov 25, 2009 4:02:32 PM (15 years ago)
Author:
vboxsync
Message:

Main: Added a timeout property to IProgress that can be used to automatically time out an operation. This is to make life simpler on the client side.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/ProgressImpl.cpp

    r23827 r24961  
    6060    mResultCode = S_OK;
    6161
    62     m_cOperations =
    63     m_ulTotalOperationsWeight =
    64     m_ulOperationsCompletedWeight =
    65     m_ulCurrentOperation =
    66     m_ulCurrentOperationWeight =
    67     m_ulOperationPercent = 0;
     62    m_cOperations
     63        = m_ulTotalOperationsWeight
     64        = m_ulOperationsCompletedWeight
     65        = m_ulCurrentOperation
     66        = m_ulCurrentOperationWeight
     67        = m_ulOperationPercent
     68        = m_cMsTimeout
     69        = 0;
    6870
    6971    // get creation timestamp
     
    467469        *aOperationPercent = m_ulOperationPercent;
    468470
     471    return S_OK;
     472}
     473
     474STDMETHODIMP ProgressBase::COMSETTER(Timeout)(ULONG aTimeout)
     475{
     476    AutoCaller autoCaller(this);
     477    CheckComRCReturnRC(autoCaller.rc());
     478
     479    AutoWriteLock alock(this);
     480
     481    if (!mCancelable)
     482        return setError(VBOX_E_INVALID_OBJECT_STATE,
     483                        tr("Operation cannot be canceled"));
     484
     485    LogThisFunc(("%#x => %#x\n", m_cMsTimeout, aTimeout));
     486    m_cMsTimeout = aTimeout;
     487    return S_OK;
     488}
     489
     490STDMETHODIMP ProgressBase::COMGETTER(Timeout)(ULONG *aTimeout)
     491{
     492    CheckComArgOutPointerValid(aTimeout);
     493
     494    AutoCaller autoCaller(this);
     495    CheckComRCReturnRC(autoCaller.rc());
     496
     497    AutoReadLock alock(this);
     498
     499    *aTimeout = m_cMsTimeout;
    469500    return S_OK;
    470501}
     
    14721503}
    14731504
     1505STDMETHODIMP CombinedProgress::COMSETTER(Timeout)(ULONG aTimeout)
     1506{
     1507    NOREF(aTimeout);
     1508    AssertFailed();
     1509    return E_NOTIMPL;
     1510}
     1511
     1512STDMETHODIMP CombinedProgress::COMGETTER(Timeout)(ULONG *aTimeout)
     1513{
     1514    CheckComArgOutPointerValid(aTimeout);
     1515
     1516    AssertFailed();
     1517    return E_NOTIMPL;
     1518}
     1519
    14741520// IProgress methods
    14751521/////////////////////////////////////////////////////////////////////////////
  • trunk/src/VBox/Main/idl/VirtualBox.xidl

    r24923 r24961  
    82968296  <interface
    82978297     name="IProgress" extends="$unknown"
    8298      uuid="62827ef1-c098-40eb-be96-36d0508489a6"
     8298     uuid="856aa038-853f-42e2-acf7-6e7b02dbe294"
    82998299     wsmap="managed"
    83008300     >
     
    84188418    <attribute name="operationPercent" type="unsigned long" readonly="yes">
    84198419        <desc>Progress value of the current sub-operation only, in percent.</desc>
     8420    </attribute>
     8421
     8422    <attribute name="timeout" type="unsigned long">
     8423      <desc>
     8424          When non-zero, this specifies the number of milliseconds after which
     8425          the operation will automatically be canceled.  This can only be set on
     8426          cancelable objects.
     8427      </desc>
    84208428    </attribute>
    84218429
  • trunk/src/VBox/Main/include/ProgressImpl.h

    r23827 r24961  
    8282    STDMETHOD(COMGETTER(OperationDescription)) (BSTR *aOperationDescription);
    8383    STDMETHOD(COMGETTER(OperationPercent)) (ULONG *aOperationPercent);
     84    STDMETHOD(COMSETTER(Timeout)) (ULONG aTimeout);
     85    STDMETHOD(COMGETTER(Timeout)) (ULONG *aTimeout);
    8486
    8587    // public methods only for internal purposes
     
    130132    ULONG m_ulCurrentOperationWeight;               // weight of current operation, given to setNextOperation()
    131133    ULONG m_ulOperationPercent;                     // percentage of current operation, set with setCurrentOperationProgress()
     134    ULONG m_cMsTimeout;                             /**< Automatic timeout value. 0 means none. */
    132135};
    133136
     
    409412    STDMETHOD(COMGETTER(OperationDescription)) (BSTR *aOperationDescription);
    410413    STDMETHOD(COMGETTER(OperationPercent)) (ULONG *aOperationPercent);
     414    STDMETHOD(COMSETTER(Timeout)) (ULONG aTimeout);
     415    STDMETHOD(COMGETTER(Timeout)) (ULONG *aTimeout);
    411416
    412417    // IProgress methods
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