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


C++ EnsureInitialized函数代码示例

本文整理汇总了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);
}
开发者ID:binoc-software,项目名称:mozilla-cvs,代码行数:7,代码来源:nsAbBSDirectory.cpp

示例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();
}
开发者ID:AOSC-Dev,项目名称:Pale-Moon,代码行数:34,代码来源:SharedThreadPool.cpp

示例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;
}
开发者ID:jawn,项目名称:IIS.ServiceMonitor,代码行数:25,代码来源:ServiceMonitor.cpp

示例4: EnsureInitialized

NS_IMETHODIMP
GfxInfo::GetAdapterDriverDate(nsAString & aAdapterDriverDate)
{
  EnsureInitialized();
  aAdapterDriverDate.Truncate();
  return NS_OK;
}
开发者ID:MichaelKohler,项目名称:gecko-dev,代码行数:7,代码来源:GfxInfo.cpp

示例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;
}
开发者ID:ajkerrigan,项目名称:gecko-dev,代码行数:29,代码来源:nsCookiePermission.cpp

示例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;
}
开发者ID:Inner-room,项目名称:libdshowcapture,代码行数:26,代码来源:device.cpp

示例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);
}
开发者ID:Inner-room,项目名称:libdshowcapture,代码行数:60,代码来源:device.cpp

示例8: GetAndroidUsage

int
AndroidGraphicBuffer::Lock(uint32_t aUsage, unsigned char **bits)
{
  if (!EnsureInitialized())
    return true;

  return sGLFunctions.fGraphicBufferLock(mHandle, GetAndroidUsage(aUsage), bits);
}
开发者ID:drexler,项目名称:releases-mozilla-aurora,代码行数:8,代码来源:AndroidGraphicBuffer.cpp

示例9:

int
AndroidGraphicBuffer::Unlock()
{
  if (!EnsureInitialized())
    return false;

  return sGLFunctions.fGraphicBufferUnlock(mHandle);
}
开发者ID:drexler,项目名称:releases-mozilla-aurora,代码行数:8,代码来源:AndroidGraphicBuffer.cpp

示例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;
}
开发者ID:escapewindow,项目名称:gecko-dev,代码行数:53,代码来源:nsIEHistoryEnumerator.cpp

示例11:

bool
GLXLibrary::SupportsTextureFromPixmap(gfxASurface* aSurface)
{
    if (!EnsureInitialized(mLibType)) {
        return false;
    }
    
    if (aSurface->GetType() != gfxSurfaceTypeXlib || !mUseTextureFromPixmap) {
        return false;
    }

    return true;
}
开发者ID:huili2,项目名称:gecko-dev,代码行数:13,代码来源:GLContextProviderGLX.cpp

示例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;
}
开发者ID:binoc-software,项目名称:mozilla-cvs,代码行数:50,代码来源:nsAbBSDirectory.cpp

示例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");
}
开发者ID:drexler,项目名称:releases-mozilla-aurora,代码行数:15,代码来源:AndroidGraphicBuffer.cpp

示例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);
}
开发者ID:FunkyVerb,项目名称:devtools-window,代码行数:16,代码来源:nsCookiePermission.cpp

示例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;
}
开发者ID:xt9852,项目名称:KeePassXT,代码行数:17,代码来源:KpInternetStream.cpp


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