当前位置: 首页>>代码示例>>C++>>正文


C++ AddRef函数代码示例

本文整理汇总了C++中AddRef函数的典型用法代码示例。如果您正苦于以下问题:C++ AddRef函数的具体用法?C++ AddRef怎么用?C++ AddRef使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了AddRef函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: promise

already_AddRefed<DetailedPromise>
MediaKeys::Init(ErrorResult& aRv)
{
  RefPtr<DetailedPromise> promise(MakePromise(aRv,
    NS_LITERAL_CSTRING("MediaKeys::Init()")));
  if (aRv.Failed()) {
    return nullptr;
  }

  mProxy = new CDMProxy(this, mKeySystem);

  // Determine principal (at creation time) of the MediaKeys object.
  nsCOMPtr<nsIScriptObjectPrincipal> sop = do_QueryInterface(GetParentObject());
  if (!sop) {
    promise->MaybeReject(NS_ERROR_DOM_INVALID_STATE_ERR,
                         NS_LITERAL_CSTRING("Couldn't get script principal in MediaKeys::Init"));
    return promise.forget();
  }
  mPrincipal = sop->GetPrincipal();

  // Determine principal of the "top-level" window; the principal of the
  // page that will display in the URL bar.
  nsCOMPtr<nsPIDOMWindowInner> window = GetParentObject();
  if (!window) {
    promise->MaybeReject(NS_ERROR_DOM_INVALID_STATE_ERR,
                         NS_LITERAL_CSTRING("Couldn't get top-level window in MediaKeys::Init"));
    return promise.forget();
  }
  nsCOMPtr<nsPIDOMWindowOuter> top = window->GetOuterWindow()->GetTop();
  if (!top || !top->GetExtantDoc()) {
    promise->MaybeReject(NS_ERROR_DOM_INVALID_STATE_ERR,
                         NS_LITERAL_CSTRING("Couldn't get document in MediaKeys::Init"));
    return promise.forget();
  }

  mTopLevelPrincipal = top->GetExtantDoc()->NodePrincipal();

  if (!mPrincipal || !mTopLevelPrincipal) {
    NS_WARNING("Failed to get principals when creating MediaKeys");
    promise->MaybeReject(NS_ERROR_DOM_INVALID_STATE_ERR,
                         NS_LITERAL_CSTRING("Couldn't get principal(s) in MediaKeys::Init"));
    return promise.forget();
  }

  nsAutoString origin;
  nsresult rv = nsContentUtils::GetUTFOrigin(mPrincipal, origin);
  if (NS_FAILED(rv)) {
    promise->MaybeReject(NS_ERROR_DOM_INVALID_STATE_ERR,
                         NS_LITERAL_CSTRING("Couldn't get principal origin string in MediaKeys::Init"));
    return promise.forget();
  }
  nsAutoString topLevelOrigin;
  rv = nsContentUtils::GetUTFOrigin(mTopLevelPrincipal, topLevelOrigin);
  if (NS_FAILED(rv)) {
    promise->MaybeReject(NS_ERROR_DOM_INVALID_STATE_ERR,
                         NS_LITERAL_CSTRING("Couldn't get top-level principal origin string in MediaKeys::Init"));
    return promise.forget();
  }

  nsIDocument* doc = window->GetExtantDoc();
  const bool inPrivateBrowsing = nsContentUtils::IsInPrivateBrowsing(doc);

  EME_LOG("MediaKeys[%p]::Create() (%s, %s), %s",
          this,
          NS_ConvertUTF16toUTF8(origin).get(),
          NS_ConvertUTF16toUTF8(topLevelOrigin).get(),
          (inPrivateBrowsing ? "PrivateBrowsing" : "NonPrivateBrowsing"));

  // The CDMProxy's initialization is asynchronous. The MediaKeys is
  // refcounted, and its instance is returned to JS by promise once
  // it's been initialized. No external refs exist to the MediaKeys while
  // we're waiting for the promise to be resolved, so we must hold a
  // reference to the new MediaKeys object until it's been created,
  // or its creation has failed. Store the id of the promise returned
  // here, and hold a self-reference until that promise is resolved or
  // rejected.
  MOZ_ASSERT(!mCreatePromiseId, "Should only be created once!");
  mCreatePromiseId = StorePromise(promise);
  AddRef();
  mProxy->Init(mCreatePromiseId,
               origin,
               topLevelOrigin,
               KeySystemToGMPName(mKeySystem),
               inPrivateBrowsing,
               new MediaKeysGMPCrashHelper(this));

  return promise.forget();
}
开发者ID:carriercomm,项目名称:gecko-dev,代码行数:88,代码来源:MediaKeys.cpp

示例2: m_tvBankedPlayTime

BasicPacketFlow::BasicPacketFlow(Process* p,
                                 IHXSessionStats* pSessionStats,
                                 UINT16 unStreamCount,
                                 PacketFlowManager* pFlowMgr,
                                 BOOL bIsMulticast)
    : m_tvBankedPlayTime(0,0)
{
    m_pProc 		 	= p;
    m_pFlowMgr 		 	= pFlowMgr;
    m_unStreamCount 	 	= unStreamCount;
    m_uNumStreamsRegistered	= 0;
    m_ulRefCount 	 	= 0;
    m_bPaused		 	= FALSE;
    m_bInSeek		 	= FALSE;
    m_bInitialSubscriptionDone	= FALSE;
    m_bInitialPlayReceived	= FALSE;
    m_bGetPacketsOutstanding	= FALSE;
    m_tTimeLineStart.tv_sec	= 0;
    m_tTimeLineStart.tv_usec	= 0;
    m_bTimeLineSuspended	= TRUE;
    m_bIsMulticast		= bIsMulticast;
    m_ulPacketsOutstanding	= 0;
    m_fDeliveryRatio		= 1.0;
    m_bSourceIsDone		= FALSE;
    m_ulNumStreamDones		= 0;
    m_uEndPoint			= 0;
    m_bIsPausePointSet          = FALSE; 
    m_bIsDone			= FALSE;
    m_ulResendIDPosition	= 0;
    m_bSubscribed		= FALSE;
    m_bAutoSubscription		= TRUE;
    m_ulWouldBlocking		= 0;
    m_bWouldBlockAvailable      = FALSE;
    m_pConvertShim              = 0;
    m_pConvertingPacket		= NULL;
    m_bPlayPendingOnSeek	= FALSE;
    m_pPlayerControl            = NULL;
    m_pPlayerSessionId          = NULL;
    m_pRateManager              = NULL;
    m_bSeekPacketPending  = FALSE;
    m_bSessionPlaying     = FALSE;
    m_bDeliveryBandwidthSet = FALSE;
    m_pStats                    = pSessionStats;
    m_pStats->AddRef();
    m_bRTPInfoRequired          = TRUE;
    m_uFirstStreamRegistered	= 0xFFFF;

    m_ulSetDeliveryBandwidth = 0;
    m_ulBandwidth = 0;

    memset(m_pResendIDs, 0, sizeof(UINT32) * MAX_RESENDS_PER_SECOND);

    // Contorted initialization due to NT not able to intialize array
    // elements on creation even though it is standard C++
    m_pStreams = new PacketStream[unStreamCount];

    // then the intialization
    for (UINT16 iStream = 0; iStream < unStreamCount; iStream++)
	m_pStreams[iStream].SetFlow(this);

    // get clock for PlayTime tracking

    if (HXR_OK != m_pProc->pc->server_context->
        QueryInterface(IID_IHXAccurateClock, (void**) &m_pAccurateClock))
    {
        // system doesn't have accurate clock, use our own.
        AddRef();
        m_pAccurateClock = (IHXAccurateClock*) this;
    }

    // for safety, initialize this to current time, although we really
    // set it in Play().
    
    HXTimeval hxt = m_pAccurateClock->GetTimeOfDay();
    m_tvRTSPPlayTime.tv_sec = hxt.tv_sec;
    m_tvRTSPPlayTime.tv_usec = hxt.tv_usec;
}
开发者ID:muromec,项目名称:qtopia-ezx,代码行数:77,代码来源:basicpcktflow.cpp

示例3: AddRef

 AwtTextComponent::OleCallback::OleCallback() {
     m_refs = 0;
     AddRef();
 }
开发者ID:sakeinntojiu,项目名称:openjdk8-jdk,代码行数:4,代码来源:awt_TextComponent.cpp

示例4: CCountedPtr

	/** default (NULL) construct or construct from a raw pointer */
	FORCEINLINE CCountedPtr(Tcls *pObj = NULL) : m_pT(pObj) {AddRef();}
开发者ID:a7omic,项目名称:OpenTTD,代码行数:2,代码来源:countedptr.hpp

示例5: AddRef

void    CchaffIGC::Terminate(void)
{
    AddRef();
	TmodelIGC<IchaffIGC>::Terminate();
    Release();
}
开发者ID:Factoid,项目名称:alleg-core,代码行数:6,代码来源:chaffIGC.cpp

示例6: AddRef

		void RocketDocument3D::AddReference()
		{
			AddRef();
		}
开发者ID:1vanK,项目名称:libRocket-Urho3D,代码行数:4,代码来源:RocketDocument3D.cpp

示例7: RefCount

GDIFontRasterizer::GDIFontRasterizer()
: RefCount(0), FontDC(NULL), NonBoldFontDC(NULL), LastBitmap(NULL), ChAntialiasMethodInit(false)
, ChUseResampling(false), ChAntialiasMethod(camResample8)
{
	AddRef();
}
开发者ID:harada3,项目名称:krkrz,代码行数:6,代码来源:GDIFontRasterizer.cpp

示例8: AddRef

/////////////////////////////////////////////////////////////////////////
//  Method:
//	IUnknown::QueryInterface
//  Purpose:
//	Implement this to export the interfaces supported by your 
//	object.
//
STDMETHODIMP FileObjectWrapper::QueryInterface(REFIID riid, void** ppvObj)
{
    if (IsEqualIID(riid, IID_IUnknown))
    {
	AddRef();
	*ppvObj = (IUnknown*)(IHXFileObject *)this;
	return HXR_OK;
    }
    else if (IsEqualIID(riid, IID_IHXFileObject))
    {
	if(m_has_file_object)
	{
	    AddRef();
	    *ppvObj = (IHXFileObject*)this;
	    return HXR_OK;
	}
    }
    else if (IsEqualIID(riid, IID_IHXFileStat))
    {
	if(m_has_file_stat)
	{
	    AddRef();
	    *ppvObj = (IHXFileStat*)this;
	    return HXR_OK;
	}
    }
    else if(IsEqualIID(riid, IID_IHXFileExists))
    {
	if(m_has_file_exists)
	{
	    AddRef();
	    *ppvObj = (IHXFileExists*)this;
	    return HXR_OK;
	}
    }
    else if(IsEqualIID(riid, IID_IHXFileMimeMapper))
    {
	if(m_has_file_mime_mapper)
	{
	    AddRef();
	    *ppvObj = (IHXFileMimeMapper*)this;
	    return HXR_OK;
	}
    }
    else if(IsEqualIID(riid, IID_IHXBroadcastMapper))
    {
	if(m_has_broadcast_mapper)
	{
	    AddRef();
	    *ppvObj = (IHXBroadcastMapper*)this;
	    return HXR_OK;
	}
    }
    else if(IsEqualIID(riid, IID_IHXGetFileFromSamePool))
    {
	if(m_has_pool_object)
	{
	    AddRef();
	    *ppvObj = (IHXGetFileFromSamePool*)this;
	    return HXR_OK;
	}
    }
    else if(IsEqualIID(riid, IID_IHXRequestHandler))
    {
	if(m_has_request_handler)
	{
	    AddRef();
	    *ppvObj = (IHXRequestHandler*)this;
	    return HXR_OK;
	}
    }
    else if(IsEqualIID(riid, IID_IHXPostDataHandler))
    {
	if(m_has_post_data_handler)
	{
	    AddRef();
	    *ppvObj = (IHXPostDataHandler*)this;
	    return HXR_OK;
	}
    }

    *ppvObj = NULL;
    return HXR_NOINTERFACE;
}
开发者ID:muromec,项目名称:qtopia-ezx,代码行数:91,代码来源:flob_wrap.cpp

示例9: AddRef

HX_RESULT
StaticPushSource::Init(IHXPSinkControl* pSink)
{
    HX_RESULT			h_result = HXR_OK;
    IHXFileObject*             pFileObject;
    IHXBandwidthNegotiator*    pBandwidthNegotiator;

    pSink->AddRef();
    m_pSinkControl = pSink;

    AddRef();
    if (HXR_OK == h_result)
    {
	if(HXR_OK == m_pFileObject->QueryInterface(IID_IHXFileObject,
						 (void**)&pFileObject))
	{
	  
	    if(m_pBWEValues && 
	       (HXR_OK == m_pFileFormat->QueryInterface(
		IID_IHXBandwidthNegotiator,
		(void**)&pBandwidthNegotiator)))
	    {
		pBandwidthNegotiator->SetBandwidthInfo(m_pBWEValues);
		pBandwidthNegotiator->Release();
		m_pBWEValues->Release();
		m_pBWEValues = NULL;
	    }

	    h_result = m_pFileFormat->InitFileFormat(m_pRequest, this,
						     pFileObject);
	    /*
	     * The IHXFileObject belongs to the IHXFileFormatObject...
	     */
	    
	    HX_RELEASE(m_pFileObject);

	    HX_RELEASE(pFileObject);

	    /*
	     * so does the IHXRequest
	     */

	    HX_RELEASE(m_pRequest);

	    if (HXR_OK != h_result)
	    {

		ERRMSG(m_proc->pc->error_handler,
		       "File Format initialization failed\n");
		m_pFileFormat->Close();
		m_pFileFormat->Release();
		m_pFileFormat = 0;
	    }
	}

    }

    Release();

    return h_result;
}
开发者ID:muromec,项目名称:qtopia-ezx,代码行数:61,代码来源:inputsrc_push.cpp

示例10: NiAdminThread

// Management thread
void NiAdminThread(THREAD *thread, void *param)
{
	NAT_ADMIN *a = (NAT_ADMIN *)param;
	NAT *n;
	SOCK *s;
	UCHAR random[SHA1_SIZE];
	UINT err;
	// Validate arguments
	if (thread == NULL || param == NULL)
	{
		return;
	}

	// Random number generation
	Rand(random, sizeof(random));

	a->Thread = thread;
	AddRef(a->Thread->ref);
	s = a->Sock;
	AddRef(s->ref);

	n = a->Nat;

	LockList(n->AdminList);
	{
		Add(n->AdminList, a);
	}
	UnlockList(n->AdminList);

	NoticeThreadInit(thread);

	err = ERR_AUTH_FAILED;

	if (StartSSL(s, n->AdminX, n->AdminK))
	{
		PACK *p;

		// Send the random number
		p = NewPack();
		PackAddData(p, "auth_random", random, sizeof(random));

		if (HttpServerSend(s, p))
		{
			PACK *p;
			// Receive a password
			p = HttpServerRecv(s);
			if (p != NULL)
			{
				UCHAR secure_password[SHA1_SIZE];
				UCHAR secure_check[SHA1_SIZE];

				if (PackGetData2(p, "secure_password", secure_password, sizeof(secure_password)))
				{
					SecurePassword(secure_check, n->HashedPassword, random);

					if (Cmp(secure_check, secure_password, SHA1_SIZE) == 0)
					{
						UCHAR test[SHA1_SIZE];
						// Password match
						Hash(test, "", 0, true);
						SecurePassword(test, test, random);

#if	0
						if (Cmp(test, secure_check, SHA1_SIZE) == 0 && s->RemoteIP.addr[0] != 127)
						{
							// A client can not connect from the outside with blank password
							err = ERR_NULL_PASSWORD_LOCAL_ONLY;
						}
						else
#endif

						{
							// Successful connection
							err = ERR_NO_ERROR;
							NiAdminMain(n, s);
						}
					}
				}

				FreePack(p);
			}
		}

		FreePack(p);

		if (err != ERR_NO_ERROR)
		{
			p = PackError(err);
			HttpServerSend(s, p);
			FreePack(p);
		}
	}

	Disconnect(s);
	ReleaseSock(s);
}
开发者ID:benapetr,项目名称:SoftEtherVPN,代码行数:97,代码来源:Nat.c

示例11: NiListenThread

// Management port Listen thread
void NiListenThread(THREAD *thread, void *param)
{
	NAT *n = (NAT *)param;
	SOCK *a;
	UINT i;
	bool b = false;
	// Validate arguments
	if (thread == NULL || param == NULL)
	{
		return;
	}

	// Initialize the management list
	n->AdminList = NewList(NULL);

	while (true)
	{
		a = Listen(DEFAULT_NAT_ADMIN_PORT);
		if (b == false)
		{
			b = true;
			NoticeThreadInit(thread);
		}
		if (a != NULL)
		{
			break;
		}

		Wait(n->HaltEvent, NAT_ADMIN_PORT_LISTEN_INTERVAL);
		if (n->Halt)
		{
			return;
		}
	}

	n->AdminListenSock = a;
	AddRef(a->ref);

	// Waiting
	while (true)
	{
		SOCK *s = Accept(a);
		THREAD *t;
		NAT_ADMIN *admin;
		if (s == NULL)
		{
			break;
		}
		if (n->Halt)
		{
			ReleaseSock(s);
			break;
		}

		admin = ZeroMalloc(sizeof(NAT_ADMIN));
		admin->Nat = n;
		admin->Sock = s;
		t = NewThread(NiAdminThread, admin);
		WaitThreadInit(t);
		ReleaseThread(t);
	}

	// Disconnect all management connections
	LockList(n->AdminList);
	{
		for (i = 0;i < LIST_NUM(n->AdminList);i++)
		{
			NAT_ADMIN *a = LIST_DATA(n->AdminList, i);
			Disconnect(a->Sock);
			WaitThread(a->Thread, INFINITE);
			ReleaseThread(a->Thread);
			ReleaseSock(a->Sock);
			Free(a);
		}
	}
	UnlockList(n->AdminList);

	ReleaseList(n->AdminList);

	ReleaseSock(a);
}
开发者ID:benapetr,项目名称:SoftEtherVPN,代码行数:82,代码来源:Nat.c

示例12: AddRef

	STDMETHODIMP DragDropTarget::QueryInterface(REFIID riid, void **ppv)
	{
		*ppv = this;
		AddRef();
		return NOERROR;
	}
开发者ID:lufinkey,项目名称:BoilermakeWormhole,代码行数:6,代码来源:DragDropTarget.cpp

示例13: NS_ENSURE_ARG

NS_IMETHODIMP 
morkStdioFile::AcquireBud(nsIMdbEnv * mdbev, nsIMdbHeap* ioHeap, nsIMdbFile **acquiredFile)
  // AcquireBud() starts a new "branch" version of the file, empty of content,
  // so that a new version of the file can be written.  This new file
  // can later be told to BecomeTrunk() the original file, so the branch
  // created by budding the file will replace the original file.  Some
  // file subclasses might initially take the unsafe but expedient
  // approach of simply truncating this file down to zero length, and
  // then returning the same morkFile pointer as this, with an extra
  // reference count increment.  Note that the caller of AcquireBud() is
  // expected to eventually call CutStrongRef() on the returned file
  // in order to release the strong reference.  High quality versions
  // of morkFile subclasses will create entirely new files which later
  // are renamed to become the old file, so that better transactional
  // behavior is exhibited by the file, so crashes protect old files.
  // Note that AcquireBud() is an illegal operation on readonly files.
{
  NS_ENSURE_ARG(acquiredFile);
  MORK_USED_1(ioHeap);
  nsresult rv = NS_OK;
  morkFile* outFile = 0;
  morkEnv *ev = morkEnv::FromMdbEnv(mdbev);

  if ( this->IsOpenAndActiveFile() )
  {
    FILE* file = (FILE*) mStdioFile_File;
    if ( file )
    {
//#ifdef MORK_WIN
//      truncate(file, /*eof*/ 0);
//#else /*MORK_WIN*/
      char* name = mFile_Name;
      if ( name )
      {
        if ( MORK_FILECLOSE(file) >= 0 )
        {
          this->SetFileActive(morkBool_kFalse);
          this->SetFileIoOpen(morkBool_kFalse);
          mStdioFile_File = 0;
          
          file = MORK_FILEOPEN(name, "wb+"); // open for write, discarding old content
          if ( file )
          {
            mStdioFile_File = file;
            this->SetFileActive(morkBool_kTrue);
            this->SetFileIoOpen(morkBool_kTrue);
            this->SetFileFrozen(morkBool_kFalse);
          }
          else
            this->new_stdio_file_fault(ev);
        }
        else
          this->new_stdio_file_fault(ev);
      }
      else
        this->NilFileNameError(ev);
      
//#endif /*MORK_WIN*/

      if ( ev->Good() && this->AddStrongRef(ev->AsMdbEnv()) )
      {
        outFile = this;
        AddRef();
      }
    }
    else if ( mFile_Thief )
    {
      rv = mFile_Thief->AcquireBud(ev->AsMdbEnv(), ioHeap, acquiredFile);
    }
    else
      this->NewMissingIoError(ev);
  }
  else this->NewFileDownError(ev);
  
  *acquiredFile = outFile;
  return rv;
}
开发者ID:alanyjw,项目名称:comm-central,代码行数:77,代码来源:morkFile.cpp

示例14: ElListenerProc

// Listener thread
void ElListenerProc(THREAD *thread, void *param)
{
	TCP_ACCEPTED_PARAM *data = (TCP_ACCEPTED_PARAM *)param;
	EL *e;
	SOCK *s;
	UCHAR rand[SHA1_SIZE];
	UCHAR pass1[SHA1_SIZE], pass2[SHA1_SIZE];
	// Validate arguments
	if (data == NULL || thread == NULL)
	{
		return;
	}

	e = (EL *)data->r->ThreadParam;
	s = data->s;
	AddRef(s->ref);
	SetTimeout(s, 5000);
	LockList(e->AdminThreadList);
	{
		AddRef(thread->ref);
		AddRef(s->ref);
		Insert(e->AdminThreadList, thread);
		Insert(e->AdminSockList, s);
	}
	UnlockList(e->AdminThreadList);
	NoticeThreadInit(thread);

	// Submit a challenge
	Rand(rand, sizeof(rand));
	SendAll(s, rand, sizeof(rand), false);

	// Receive a response
	SecurePassword(pass1, e->HashedPassword, rand);
	Zero(pass2, sizeof(pass2));
	RecvAll(s, pass2, sizeof(pass2), false);

	if (Cmp(pass1, pass2, SHA1_SIZE) != 0)
	{
		// Password incorrect
		bool code = false;
		code = Endian32(code);
		SendAll(s, &code, sizeof(code), false);
	}
	else
	{
		// Password match
		bool code = true;
		RPC *r;

		code = Endian32(code);
		SendAll(s, &code, sizeof(code), false);

		SetTimeout(s, INFINITE);

		// Start operation as a RPC server
		r = StartRpcServer(s, ElRpcServer, e);
		RpcServer(r);
		RpcFree(r);
	}

	Disconnect(s);
	ReleaseSock(s);

	LockList(e->AdminThreadList);
	{
		if (Delete(e->AdminThreadList, thread))
		{
			ReleaseThread(thread);
		}
		if (Delete(e->AdminSockList, s))
		{
			ReleaseSock(s);
		}
	}
	UnlockList(e->AdminThreadList);
}
开发者ID:455475876github,项目名称:SoftEtherVPN,代码行数:77,代码来源:EtherLog.c

示例15: AddRef

void eFilePushThread::sendEvent(int evt)
{
	/* add a ref, to make sure the object is not destroyed while the messagepump contains unhandled messages */
	AddRef();
	m_messagepump.send(evt);
}
开发者ID:fairbird,项目名称:OpenPLI-BlackHole,代码行数:6,代码来源:filepush.cpp


注:本文中的AddRef函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。