Index: trunk/src/VBox/Main/ProgressImpl.cpp
===================================================================
--- trunk/src/VBox/Main/ProgressImpl.cpp	(revision 31625)
+++ trunk/src/VBox/Main/ProgressImpl.cpp	(revision 32780)
@@ -6,5 +6,5 @@
 
 /*
- * Copyright (C) 2006-2009 Oracle Corporation
+ * Copyright (C) 2006-2010 Oracle Corporation
  *
  * This file is part of VirtualBox Open Source Edition (OSE), as
@@ -19,9 +19,9 @@
 #include <iprt/types.h>
 
-#if defined (VBOX_WITH_XPCOM)
+#if defined(VBOX_WITH_XPCOM)
 #include <nsIServiceManager.h>
 #include <nsIExceptionService.h>
 #include <nsCOMPtr.h>
-#endif /* defined (VBOX_WITH_XPCOM) */
+#endif /* defined(VBOX_WITH_XPCOM) */
 
 #include "ProgressCombinedImpl.h"
@@ -46,5 +46,5 @@
 
 ProgressBase::ProgressBase()
-#if !defined (VBOX_COM_INPROC)
+#if !defined(VBOX_COM_INPROC)
     : mParent(NULL)
 #endif
@@ -105,5 +105,5 @@
  */
 HRESULT ProgressBase::protectedInit(AutoInitSpan &aAutoInitSpan,
-#if !defined (VBOX_COM_INPROC)
+#if !defined(VBOX_COM_INPROC)
                                     VirtualBox *aParent,
 #endif
@@ -113,10 +113,10 @@
 {
     /* Guarantees subclasses call this method at the proper time */
-    NOREF (aAutoInitSpan);
+    NOREF(aAutoInitSpan);
 
     AutoCaller autoCaller(this);
     AssertReturn(autoCaller.state() == InInit, E_FAIL);
 
-#if !defined (VBOX_COM_INPROC)
+#if !defined(VBOX_COM_INPROC)
     AssertReturn(aParent, E_INVALIDARG);
 #else
@@ -126,10 +126,10 @@
     AssertReturn(aDescription, E_INVALIDARG);
 
-#if !defined (VBOX_COM_INPROC)
+#if !defined(VBOX_COM_INPROC)
     /* share parent weakly */
     unconst(mParent) = aParent;
 #endif
 
-#if !defined (VBOX_COM_INPROC)
+#if !defined(VBOX_COM_INPROC)
     /* assign (and therefore addref) initiator only if it is not VirtualBox
      * (to avoid cycling); otherwise mInitiator will remain null which means
@@ -149,5 +149,5 @@
         mId.cloneTo(aId);
 
-#if !defined (VBOX_COM_INPROC)
+#if !defined(VBOX_COM_INPROC)
     /* add to the global collection of progress operations (note: after
      * creating mId) */
@@ -173,8 +173,8 @@
  * @param aAutoInitSpan AutoInitSpan object instantiated by a subclass.
  */
-HRESULT ProgressBase::protectedInit (AutoInitSpan &aAutoInitSpan)
+HRESULT ProgressBase::protectedInit(AutoInitSpan &aAutoInitSpan)
 {
     /* Guarantees subclasses call this method at the proper time */
-    NOREF (aAutoInitSpan);
+    NOREF(aAutoInitSpan);
 
     return S_OK;
@@ -190,5 +190,5 @@
  * @note Using the mParent member after this method returns is forbidden.
  */
-void ProgressBase::protectedUninit (AutoUninitSpan &aAutoUninitSpan)
+void ProgressBase::protectedUninit(AutoUninitSpan &aAutoUninitSpan)
 {
     /* release initiator (effective only if mInitiator has been assigned in
@@ -196,10 +196,10 @@
     unconst(mInitiator).setNull();
 
-#if !defined (VBOX_COM_INPROC)
+#if !defined(VBOX_COM_INPROC)
     if (mParent)
     {
         /* remove the added progress on failure to complete the initialization */
         if (aAutoUninitSpan.initFailed() && !mId.isEmpty())
-            mParent->removeProgress (mId);
+            mParent->removeProgress(mId.ref());
 
         unconst(mParent) = NULL;
@@ -211,5 +211,5 @@
 /////////////////////////////////////////////////////////////////////////////
 
-STDMETHODIMP ProgressBase::COMGETTER(Id) (BSTR *aId)
+STDMETHODIMP ProgressBase::COMGETTER(Id)(BSTR *aId)
 {
     CheckComArgOutPointerValid(aId);
@@ -224,5 +224,5 @@
 }
 
-STDMETHODIMP ProgressBase::COMGETTER(Description) (BSTR *aDescription)
+STDMETHODIMP ProgressBase::COMGETTER(Description)(BSTR *aDescription)
 {
     CheckComArgOutPointerValid(aDescription);
@@ -237,5 +237,5 @@
 }
 
-STDMETHODIMP ProgressBase::COMGETTER(Initiator) (IUnknown **aInitiator)
+STDMETHODIMP ProgressBase::COMGETTER(Initiator)(IUnknown **aInitiator)
 {
     CheckComArgOutPointerValid(aInitiator);
@@ -246,5 +246,5 @@
     /* mInitiator/mParent are constant during life time, no need to lock */
 
-#if !defined (VBOX_COM_INPROC)
+#if !defined(VBOX_COM_INPROC)
     if (mInitiator)
         mInitiator.queryInterfaceTo(aInitiator);
@@ -261,5 +261,5 @@
 }
 
-STDMETHODIMP ProgressBase::COMGETTER(Cancelable) (BOOL *aCancelable)
+STDMETHODIMP ProgressBase::COMGETTER(Cancelable)(BOOL *aCancelable)
 {
     CheckComArgOutPointerValid(aCancelable);
@@ -379,5 +379,5 @@
 }
 
-STDMETHODIMP ProgressBase::COMGETTER(Completed) (BOOL *aCompleted)
+STDMETHODIMP ProgressBase::COMGETTER(Completed)(BOOL *aCompleted)
 {
     CheckComArgOutPointerValid(aCompleted);
@@ -393,5 +393,5 @@
 }
 
-STDMETHODIMP ProgressBase::COMGETTER(Canceled) (BOOL *aCanceled)
+STDMETHODIMP ProgressBase::COMGETTER(Canceled)(BOOL *aCanceled)
 {
     CheckComArgOutPointerValid(aCanceled);
@@ -407,5 +407,5 @@
 }
 
-STDMETHODIMP ProgressBase::COMGETTER(ResultCode) (LONG *aResultCode)
+STDMETHODIMP ProgressBase::COMGETTER(ResultCode)(LONG *aResultCode)
 {
     CheckComArgOutPointerValid(aResultCode);
@@ -425,5 +425,5 @@
 }
 
-STDMETHODIMP ProgressBase::COMGETTER(ErrorInfo) (IVirtualBoxErrorInfo **aErrorInfo)
+STDMETHODIMP ProgressBase::COMGETTER(ErrorInfo)(IVirtualBoxErrorInfo **aErrorInfo)
 {
     CheckComArgOutPointerValid(aErrorInfo);
@@ -443,5 +443,5 @@
 }
 
-STDMETHODIMP ProgressBase::COMGETTER(OperationCount) (ULONG *aOperationCount)
+STDMETHODIMP ProgressBase::COMGETTER(OperationCount)(ULONG *aOperationCount)
 {
     CheckComArgOutPointerValid(aOperationCount);
@@ -457,5 +457,5 @@
 }
 
-STDMETHODIMP ProgressBase::COMGETTER(Operation) (ULONG *aOperation)
+STDMETHODIMP ProgressBase::COMGETTER(Operation)(ULONG *aOperation)
 {
     CheckComArgOutPointerValid(aOperation);
@@ -471,5 +471,5 @@
 }
 
-STDMETHODIMP ProgressBase::COMGETTER(OperationDescription) (BSTR *aOperationDescription)
+STDMETHODIMP ProgressBase::COMGETTER(OperationDescription)(BSTR *aOperationDescription)
 {
     CheckComArgOutPointerValid(aOperationDescription);
@@ -647,16 +647,16 @@
  * @param aId               See ProgressBase::init().
  */
-HRESULT Progress::init (
-#if !defined (VBOX_COM_INPROC)
-                        VirtualBox *aParent,
+HRESULT Progress::init(
+#if !defined(VBOX_COM_INPROC)
+                       VirtualBox *aParent,
 #endif
-                        IUnknown *aInitiator,
-                        CBSTR aDescription,
-                        BOOL aCancelable,
-                        ULONG cOperations,
-                        ULONG ulTotalOperationsWeight,
-                        CBSTR bstrFirstOperationDescription,
-                        ULONG ulFirstOperationWeight,
-                        OUT_GUID aId /* = NULL */)
+                       IUnknown *aInitiator,
+                       CBSTR aDescription,
+                       BOOL aCancelable,
+                       ULONG cOperations,
+                       ULONG ulTotalOperationsWeight,
+                       CBSTR bstrFirstOperationDescription,
+                       ULONG ulFirstOperationWeight,
+                       OUT_GUID aId /* = NULL */)
 {
     LogFlowThisFunc(("aDescription=\"%ls\", cOperations=%d, ulTotalOperationsWeight=%d, bstrFirstOperationDescription=\"%ls\", ulFirstOperationWeight=%d\n",
@@ -676,9 +676,9 @@
     HRESULT rc = S_OK;
 
-    rc = ProgressBase::protectedInit (autoInitSpan,
-#if !defined (VBOX_COM_INPROC)
-                                      aParent,
+    rc = ProgressBase::protectedInit(autoInitSpan,
+#if !defined(VBOX_COM_INPROC)
+                                     aParent,
 #endif
-                                      aInitiator, aDescription, aId);
+                                     aInitiator, aDescription, aId);
     if (FAILED(rc)) return rc;
 
@@ -693,8 +693,8 @@
     m_ulOperationPercent = 0;
 
-    int vrc = RTSemEventMultiCreate (&mCompletedSem);
-    ComAssertRCRet (vrc, E_FAIL);
-
-    RTSemEventMultiReset (mCompletedSem);
+    int vrc = RTSemEventMultiCreate(&mCompletedSem);
+    ComAssertRCRet(vrc, E_FAIL);
+
+    RTSemEventMultiReset(mCompletedSem);
 
     /* Confirm a successful initialization when it's the case */
@@ -732,5 +732,5 @@
     HRESULT rc = S_OK;
 
-    rc = ProgressBase::protectedInit (autoInitSpan);
+    rc = ProgressBase::protectedInit(autoInitSpan);
     if (FAILED(rc)) return rc;
 
@@ -747,8 +747,8 @@
     m_ulOperationPercent = 0;
 
-    int vrc = RTSemEventMultiCreate (&mCompletedSem);
-    ComAssertRCRet (vrc, E_FAIL);
-
-    RTSemEventMultiReset (mCompletedSem);
+    int vrc = RTSemEventMultiCreate(&mCompletedSem);
+    ComAssertRCRet(vrc, E_FAIL);
+
+    RTSemEventMultiReset(mCompletedSem);
 
     /* Confirm a successful initialization when it's the case */
@@ -776,12 +776,12 @@
     if (mWaitersCount > 0)
     {
-        LogFlow (("WARNING: There are still %d threads waiting for '%ls' completion!\n",
-                  mWaitersCount, mDescription.raw()));
-        RTSemEventMultiSignal (mCompletedSem);
-    }
-
-    RTSemEventMultiDestroy (mCompletedSem);
-
-    ProgressBase::protectedUninit (autoUninitSpan);
+        LogFlow(("WARNING: There are still %d threads waiting for '%ls' completion!\n",
+                 mWaitersCount, mDescription.raw()));
+        RTSemEventMultiSignal(mCompletedSem);
+    }
+
+    RTSemEventMultiDestroy(mCompletedSem);
+
+    ProgressBase::protectedUninit(autoUninitSpan);
 }
 
@@ -798,5 +798,5 @@
  *       calling this method will definitely freeze event processing.
  */
-STDMETHODIMP Progress::WaitForCompletion (LONG aTimeout)
+STDMETHODIMP Progress::WaitForCompletion(LONG aTimeout)
 {
     LogFlowThisFuncEnter();
@@ -1033,5 +1033,5 @@
         /* try to import error info from the current thread */
 
-#if !defined (VBOX_WITH_XPCOM)
+#if !defined(VBOX_WITH_XPCOM)
 
         ComPtr<IErrorInfo> err;
@@ -1044,5 +1044,5 @@
         }
 
-#else /* !defined (VBOX_WITH_XPCOM) */
+#else /* !defined(VBOX_WITH_XPCOM) */
 
         nsCOMPtr<nsIExceptionService> es;
@@ -1064,8 +1064,8 @@
             }
         }
-#endif /* !defined (VBOX_WITH_XPCOM) */
-
-        AssertMsg (rc == S_OK, ("Couldn't get error info (rc=%08X) while trying "
-                                "to set a failed result (%08X)!\n", rc, aResultCode));
+#endif /* !defined(VBOX_WITH_XPCOM) */
+
+        AssertMsg(rc == S_OK, ("Couldn't get error info (rc=%08X) while trying to set a failed result (%08X)!\n",
+                               rc, aResultCode));
     }
 
@@ -1116,5 +1116,5 @@
     /* remove from the global collection of pending progress operations */
     if (mParent)
-        mParent->removeProgress (mId);
+        mParent->removeProgress(mId.ref());
 #endif
 
@@ -1180,5 +1180,5 @@
     ComObjPtr<VirtualBoxErrorInfo> errorInfo;
     HRESULT rc = errorInfo.createObject();
-    AssertComRC (rc);
+    AssertComRC(rc);
     if (SUCCEEDED(rc))
     {
@@ -1190,5 +1190,5 @@
     /* remove from the global collection of pending progress operations */
     if (mParent)
-        mParent->removeProgress (mId);
+        mParent->removeProgress(mId.ref());
 #endif
 
@@ -1265,10 +1265,10 @@
  * @param aId           See ProgressBase::init().
  */
-HRESULT CombinedProgress::protectedInit (AutoInitSpan &aAutoInitSpan,
-#if !defined (VBOX_COM_INPROC)
-                                         VirtualBox *aParent,
+HRESULT CombinedProgress::protectedInit(AutoInitSpan &aAutoInitSpan,
+#if !defined(VBOX_COM_INPROC)
+                                        VirtualBox *aParent,
 #endif
-                                         IUnknown *aInitiator,
-                                         CBSTR aDescription, OUT_GUID aId)
+                                        IUnknown *aInitiator,
+                                        CBSTR aDescription, OUT_GUID aId)
 {
     LogFlowThisFunc(("aDescription={%ls} mProgresses.size()=%d\n",
@@ -1277,9 +1277,9 @@
     HRESULT rc = S_OK;
 
-    rc = ProgressBase::protectedInit (aAutoInitSpan,
-#if !defined (VBOX_COM_INPROC)
-                                      aParent,
+    rc = ProgressBase::protectedInit(aAutoInitSpan,
+#if !defined(VBOX_COM_INPROC)
+                                     aParent,
 #endif
-                                      aInitiator, aDescription, aId);
+                                     aInitiator, aDescription, aId);
     if (FAILED(rc)) return rc;
 
@@ -1336,5 +1336,5 @@
  */
 HRESULT CombinedProgress::init(
-#if !defined (VBOX_COM_INPROC)
+#if !defined(VBOX_COM_INPROC)
                                VirtualBox *aParent,
 #endif
@@ -1354,5 +1354,5 @@
 
     HRESULT rc =  protectedInit(autoInitSpan,
-#if !defined (VBOX_COM_INPROC)
+#if !defined(VBOX_COM_INPROC)
                                 aParent,
 #endif
@@ -1385,5 +1385,5 @@
     mProgresses.clear();
 
-    ProgressBase::protectedUninit (autoUninitSpan);
+    ProgressBase::protectedUninit(autoUninitSpan);
 }
 
@@ -1417,5 +1417,5 @@
 }
 
-STDMETHODIMP CombinedProgress::COMGETTER(Completed) (BOOL *aCompleted)
+STDMETHODIMP CombinedProgress::COMGETTER(Completed)(BOOL *aCompleted)
 {
     CheckComArgOutPointerValid(aCompleted);
@@ -1430,8 +1430,8 @@
     if (FAILED(rc)) return rc;
 
-    return ProgressBase::COMGETTER(Completed) (aCompleted);
-}
-
-STDMETHODIMP CombinedProgress::COMGETTER(Canceled) (BOOL *aCanceled)
+    return ProgressBase::COMGETTER(Completed)(aCompleted);
+}
+
+STDMETHODIMP CombinedProgress::COMGETTER(Canceled)(BOOL *aCanceled)
 {
     CheckComArgOutPointerValid(aCanceled);
@@ -1446,8 +1446,8 @@
     if (FAILED(rc)) return rc;
 
-    return ProgressBase::COMGETTER(Canceled) (aCanceled);
-}
-
-STDMETHODIMP CombinedProgress::COMGETTER(ResultCode) (LONG *aResultCode)
+    return ProgressBase::COMGETTER(Canceled)(aCanceled);
+}
+
+STDMETHODIMP CombinedProgress::COMGETTER(ResultCode)(LONG *aResultCode)
 {
     CheckComArgOutPointerValid(aResultCode);
@@ -1462,8 +1462,8 @@
     if (FAILED(rc)) return rc;
 
-    return ProgressBase::COMGETTER(ResultCode) (aResultCode);
-}
-
-STDMETHODIMP CombinedProgress::COMGETTER(ErrorInfo) (IVirtualBoxErrorInfo **aErrorInfo)
+    return ProgressBase::COMGETTER(ResultCode)(aResultCode);
+}
+
+STDMETHODIMP CombinedProgress::COMGETTER(ErrorInfo)(IVirtualBoxErrorInfo **aErrorInfo)
 {
     CheckComArgOutPointerValid(aErrorInfo);
@@ -1478,8 +1478,8 @@
     if (FAILED(rc)) return rc;
 
-    return ProgressBase::COMGETTER(ErrorInfo) (aErrorInfo);
-}
-
-STDMETHODIMP CombinedProgress::COMGETTER(Operation) (ULONG *aOperation)
+    return ProgressBase::COMGETTER(ErrorInfo)(aErrorInfo);
+}
+
+STDMETHODIMP CombinedProgress::COMGETTER(Operation)(ULONG *aOperation)
 {
     CheckComArgOutPointerValid(aOperation);
@@ -1494,8 +1494,8 @@
     if (FAILED(rc)) return rc;
 
-    return ProgressBase::COMGETTER(Operation) (aOperation);
-}
-
-STDMETHODIMP CombinedProgress::COMGETTER(OperationDescription) (BSTR *aOperationDescription)
+    return ProgressBase::COMGETTER(Operation)(aOperation);
+}
+
+STDMETHODIMP CombinedProgress::COMGETTER(OperationDescription)(BSTR *aOperationDescription)
 {
     CheckComArgOutPointerValid(aOperationDescription);
@@ -1510,5 +1510,5 @@
     if (FAILED(rc)) return rc;
 
-    return ProgressBase::COMGETTER(OperationDescription) (aOperationDescription);
+    return ProgressBase::COMGETTER(OperationDescription)(aOperationDescription);
 }
 
@@ -1526,5 +1526,5 @@
     if (FAILED(rc)) return rc;
 
-    return ProgressBase::COMGETTER(OperationPercent) (aOperationPercent);
+    return ProgressBase::COMGETTER(OperationPercent)(aOperationPercent);
 }
 
@@ -1553,5 +1553,5 @@
  *       calling this method will definitely freeze event processing.
  */
-STDMETHODIMP CombinedProgress::WaitForCompletion (LONG aTimeout)
+STDMETHODIMP CombinedProgress::WaitForCompletion(LONG aTimeout)
 {
     LogFlowThisFuncEnter();
@@ -1604,5 +1604,5 @@
  *       calling this method will definitely freeze event processing.
  */
-STDMETHODIMP CombinedProgress::WaitForOperationCompletion (ULONG aOperation, LONG aTimeout)
+STDMETHODIMP CombinedProgress::WaitForOperationCompletion(ULONG aOperation, LONG aTimeout)
 {
     LogFlowThisFuncEnter();
@@ -1756,5 +1756,5 @@
             if (FAILED(mResultCode))
             {
-                rc = progress->COMGETTER(ErrorInfo) (mErrorInfo.asOutParam());
+                rc = progress->COMGETTER(ErrorInfo)(mErrorInfo.asOutParam());
                 if (FAILED(rc))
                     return rc;
@@ -1768,5 +1768,5 @@
             {
                 ULONG opCount = 0;
-                rc = progress->COMGETTER(OperationCount) (&opCount);
+                rc = progress->COMGETTER(OperationCount)(&opCount);
                 if (FAILED(rc))
                     return rc;
@@ -1784,14 +1784,13 @@
     while (fCompleted && !mCompleted);
 
-    rc = progress->COMGETTER(OperationPercent) (&m_ulOperationPercent);
+    rc = progress->COMGETTER(OperationPercent)(&m_ulOperationPercent);
     if (SUCCEEDED(rc))
     {
         ULONG operation = 0;
-        rc = progress->COMGETTER(Operation) (&operation);
+        rc = progress->COMGETTER(Operation)(&operation);
         if (SUCCEEDED(rc) && mCompletedOperations + operation > m_ulCurrentOperation)
         {
             m_ulCurrentOperation = mCompletedOperations + operation;
-            rc = progress->COMGETTER(OperationDescription) (
-                m_bstrOperationDescription.asOutParam());
+            rc = progress->COMGETTER(OperationDescription)(m_bstrOperationDescription.asOutParam());
         }
     }
