本文整理汇总了C++中nsAutoPtr::forget方法的典型用法代码示例。如果您正苦于以下问题:C++ nsAutoPtr::forget方法的具体用法?C++ nsAutoPtr::forget怎么用?C++ nsAutoPtr::forget使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nsAutoPtr
的用法示例。
在下文中一共展示了nsAutoPtr::forget方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ConstructMediaTracks
void
MediaDecoder::MetadataLoaded(nsAutoPtr<MediaInfo> aInfo,
nsAutoPtr<MetadataTags> aTags,
MediaDecoderEventVisibility aEventVisibility)
{
MOZ_ASSERT(NS_IsMainThread());
if (mShuttingDown) {
return;
}
DECODER_LOG("MetadataLoaded, channels=%u rate=%u hasAudio=%d hasVideo=%d",
aInfo->mAudio.mChannels, aInfo->mAudio.mRate,
aInfo->HasAudio(), aInfo->HasVideo());
mInfo = aInfo.forget();
ConstructMediaTracks();
// Make sure the element and the frame (if any) are told about
// our new size.
Invalidate();
if (aEventVisibility != MediaDecoderEventVisibility::Suppressed) {
mFiredMetadataLoaded = true;
mOwner->MetadataLoaded(mInfo, nsAutoPtr<const MetadataTags>(aTags.forget()));
}
}
示例2: IDBFactory
// static
nsresult
IDBFactory::CreateForJSInternal(JSContext* aCx,
JS::Handle<JSObject*> aOwningObject,
nsAutoPtr<PrincipalInfo>& aPrincipalInfo,
uint64_t aInnerWindowID,
IDBFactory** aFactory)
{
MOZ_ASSERT(aCx);
MOZ_ASSERT(aOwningObject);
MOZ_ASSERT(aPrincipalInfo);
MOZ_ASSERT(aPrincipalInfo->type() != PrincipalInfo::T__None);
MOZ_ASSERT(aFactory);
MOZ_ASSERT(JS_GetGlobalForObject(aCx, aOwningObject) == aOwningObject,
"Not a global object!");
if (aPrincipalInfo->type() != PrincipalInfo::TContentPrincipalInfo &&
aPrincipalInfo->type() != PrincipalInfo::TSystemPrincipalInfo) {
NS_WARNING("IndexedDB not allowed for this principal!");
aPrincipalInfo = nullptr;
*aFactory = nullptr;
return NS_OK;
}
RefPtr<IDBFactory> factory = new IDBFactory();
factory->mPrincipalInfo = aPrincipalInfo.forget();
factory->mOwningObject = aOwningObject;
mozilla::HoldJSObjects(factory.get());
factory->mInnerWindowID = aInnerWindowID;
factory.forget(aFactory);
return NS_OK;
}
示例3: BackgroundActorCreated
nsresult
QuotaManagerService::InitiateRequest(nsAutoPtr<PendingRequestInfo>& aInfo)
{
// Nothing can be done here if we have previously failed to create a
// background actor.
if (mBackgroundActorFailed) {
return NS_ERROR_FAILURE;
}
if (!mBackgroundActor && mPendingRequests.IsEmpty()) {
if (PBackgroundChild* actor = BackgroundChild::GetForCurrentThread()) {
BackgroundActorCreated(actor);
} else {
// We need to start the sequence to create a background actor for this
// thread.
RefPtr<BackgroundCreateCallback> cb = new BackgroundCreateCallback(this);
if (NS_WARN_IF(!BackgroundChild::GetOrCreateForCurrentThread(cb))) {
return NS_ERROR_FAILURE;
}
}
}
// If we already have a background actor then we can start this request now.
if (mBackgroundActor) {
nsresult rv = aInfo->InitiateRequest(mBackgroundActor);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
} else {
mPendingRequests.AppendElement(aInfo.forget());
}
return NS_OK;
}
示例4: PlayStateStr
void
MediaDecoder::FirstFrameLoaded(nsAutoPtr<MediaInfo> aInfo,
MediaDecoderEventVisibility aEventVisibility)
{
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(!mShuttingDown);
DECODER_LOG("FirstFrameLoaded, channels=%u rate=%u hasAudio=%d hasVideo=%d mPlayState=%s mIsDormant=%d",
aInfo->mAudio.mChannels, aInfo->mAudio.mRate,
aInfo->HasAudio(), aInfo->HasVideo(), PlayStateStr(), mIsDormant);
mInfo = aInfo.forget();
Invalidate();
if (aEventVisibility != MediaDecoderEventVisibility::Suppressed) {
mOwner->FirstFrameLoaded();
}
// This can run cache callbacks.
mResource->EnsureCacheUpToDate();
// The element can run javascript via events
// before reaching here, so only change the
// state if we're still set to the original
// loading state.
if (mPlayState == PLAY_STATE_LOADING && !mIsDormant) {
ChangeState(mNextState);
}
// Run NotifySuspendedStatusChanged now to give us a chance to notice
// that autoplay should run.
NotifySuspendedStatusChanged();
}
示例5: context
void
MediaDecoder::FirstFrameLoaded(nsAutoPtr<MediaInfo> aInfo,
MediaDecoderEventVisibility aEventVisibility)
{
MOZ_ASSERT(NS_IsMainThread());
MOZ_DIAGNOSTIC_ASSERT(!IsShutdown());
AbstractThread::AutoEnter context(AbstractMainThread());
LOG("FirstFrameLoaded, channels=%u rate=%u hasAudio=%d hasVideo=%d "
"mPlayState=%s transportSeekable=%d",
aInfo->mAudio.mChannels, aInfo->mAudio.mRate, aInfo->HasAudio(),
aInfo->HasVideo(), PlayStateStr(), IsTransportSeekable());
mInfo = aInfo.forget();
Invalidate();
// The element can run javascript via events
// before reaching here, so only change the
// state if we're still set to the original
// loading state.
if (mPlayState == PLAY_STATE_LOADING) {
ChangeState(mNextState);
}
// GetOwner()->FirstFrameLoaded() might call us back. Put it at the bottom of
// this function to avoid unexpected shutdown from reentrant calls.
if (aEventVisibility != MediaDecoderEventVisibility::Suppressed) {
GetOwner()->FirstFrameLoaded();
}
}
示例6: LOG
nsresult
nsUrlClassifierLookupCallback::HandleResults()
{
if (!mResults) {
// No results, this URI is clean.
return mCallback->HandleEvent(NS_LITERAL_CSTRING(""));
}
nsTArray<nsCString> tables;
// Build a stringified list of result tables.
for (PRUint32 i = 0; i < mResults->Length(); i++) {
LookupResult& result = mResults->ElementAt(i);
// Leave out results that weren't confirmed, as their existence on
// the list can't be verified. Also leave out randomly-generated
// noise.
if (!result.Confirmed() || result.mNoise) {
LOG(("Skipping result from table %s", result.mTableName.get()));
continue;
}
LOG(("Confirmed result from table %s", result.mTableName.get()));
if (tables.IndexOf(result.mTableName) == nsTArray<nsCString>::NoIndex) {
tables.AppendElement(result.mTableName);
}
}
// Some parts of this gethash request generated no hits at all.
// Prefixes must have been removed from the database since our last update.
// Save the prefixes we checked to prevent repeated requests
// until the next update.
nsAutoPtr<PrefixArray> cacheMisses(new PrefixArray());
if (cacheMisses) {
for (uint32 i = 0; i < mResults->Length(); i++) {
LookupResult &result = mResults->ElementAt(i);
if (!result.Confirmed()) {
cacheMisses->AppendElement(result.PrefixHash());
}
}
// Hands ownership of the miss array back to the worker thread.
mDBService->CacheMisses(cacheMisses.forget());
}
if (mCacheResults) {
// This hands ownership of the cache results array back to the worker
// thread.
mDBService->CacheCompletions(mCacheResults.forget());
}
nsCAutoString tableStr;
for (PRUint32 i = 0; i < tables.Length(); i++) {
if (i != 0)
tableStr.Append(',');
tableStr.Append(tables[i]);
}
return mCallback->HandleEvent(tableStr);
}
示例7: dre
void
RilConsumer::ReceiveSocketData(nsAutoPtr<UnixSocketRawData>& aMessage)
{
MOZ_ASSERT(NS_IsMainThread());
nsRefPtr<DispatchRILEvent> dre(new DispatchRILEvent(aMessage.forget()));
mDispatcher->PostTask(dre);
}
示例8: AddSelector
void nsCSSSelectorList::AddSelector(nsAutoPtr<nsCSSSelector>& aSelector)
{ // prepend to list
nsCSSSelector* newSel = aSelector.forget();
if (newSel) {
newSel->mNext = mSelectors;
mSelectors = newSel;
}
}
示例9: MetadataLoaded
void MediaDecoder::MetadataLoaded(nsAutoPtr<MediaInfo> aInfo,
nsAutoPtr<MetadataTags> aTags,
MediaDecoderEventVisibility aEventVisibility)
{
MOZ_ASSERT(NS_IsMainThread());
if (mShuttingDown) {
return;
}
DECODER_LOG("MetadataLoaded, channels=%u rate=%u hasAudio=%d hasVideo=%d",
aInfo->mAudio.mChannels, aInfo->mAudio.mRate,
aInfo->HasAudio(), aInfo->HasVideo());
{
ReentrantMonitorAutoEnter mon(GetReentrantMonitor());
mDuration = mDecoderStateMachine ? mDecoderStateMachine->GetDuration() : -1;
// Duration has changed so we should recompute playback rate
UpdatePlaybackRate();
}
if (mDuration == -1) {
SetInfinite(true);
}
mInfo = aInfo.forget();
ConstructMediaTracks();
if (mOwner) {
// Make sure the element and the frame (if any) are told about
// our new size.
Invalidate();
if (aEventVisibility != MediaDecoderEventVisibility::Suppressed) {
mOwner->MetadataLoaded(mInfo, nsAutoPtr<const MetadataTags>(aTags.forget()));
}
}
}
示例10:
nsresult
txStylesheetCompilerState::addInstruction(nsAutoPtr<txInstruction> aInstruction)
{
NS_PRECONDITION(mNextInstrPtr, "adding instruction outside container");
txInstruction* newInstr = aInstruction;
*mNextInstrPtr = aInstruction.forget();
mNextInstrPtr = newInstr->mNext.StartAssignment();
uint32_t i, count = mGotoTargetPointers.Length();
for (i = 0; i < count; ++i) {
*mGotoTargetPointers[i] = newInstr;
}
mGotoTargetPointers.Clear();
return NS_OK;
}
示例11:
void
CDMProxy::gmp_Decrypt(nsAutoPtr<DecryptJob> aJob)
{
MOZ_ASSERT(IsOnGMPThread());
MOZ_ASSERT(aJob->mClient);
MOZ_ASSERT(aJob->mSample);
if (!mCDM) {
aJob->mClient->Decrypted(GMPAbortedErr, nullptr);
return;
}
aJob->mId = ++mDecryptionJobCount;
nsTArray<uint8_t> data;
data.AppendElements(aJob->mSample->data, aJob->mSample->size);
mCDM->Decrypt(aJob->mId, aJob->mSample->crypto, data);
mDecryptionJobs.AppendElement(aJob.forget());
}
示例12:
nsresult
txStylesheet::addDecimalFormat(const txExpandedName& aName,
nsAutoPtr<txDecimalFormat> aFormat)
{
txDecimalFormat* existing = mDecimalFormats.get(aName);
if (existing) {
NS_ENSURE_TRUE(existing->isEqual(aFormat),
NS_ERROR_XSLT_PARSE_FAILURE);
return NS_OK;
}
nsresult rv = mDecimalFormats.add(aName, aFormat);
NS_ENSURE_SUCCESS(rv, rv);
aFormat.forget();
return NS_OK;
}
示例13: ReceiveTask
void
RilSocketIO::ConsumeBuffer()
{
nsRefPtr<ReceiveTask> task = new ReceiveTask(this, mBuffer.forget());
NS_WARN_IF(!mDispatcher->PostTask(task));
}
示例14: switch
/**
* Creates a binary Expr for the given operator
*/
nsresult
txExprParser::createBinaryExpr(nsAutoPtr<Expr>& left, nsAutoPtr<Expr>& right,
Token* op, Expr** aResult)
{
NS_ASSERTION(op, "internal error");
*aResult = nullptr;
Expr* expr = nullptr;
switch (op->mType) {
//-- math ops
case Token::ADDITION_OP :
expr = new txNumberExpr(left, right, txNumberExpr::ADD);
break;
case Token::SUBTRACTION_OP:
expr = new txNumberExpr(left, right, txNumberExpr::SUBTRACT);
break;
case Token::DIVIDE_OP :
expr = new txNumberExpr(left, right, txNumberExpr::DIVIDE);
break;
case Token::MODULUS_OP :
expr = new txNumberExpr(left, right, txNumberExpr::MODULUS);
break;
case Token::MULTIPLY_OP :
expr = new txNumberExpr(left, right, txNumberExpr::MULTIPLY);
break;
//-- case boolean ops
case Token::AND_OP:
expr = new BooleanExpr(left, right, BooleanExpr::AND);
break;
case Token::OR_OP:
expr = new BooleanExpr(left, right, BooleanExpr::OR);
break;
//-- equality ops
case Token::EQUAL_OP :
expr = new RelationalExpr(left, right, RelationalExpr::EQUAL);
break;
case Token::NOT_EQUAL_OP :
expr = new RelationalExpr(left, right, RelationalExpr::NOT_EQUAL);
break;
//-- relational ops
case Token::LESS_THAN_OP:
expr = new RelationalExpr(left, right, RelationalExpr::LESS_THAN);
break;
case Token::GREATER_THAN_OP:
expr = new RelationalExpr(left, right,
RelationalExpr::GREATER_THAN);
break;
case Token::LESS_OR_EQUAL_OP:
expr = new RelationalExpr(left, right,
RelationalExpr::LESS_OR_EQUAL);
break;
case Token::GREATER_OR_EQUAL_OP:
expr = new RelationalExpr(left, right,
RelationalExpr::GREATER_OR_EQUAL);
break;
default:
NS_NOTREACHED("operator tokens should be already checked");
return NS_ERROR_UNEXPECTED;
}
NS_ENSURE_TRUE(expr, NS_ERROR_OUT_OF_MEMORY);
left.forget();
right.forget();
*aResult = expr;
return NS_OK;
}