本文整理匯總了C++中EnsureInitialized函數的典型用法代碼示例。如果您正苦於以下問題:C++ EnsureInitialized函數的具體用法?C++ EnsureInitialized怎麽用?C++ EnsureInitialized使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了EnsureInitialized函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: EnsureInitialized
NS_IMETHODIMP nsAbBSDirectory::GetChildNodes(nsISimpleEnumerator* *aResult)
{
nsresult rv = EnsureInitialized();
NS_ENSURE_SUCCESS(rv, rv);
return NS_NewArrayEnumerator(aResult, mSubDirectories);
}
示例2: MOZ_ASSERT
TemporaryRef<SharedThreadPool>
SharedThreadPool::Get(const nsCString& aName, uint32_t aThreadLimit)
{
MOZ_ASSERT(NS_IsMainThread());
EnsureInitialized();
MOZ_ASSERT(sMonitor);
ReentrantMonitorAutoEnter mon(*sMonitor);
SharedThreadPool* pool = nullptr;
nsresult rv;
if (!sPools->Get(aName, &pool)) {
nsCOMPtr<nsIThreadPool> threadPool(CreateThreadPool(aName));
NS_ENSURE_TRUE(threadPool, nullptr);
pool = new SharedThreadPool(aName, threadPool);
// Set the thread and idle limits. Note that we don't rely on the
// EnsureThreadLimitIsAtLeast() call below, as the default thread limit
// is 4, and if aThreadLimit is less than 4 we'll end up with a pool
// with 4 threads rather than what we expected; so we'll have unexpected
// behaviour.
rv = pool->SetThreadLimit(aThreadLimit);
NS_ENSURE_SUCCESS(rv, nullptr);
rv = pool->SetIdleThreadLimit(aThreadLimit);
NS_ENSURE_SUCCESS(rv, nullptr);
sPools->Put(aName, pool);
} else if (NS_FAILED(pool->EnsureThreadLimitIsAtLeast(aThreadLimit))) {
NS_WARNING("Failed to set limits on thread pool");
}
MOZ_ASSERT(pool);
RefPtr<SharedThreadPool> instance(pool);
return instance.forget();
}
示例3: _tprintf
HRESULT Service_Monitor::GetServiceHandle(LPCTSTR pServiceName, SC_HANDLE* pHandle)
{
HRESULT hr = S_OK;
if (pServiceName == NULL)
{
_tprintf(L"\nERROR: Null parameter for GetServiceHandle()\n");
hr = HRESULT_FROM_WIN32(ERROR_INVALID_PARAMETER);
goto Finished;
}
hr = EnsureInitialized();
if (SUCCEEDED(hr))
{
*pHandle = OpenService(_hSCManager, pServiceName, SERVICE_START | SERVICE_STOP | SERVICE_QUERY_STATUS);
if (*pHandle == NULL)
{
hr = HRESULT_FROM_WIN32(GetLastError());
goto Finished;
}
}
Finished:
return hr;
}
示例4: EnsureInitialized
NS_IMETHODIMP
GfxInfo::GetAdapterDriverDate(nsAString & aAdapterDriverDate)
{
EnsureInitialized();
aAdapterDriverDate.Truncate();
return NS_OK;
}
示例5: NS_URIChainHasFlags
NS_IMETHODIMP
nsCookiePermission::CanAccess(nsIURI *aURI,
nsIChannel *aChannel,
nsCookieAccess *aResult)
{
// Check this protocol doesn't allow cookies
bool hasFlags;
nsresult rv =
NS_URIChainHasFlags(aURI, nsIProtocolHandler::URI_FORBIDS_COOKIE_ACCESS,
&hasFlags);
if (NS_FAILED(rv) || hasFlags) {
*aResult = ACCESS_DENY;
return NS_OK;
}
// Lazily initialize ourselves
if (!EnsureInitialized())
return NS_ERROR_UNEXPECTED;
// finally, check with permission manager...
rv = mPermMgr->TestPermission(aURI, kPermissionType, (uint32_t *) aResult);
if (NS_SUCCEEDED(rv)) {
if (*aResult == nsICookiePermission::ACCESS_SESSION) {
*aResult = nsICookiePermission::ACCESS_ALLOW;
}
}
return rv;
}
示例6: Start
Result HDevice::Start()
{
HRESULT hr;
if (!EnsureInitialized(L"Start") ||
!EnsureInactive(L"Start"))
return Result::Error;
if (!!rocketEncoder)
Sleep(ROCKET_WAIT_TIME_MS);
hr = control->Run();
if (FAILED(hr)) {
if (hr == (HRESULT)0x8007001F) {
WarningHR(L"Run failed, device already in use", hr);
return Result::InUse;
} else {
WarningHR(L"Run failed", hr);
return Result::Error;
}
}
active = true;
return Result::Success;
}
示例7: SetAudioConfig
bool HDevice::SetAudioConfig(AudioConfig *config)
{
ComPtr<IBaseFilter> filter;
if (!EnsureInitialized(L"SetAudioConfig") ||
!EnsureInactive(L"SetAudioConfig"))
return false;
if (!audioConfig.useVideoDevice)
graph->RemoveFilter(audioFilter);
graph->RemoveFilter(audioCapture);
graph->RemoveFilter(audioOutput);
audioFilter.Release();
audioCapture.Release();
audioOutput.Release();
audioMediaType = NULL;
if (!config)
return true;
if (!config->useVideoDevice &&
config->name.empty() && config->path.empty()) {
Error(L"No audio device name or path specified");
return false;
}
if (config->useVideoDevice) {
if (videoFilter == NULL) {
Error(L"Tried to use video device's built-in audio, "
L"but no video device is present");
return false;
}
filter = videoFilter;
} else {
bool success = GetDeviceFilter(CLSID_AudioInputDeviceCategory,
config->name.c_str(), config->path.c_str(),
&filter);
if (!success) {
Error(L"Audio device '%s': %s not found", config->name.c_str(),
config->path.c_str());
return false;
}
}
if (filter == NULL)
return false;
audioConfig = *config;
if (config->mode == AudioMode::Capture) {
if (!SetupAudioCapture(filter, audioConfig))
return false;
*config = audioConfig;
return true;
}
return SetupAudioOutput(filter, audioConfig);
}
示例8: GetAndroidUsage
int
AndroidGraphicBuffer::Lock(uint32_t aUsage, unsigned char **bits)
{
if (!EnsureInitialized())
return true;
return sGLFunctions.fGraphicBufferLock(mHandle, GetAndroidUsage(aUsage), bits);
}
示例9:
int
AndroidGraphicBuffer::Unlock()
{
if (!EnsureInitialized())
return false;
return sGLFunctions.fGraphicBufferUnlock(mHandle);
}
示例10: EnsureInitialized
NS_IMETHODIMP
nsIEHistoryEnumerator::HasMoreElements(bool* _retval)
{
*_retval = false;
EnsureInitialized();
MOZ_ASSERT(mURLEnumerator, "Should have instanced an IE History URLEnumerator");
if (!mURLEnumerator)
return NS_OK;
STATURL statURL;
ULONG fetched;
// First argument is not implemented, so doesn't matter what we pass.
HRESULT hr = mURLEnumerator->Next(1, &statURL, &fetched);
if (FAILED(hr) || fetched != 1UL) {
// Reached the last entry.
return NS_OK;
}
nsCOMPtr<nsIURI> uri;
if (statURL.pwcsUrl) {
nsDependentString url(statURL.pwcsUrl);
nsresult rv = NS_NewURI(getter_AddRefs(uri), url);
::CoTaskMemFree(statURL.pwcsUrl);
if (NS_FAILED(rv)) {
// Got a corrupt or invalid URI, continue to the next entry.
return HasMoreElements(_retval);
}
}
nsDependentString title(statURL.pwcsTitle ? statURL.pwcsTitle : L"");
bool lastVisitTimeIsValid;
PRTime lastVisited = WinMigrationFileTimeToPRTime(&(statURL.ftLastVisited), &lastVisitTimeIsValid);
mCachedNextEntry = do_CreateInstance("@mozilla.org/hash-property-bag;1");
MOZ_ASSERT(mCachedNextEntry, "Should have instanced a new property bag");
if (mCachedNextEntry) {
mCachedNextEntry->SetPropertyAsInterface(NS_LITERAL_STRING("uri"), uri);
mCachedNextEntry->SetPropertyAsAString(NS_LITERAL_STRING("title"), title);
if (lastVisitTimeIsValid) {
mCachedNextEntry->SetPropertyAsInt64(NS_LITERAL_STRING("time"), lastVisited);
}
*_retval = true;
}
if (statURL.pwcsTitle)
::CoTaskMemFree(statURL.pwcsTitle);
return NS_OK;
}
示例11:
bool
GLXLibrary::SupportsTextureFromPixmap(gfxASurface* aSurface)
{
if (!EnsureInitialized(mLibType)) {
return false;
}
if (aSurface->GetType() != gfxSurfaceTypeXlib || !mUseTextureFromPixmap) {
return false;
}
return true;
}
示例12: NS_ENSURE_ARG_POINTER
NS_IMETHODIMP nsAbBSDirectory::DeleteDirectory(nsIAbDirectory *directory)
{
NS_ENSURE_ARG_POINTER(directory);
nsresult rv = EnsureInitialized();
NS_ENSURE_SUCCESS(rv, rv);
DIR_Server *server = nsnull;
mServers.Get(directory, &server);
if (!server)
return NS_ERROR_FAILURE;
GetDirectories getDirectories(server);
mServers.EnumerateRead(GetDirectories_getDirectory,
(void*)&getDirectories);
DIR_DeleteServerFromList(server);
nsCOMPtr<nsIAbDirFactoryService> dirFactoryService =
do_GetService(NS_ABDIRFACTORYSERVICE_CONTRACTID,&rv);
NS_ENSURE_SUCCESS (rv, rv);
PRUint32 count = getDirectories.directories.Count();
nsCOMPtr<nsIAbManager> abManager = do_GetService(NS_ABMANAGER_CONTRACTID);
for (PRUint32 i = 0; i < count; i++) {
nsCOMPtr<nsIAbDirectory> d = getDirectories.directories[i];
mServers.Remove(d);
rv = mSubDirectories.RemoveObject(d);
if (abManager)
abManager->NotifyDirectoryDeleted(this, d);
nsCOMPtr<nsIRDFResource> resource(do_QueryInterface (d, &rv));
nsCString uri;
resource->GetValueUTF8(uri);
nsCOMPtr<nsIAbDirFactory> dirFactory;
rv = dirFactoryService->GetDirFactory(uri, getter_AddRefs(dirFactory));
if (NS_FAILED(rv))
continue;
rv = dirFactory->DeleteDirectory(d);
}
return rv;
}
示例13: ensureNoGLError
bool
AndroidGraphicBuffer::Bind()
{
if (!EnsureInitialized())
return false;
if (!EnsureEGLImage()) {
LOG("No valid EGLImage!");
return false;
}
clearGLError();
sGLFunctions.fImageTargetTexture2DOES(GL_TEXTURE_2D, mEGLImage);
return ensureNoGLError("glEGLImageTargetTexture2DOES");
}
示例14:
NS_IMETHODIMP
nsCookiePermission::SetAccess(nsIURI *aURI,
nsCookieAccess aAccess)
{
// Lazily initialize ourselves
if (!EnsureInitialized())
return NS_ERROR_UNEXPECTED;
//
// NOTE: nsCookieAccess values conveniently match up with
// the permission codes used by nsIPermissionManager.
// this is nice because it avoids conversion code.
//
return mPermMgr->Add(aURI, kPermissionType, aAccess,
nsIPermissionManager::EXPIRE_NEVER, 0);
}
示例15: EnsureInitialized
HRESULT CKpInternetStream::ReadPartial(BYTE* pbBuffer, UINT64 uCount,
UINT64* puRead)
{
EnsureInitialized();
if(m_hFile == NULL) { if(puRead != NULL) *puRead = 0; return STG_E_INVALIDHANDLE; }
if(pbBuffer == NULL) CKPIS_R_FAIL(E_POINTER);
if(uCount > static_cast<UINT64>(DWORD_MAX)) CKPIS_R_FAIL(E_INVALIDARG);
DWORD dwRead = 0;
const BOOL bRes = InternetReadFile(m_hFile, pbBuffer, static_cast<DWORD>(
uCount), &dwRead);
if(bRes == FALSE) CKPIS_R_FAIL(STG_E_READFAULT);
if(puRead != NULL) *puRead = dwRead;
return S_OK;
}