TokenImpl.cpp revision bf17ed67e9d9e0767b4432ae0043fea2e27434f2
/* $Id$ */
/** @file
*
* Token COM class implementation: MachineToken and MediumLockToken
*/
/*
* Copyright (C) 2013 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*/
#include "TokenImpl.h"
#include "MachineImpl.h"
#include "MediumImpl.h"
#include "AutoCaller.h"
#include "Logging.h"
// constructor / destructor
/////////////////////////////////////////////////////////////////////////////
{
return BaseFinalConstruct();
}
void MachineToken::FinalRelease()
{
uninit();
}
// public initializer/uninitializer for internal purposes only
/////////////////////////////////////////////////////////////////////////////
/**
* Initializes the token object.
*
* @param pSessionMachine Pointer to a SessionMachine object.
*/
{
/* Enclose the state transition NotReady->InInit->Ready */
AutoInitSpan autoInitSpan(this);
/* Confirm a successful initialization */
return S_OK;
}
/**
* Uninitializes the instance and sets the ready flag to FALSE.
* Called either from FinalRelease() or by the parent when it gets destroyed.
*/
void MachineToken::uninit()
{
LogFlowThisFunc(("\n"));
/* Enclose the state transition Ready->InUninit->NotReady */
AutoUninitSpan autoUninitSpan(this);
if (autoUninitSpan.uninitDone())
return;
/* Destroy the SessionMachine object, check is paranoia */
if (!m.pSessionMachine.isNull())
{
m.pSessionMachine->uninit();
m.pSessionMachine.setNull();
}
}
// IToken methods
/////////////////////////////////////////////////////////////////////////////
{
/* have to release the AutoCaller before calling uninit(), self-deadlock */
/* uninit does everything we need */
uninit();
return S_OK;
}
{
/* Remember, the wrapper contains the AutoCaller, which means that after
* uninit() this code won't be reached any more. */
/* this is a NOOP, no need to lock */
return S_OK;
}
// public methods only for internal purposes
/////////////////////////////////////////////////////////////////////////////
// constructor / destructor
/////////////////////////////////////////////////////////////////////////////
{
return BaseFinalConstruct();
}
void MediumLockToken::FinalRelease()
{
uninit();
}
// public initializer/uninitializer for internal purposes only
/////////////////////////////////////////////////////////////////////////////
/**
* Initializes the token object.
*
* @param pMedium Pointer to a Medium object.
* @param fWrite True if this is a write lock, false otherwise.
*/
{
/* Enclose the state transition NotReady->InInit->Ready */
AutoInitSpan autoInitSpan(this);
/* Confirm a successful initialization */
return S_OK;
}
/**
* Uninitializes the instance and sets the ready flag to FALSE.
* Called either from FinalRelease() or by the parent when it gets destroyed.
*/
void MediumLockToken::uninit()
{
LogFlowThisFunc(("\n"));
/* Enclose the state transition Ready->InUninit->NotReady */
AutoUninitSpan autoUninitSpan(this);
if (autoUninitSpan.uninitDone())
return;
/* Release the appropriate lock, check is paranoia */
{
if (m.fWrite)
{
}
else
{
}
}
}
// IToken methods
/////////////////////////////////////////////////////////////////////////////
{
/* have to release the AutoCaller before calling uninit(), self-deadlock */
/* uninit does everything we need */
uninit();
return S_OK;
}
{
/* Remember, the wrapper contains the AutoCaller, which means that after
* uninit() this code won't be reached any more. */
/* this is a NOOP, no need to lock */
return S_OK;
}
// public methods only for internal purposes
/////////////////////////////////////////////////////////////////////////////
/* vi: set tabstop=4 shiftwidth=4 expandtab: */