本文整理汇总了C++中NS_GetCurrentThread函数的典型用法代码示例。如果您正苦于以下问题:C++ NS_GetCurrentThread函数的具体用法?C++ NS_GetCurrentThread怎么用?C++ NS_GetCurrentThread使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NS_GetCurrentThread函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: LOGD
void
GMPDecryptorParent::Shutdown()
{
LOGD(("GMPDecryptorParent[%p]::Shutdown()", this));
MOZ_ASSERT(mGMPThread == NS_GetCurrentThread());
if (mShuttingDown) {
return;
}
mShuttingDown = true;
// Notify client we're gone! Won't occur after Close()
if (mCallback) {
mCallback->Terminated();
mCallback = nullptr;
}
mIsOpen = false;
if (!mActorDestroyed) {
Unused << SendDecryptingComplete();
}
}
示例2: DoSendPrompt
NS_IMETHODIMP nsEmbedFilePicker::Show(int16_t* _retval)
{
DoSendPrompt();
nsresult rv;
mService->EnterSecureJSContext();
nsCOMPtr<nsIDOMWindowUtils> utils = do_GetInterface(mWin);
NS_ENSURE_TRUE(utils, NS_ERROR_FAILURE);
rv = utils->EnterModalState();
mModalDepth++;
int origModalDepth = mModalDepth;
nsCOMPtr<nsIThread> thread;
NS_GetCurrentThread(getter_AddRefs(thread));
while (mModalDepth == origModalDepth && NS_SUCCEEDED(rv)) {
bool processedEvent;
rv = thread->ProcessNextEvent(true, &processedEvent);
if (NS_SUCCEEDED(rv) && !processedEvent) {
rv = NS_ERROR_UNEXPECTED;
}
}
mService->RemoveMessageListener("promptresponse", this);
uint32_t winid;
mService->GetIDByWindow(mWin, &winid);
std::map<uint32_t, EmbedFilePickerResponse>::iterator it = mResponseMap.find(winid);
if (it == mResponseMap.end()) {
return NS_ERROR_UNEXPECTED;
}
rv = utils->LeaveModalState();
mService->LeaveSecureJSContext();
return rv;
}
示例3: LOGD
// Note: Consider keeping ActorDestroy sync'd up when making changes here.
nsresult
GMPAudioDecoderParent::Shutdown()
{
LOGD(("%s: %p", __FUNCTION__, this));
MOZ_ASSERT(mPlugin->GMPThread() == NS_GetCurrentThread());
if (mShuttingDown) {
return NS_OK;
}
mShuttingDown = true;
// Notify client we're gone! Won't occur after Close()
if (mCallback) {
mCallback->Terminated();
mCallback = nullptr;
}
mIsOpen = false;
unused << SendDecodingComplete();
return NS_OK;
}
示例4: MOZ_ASSERT
NS_IMETHODIMP
GeckoMediaPluginService::GetGMPVideoEncoder(nsTArray<nsCString>* aTags,
const nsACString& aNodeId,
UniquePtr<GetGMPVideoEncoderCallback>&& aCallback)
{
MOZ_ASSERT(NS_GetCurrentThread() == mGMPThread);
NS_ENSURE_ARG(aTags && aTags->Length() > 0);
NS_ENSURE_ARG(aCallback);
if (mShuttingDownOnGMPThread) {
return NS_ERROR_FAILURE;
}
UniquePtr<GetGMPContentParentCallback> callback(
new GetGMPContentParentForVideoEncoderDone(Move(aCallback)));
if (!GetContentParentFrom(aNodeId, NS_LITERAL_CSTRING(GMP_API_VIDEO_ENCODER),
*aTags, Move(callback))) {
return NS_ERROR_FAILURE;
}
return NS_OK;
}
示例5: NS_ASSERTION
void
nsBaseAppShell::ScheduleSyncSection(already_AddRefed<nsIRunnable> aRunnable,
bool aStable)
{
NS_ASSERTION(NS_IsMainThread(), "Should be on main thread.");
nsIThread* thread = NS_GetCurrentThread();
// Add this runnable to our list of synchronous sections.
SyncSection* section = mSyncSections.AppendElement();
section->mStable = aStable;
section->mRunnable = aRunnable;
// If aStable is false then this synchronous section is supposed to run before
// the next event at the current nesting level. Record the event loop nesting
// level and the thread recursion level so that the synchronous section will
// run at the proper time.
if (!aStable) {
section->mEventloopNestingLevel = mEventloopNestingLevel;
nsCOMPtr<nsIThreadInternal> threadInternal = do_QueryInterface(thread);
NS_ASSERTION(threadInternal, "This should never fail!");
uint32_t recursionLevel;
if (NS_FAILED(threadInternal->GetRecursionDepth(&recursionLevel))) {
NS_ERROR("This should never fail!");
}
// Due to the weird way that the thread recursion counter is implemented we
// subtract one from the recursion level if we have one.
section->mThreadRecursionLevel = recursionLevel ? recursionLevel - 1 : 0;
}
// Ensure we've got a pending event, else the callbacks will never run.
if (!NS_HasPendingEvents(thread) && !DispatchDummyEvent(thread)) {
RunSyncSections(true, 0);
}
}
示例6: autoDestroy
nsresult
GMPVideoDecoderParent::Decode(GMPVideoEncodedFrame* aInputFrame,
bool aMissingFrames,
const nsTArray<uint8_t>& aCodecSpecificInfo,
int64_t aRenderTimeMs)
{
nsAutoRef<GMPVideoEncodedFrame> autoDestroy(aInputFrame);
if (!mCanSendMessages) {
NS_WARNING("Trying to use an invalid GMP video decoder!");
return NS_ERROR_FAILURE;
}
MOZ_ASSERT(mPlugin->GMPThread() == NS_GetCurrentThread());
auto inputFrameImpl = static_cast<GMPVideoEncodedFrameImpl*>(aInputFrame);
GMPVideoEncodedFrameData frameData;
inputFrameImpl->RelinquishFrameData(frameData);
// Very rough kill-switch if the plugin stops processing. If it's merely
// hung and continues, we'll come back to life eventually.
// 3* is because we're using 3 buffers per frame for i420 data for now.
if (NumInUse(kGMPFrameData) > 3*GMPSharedMemManager::kGMPBufLimit ||
NumInUse(kGMPEncodedData) > GMPSharedMemManager::kGMPBufLimit) {
return NS_ERROR_FAILURE;
}
if (!SendDecode(frameData,
aMissingFrames,
aCodecSpecificInfo,
aRenderTimeMs)) {
return NS_ERROR_FAILURE;
}
// Async IPC, we don't have access to a return value.
return NS_OK;
}
示例7: MOZ_ASSERT
NS_IMETHODIMP
GeckoMediaPluginService::GetDecryptingGMPVideoDecoder(GMPCrashHelper* aHelper,
nsTArray<nsCString>* aTags,
const nsACString& aNodeId,
UniquePtr<GetGMPVideoDecoderCallback>&& aCallback,
uint32_t aDecryptorId)
{
MOZ_ASSERT(NS_GetCurrentThread() == mGMPThread);
NS_ENSURE_ARG(aTags && aTags->Length() > 0);
NS_ENSURE_ARG(aCallback);
if (mShuttingDownOnGMPThread) {
return NS_ERROR_FAILURE;
}
GetGMPVideoDecoderCallback* rawCallback = aCallback.release();
RefPtr<AbstractThread> thread(GetAbstractGMPThread());
RefPtr<GMPCrashHelper> helper(aHelper);
GetContentParent(aHelper, aNodeId, NS_LITERAL_CSTRING(GMP_API_VIDEO_DECODER), *aTags)
->Then(thread, __func__,
[rawCallback, helper, aDecryptorId](RefPtr<GMPContentParent::CloseBlocker> wrapper) {
RefPtr<GMPContentParent> parent = wrapper->mParent;
UniquePtr<GetGMPVideoDecoderCallback> callback(rawCallback);
GMPVideoDecoderParent* actor = nullptr;
GMPVideoHostImpl* host = nullptr;
if (parent && NS_SUCCEEDED(parent->GetGMPVideoDecoder(&actor, aDecryptorId))) {
host = &(actor->Host());
actor->SetCrashHelper(helper);
}
callback->Done(actor, host);
},
[rawCallback] {
UniquePtr<GetGMPVideoDecoderCallback> callback(rawCallback);
callback->Done(nullptr, nullptr);
});
return NS_OK;
}
示例8: mName
ThreadInfo::ThreadInfo(const char* aName, int aThreadId,
bool aIsMainThread, PseudoStack* aPseudoStack,
void* aStackTop)
: mName(strdup(aName))
, mThreadId(aThreadId)
, mIsMainThread(aIsMainThread)
, mPseudoStack(aPseudoStack)
, mPlatformData(Sampler::AllocPlatformData(aThreadId))
, mProfile(nullptr)
, mStackTop(aStackTop)
, mPendingDelete(false)
{
MOZ_COUNT_CTOR(ThreadInfo);
#ifndef SPS_STANDALONE
mThread = NS_GetCurrentThread();
#endif
// We don't have to guess on mac
#ifdef XP_MACOSX
pthread_t self = pthread_self();
mStackTop = pthread_get_stackaddr_np(self);
#endif
}
示例9: MOZ_ASSERT
nsresult
GMPParent::Init(GeckoMediaPluginService *aService, nsIFile* aPluginDir)
{
MOZ_ASSERT(aPluginDir);
MOZ_ASSERT(aService);
MOZ_ASSERT(GMPThread() == NS_GetCurrentThread());
mService = aService;
mDirectory = aPluginDir;
nsAutoString leafname;
nsresult rv = aPluginDir->GetLeafName(leafname);
if (NS_FAILED(rv)) {
return rv;
}
LOGD(("%s::%s: %p for %s", __CLASS__, __FUNCTION__, this,
NS_LossyConvertUTF16toASCII(leafname).get()));
MOZ_ASSERT(leafname.Length() > 4);
mName = Substring(leafname, 4);
return ReadGMPMetaData();
}
示例10: Run
NS_IMETHOD Run()
{
MOZ_ASSERT(!NS_IsMainThread());
bool continueThread;
do {
continueThread = mDBusWatcher->Poll();
} while (continueThread);
mDBusWatcher->CleanUp();
nsIThread* thread;
nsresult rv = NS_GetCurrentThread(&thread);
NS_ENSURE_SUCCESS(rv, rv);
nsRefPtr<nsIRunnable> runnable =
NS_NewRunnableMethod(thread, &nsIThread::Shutdown);
rv = NS_DispatchToMainThread(runnable);
NS_ENSURE_SUCCESS(rv, rv);
return NS_OK;
}
示例11: MOZ_ASSERT
nsresult
GMPAudioDecoder::Init()
{
MOZ_ASSERT(IsOnGMPThread());
mMPS = do_GetService("@mozilla.org/gecko-media-plugin-service;1");
MOZ_ASSERT(mMPS);
nsCOMPtr<nsIThread> gmpThread = NS_GetCurrentThread();
nsRefPtr<GMPInitDoneRunnable> initDone(new GMPInitDoneRunnable());
gmpThread->Dispatch(
NS_NewRunnableMethodWithArg<GMPInitDoneRunnable*>(this,
&GMPAudioDecoder::GetGMPAPI,
initDone),
NS_DISPATCH_NORMAL);
while (!initDone->IsDone()) {
NS_ProcessNextEvent(gmpThread, true);
}
return mGMP ? NS_OK : NS_ERROR_FAILURE;
}
示例12: NS_InitXPCOM2
void*
WebRTCCall::State::WorkFunc(void* ptr)
{
nsRefPtr<State> self = static_cast<State*>(ptr);
NS_InitXPCOM2(nullptr, nullptr, nullptr);
NSS_NoDB_Init(nullptr);
NSS_SetDomesticPolicy();
nsresult rv;
rv = NS_GetCurrentThread(getter_AddRefs(self->mThread));
if (NS_FAILED(rv)) {
LOG("failed to get current thread\n");
return 0;
}
sipcc::IceConfiguration cfg;
self->mPeerConnection = sipcc::PeerConnectionImpl::CreatePeerConnection();
self->mPeerConnectionObserver = new PCObserver(self);
self->mPeerConnection->Initialize(*(self->mPeerConnectionObserver), nullptr, cfg, self->mThread.get());
self->mTimer = do_CreateInstance(NS_TIMER_CONTRACTID, &rv);
if (NS_FAILED(rv)) {
LOG("failed to create timer\n");
return 0;
}
self->mTimer->InitWithCallback(
self->mPeerConnectionObserver,
PR_MillisecondsToInterval(30),
nsITimer::TYPE_REPEATING_PRECISE);
while (self->mRunThread) { NS_ProcessNextEvent(nullptr, true); }
return nullptr;
}
示例13: MOZ_ASSERT
void
RegisterOperator::Reply(DNSServiceRef aSdRef,
DNSServiceFlags aFlags,
DNSServiceErrorType aErrorCode,
const nsACString& aName,
const nsACString& aRegType,
const nsACString& aDomain)
{
MOZ_ASSERT(GetThread() == NS_GetCurrentThread());
if (kDNSServiceErr_NoError != aErrorCode) {
LOG_E("RegisterOperator::Reply (%d)", aErrorCode);
}
if (!mListener) { return; }
nsCOMPtr<nsIDNSServiceInfo> info = new nsDNSServiceInfo(mServiceInfo);
if (NS_WARN_IF(NS_FAILED(info->SetServiceName(aName)))) { return; }
if (NS_WARN_IF(NS_FAILED(info->SetServiceType(aRegType)))) { return; }
if (NS_WARN_IF(NS_FAILED(info->SetDomainName(aDomain)))) { return; }
if (kDNSServiceErr_NoError == aErrorCode) {
if (aFlags & kDNSServiceFlagsAdd) {
mListener->OnServiceRegistered(info);
} else {
// If a successfully-registered name later suffers a name conflict
// or similar problem and has to be deregistered, the callback will
// be invoked with the kDNSServiceFlagsAdd flag not set.
LOG_E("RegisterOperator::Reply: deregister");
if (NS_WARN_IF(NS_FAILED(Stop()))) {
return;
}
}
} else {
mListener->OnRegistrationFailed(info, aErrorCode);
}
}
示例14: NS_ENSURE_ARG_POINTER
NS_IMETHODIMP
calICSService::ParseICSAsync(const nsACString& serialized,
calITimezoneProvider *tzProvider,
calIIcsComponentParsingListener *listener)
{
nsresult rv;
NS_ENSURE_ARG_POINTER(listener);
nsCOMPtr<nsIThread> workerThread;
nsCOMPtr<nsIThread> currentThread;
rv = NS_GetCurrentThread(getter_AddRefs(currentThread));
NS_ENSURE_SUCCESS(rv, rv);
rv = NS_NewThread(getter_AddRefs(workerThread));
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIRunnable> worker = new ParserWorker(currentThread, workerThread,
serialized, tzProvider, listener);
NS_ENSURE_TRUE(worker, NS_ERROR_OUT_OF_MEMORY);
rv = workerThread->Dispatch(worker, NS_DISPATCH_NORMAL);
NS_ENSURE_SUCCESS(rv, rv);
return NS_OK;
}
示例15: NS_ABORT_IF_FALSE
PRStatus
nsSOCKSSocketInfo::StartDNS(PRFileDesc *fd)
{
NS_ABORT_IF_FALSE(!mDnsRec && mState == SOCKS_INITIAL,
"Must be in initial state to make DNS Lookup");
nsCOMPtr<nsIDNSService> dns = do_GetService(NS_DNSSERVICE_CONTRACTID);
if (!dns)
return PR_FAILURE;
mFD = fd;
nsresult rv = dns->AsyncResolve(mProxyHost, 0, this,
NS_GetCurrentThread(),
getter_AddRefs(mLookup));
if (NS_FAILED(rv)) {
LOGERROR(("socks: DNS lookup for SOCKS proxy %s failed",
mProxyHost.get()));
return PR_FAILURE;
}
mState = SOCKS_DNS_IN_PROGRESS;
PR_SetError(PR_IN_PROGRESS_ERROR, 0);
return PR_FAILURE;
}