本文整理汇总了C++中RuntimeService类的典型用法代码示例。如果您正苦于以下问题:C++ RuntimeService类的具体用法?C++ RuntimeService怎么用?C++ RuntimeService使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了RuntimeService类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AssertIsOnMainThread
// static
already_AddRefed<SharedWorker>
SharedWorker::Constructor(const GlobalObject& aGlobal, JSContext* aCx,
const nsAString& aScriptURL,
const mozilla::dom::Optional<nsAString>& aName,
ErrorResult& aRv)
{
AssertIsOnMainThread();
RuntimeService* rts = RuntimeService::GetOrCreateService();
if (!rts) {
aRv = NS_ERROR_NOT_AVAILABLE;
return nullptr;
}
nsString name;
if (aName.WasPassed()) {
name = aName.Value();
}
nsRefPtr<SharedWorker> sharedWorker;
nsresult rv = rts->CreateSharedWorker(aGlobal, aScriptURL, name,
getter_AddRefs(sharedWorker));
if (NS_FAILED(rv)) {
aRv = rv;
return nullptr;
}
return sharedWorker.forget();
}
示例2:
uint64_t
WorkerNavigator::HardwareConcurrency() const
{
RuntimeService* rts = RuntimeService::GetService();
MOZ_ASSERT(rts);
return rts->ClampedHardwareConcurrency();
}
示例3: ResumeWorkersForWindow
void
ResumeWorkersForWindow(JSContext* aCx, nsPIDOMWindow* aWindow)
{
AssertIsOnMainThread();
RuntimeService* runtime = RuntimeService::GetService();
if (runtime) {
runtime->ResumeWorkersForWindow(aCx, aWindow);
}
}
示例4: MOZ_ASSERT
/* static */ already_AddRefed<WorkerNavigator>
WorkerNavigator::Create(bool aOnLine)
{
RuntimeService* rts = RuntimeService::GetService();
MOZ_ASSERT(rts);
const RuntimeService::NavigatorProperties& properties =
rts->GetNavigatorProperties();
nsRefPtr<WorkerNavigator> navigator =
new WorkerNavigator(properties, aOnLine);
return navigator.forget();
}
示例5: MOZ_ASSERT
/* static */ already_AddRefed<WorkerNavigator>
WorkerNavigator::Create(bool aOnLine)
{
RuntimeService* rts = RuntimeService::GetService();
MOZ_ASSERT(rts);
const RuntimeService::NavigatorProperties& properties =
rts->GetNavigatorProperties();
nsRefPtr<WorkerNavigator> navigator =
new WorkerNavigator(properties.mAppName, properties.mAppVersion,
properties.mPlatform, properties.mUserAgent,
properties.mLanguages, aOnLine);
return navigator.forget();
}
示例6: MOZ_ASSERT
BEGIN_WORKERS_NAMESPACE
/* static */ already_AddRefed<WorkerNavigator>
WorkerNavigator::Create(JSContext* aCx, JS::Handle<JSObject*> aGlobal)
{
RuntimeService* rts = RuntimeService::GetService();
MOZ_ASSERT(rts);
const RuntimeService::NavigatorStrings& strings =
rts->GetNavigatorStrings();
nsRefPtr<WorkerNavigator> navigator =
new WorkerNavigator(aCx, strings.mAppName, strings.mAppVersion,
strings.mPlatform, strings.mUserAgent);
if (!Wrap(aCx, aGlobal, navigator)) {
return nullptr;
}
return navigator.forget();
}
示例7: str
void
WorkerGlobalScope::Dump(const Optional<nsAString>& aString) const
{
mWorkerPrivate->AssertIsOnWorkerThread();
if (!aString.WasPassed()) {
return;
}
RuntimeService* runtimeService = RuntimeService::GetService();
MOZ_ASSERT(runtimeService);
if (!runtimeService->WorkersDumpEnabled()) {
return;
}
NS_ConvertUTF16toUTF8 str(aString.Value());
#ifdef ANDROID
__android_log_print(ANDROID_LOG_INFO, "Gecko", "%s", str.get());
#endif
fputs(str.get(), stdout);
fflush(stdout);
}
示例8: do_CreateInstance
nsresult
FileReaderSync::GuessCharset(nsIInputStream *aStream, nsACString &aCharset)
{
// First try the universal charset detector
nsCOMPtr<nsICharsetDetector> detector
= do_CreateInstance(NS_CHARSET_DETECTOR_CONTRACTID_BASE
"universal_charset_detector");
if (!detector) {
RuntimeService* runtime = RuntimeService::GetService();
NS_ASSERTION(runtime, "This should never be null!");
// No universal charset detector, try the default charset detector
const nsACString& detectorName = runtime->GetDetectorName();
if (!detectorName.IsEmpty()) {
nsAutoCString detectorContractID;
detectorContractID.AssignLiteral(NS_CHARSET_DETECTOR_CONTRACTID_BASE);
detectorContractID += detectorName;
detector = do_CreateInstance(detectorContractID.get());
}
}
nsresult rv;
if (detector) {
detector->Init(this);
bool done;
uint32_t numRead;
do {
char readBuf[4096];
rv = aStream->Read(readBuf, sizeof(readBuf), &numRead);
NS_ENSURE_SUCCESS(rv, rv);
if (numRead <= 0) {
break;
}
rv = detector->DoIt(readBuf, numRead, &done);
NS_ENSURE_SUCCESS(rv, rv);
} while (!done);
rv = detector->Done();
NS_ENSURE_SUCCESS(rv, rv);
} else {
// no charset detector available, check the BOM
unsigned char sniffBuf[4];
uint32_t numRead;
rv = aStream->Read(reinterpret_cast<char*>(sniffBuf),
sizeof(sniffBuf), &numRead);
NS_ENSURE_SUCCESS(rv, rv);
if (numRead >= 2 &&
sniffBuf[0] == 0xfe &&
sniffBuf[1] == 0xff) {
mCharset = "UTF-16BE";
} else if (numRead >= 2 &&
sniffBuf[0] == 0xff &&
sniffBuf[1] == 0xfe) {
mCharset = "UTF-16LE";
} else if (numRead >= 3 &&
sniffBuf[0] == 0xef &&
sniffBuf[1] == 0xbb &&
sniffBuf[2] == 0xbf) {
mCharset = "UTF-8";
}
}
if (mCharset.IsEmpty()) {
RuntimeService* runtime = RuntimeService::GetService();
mCharset = runtime->GetSystemCharset();
}
if (mCharset.IsEmpty()) {
// no sniffed or default charset, try UTF-8
mCharset.AssignLiteral("UTF-8");
}
aCharset = mCharset;
mCharset.Truncate();
return NS_OK;
}