本文整理汇总了C++中nsACString::Data方法的典型用法代码示例。如果您正苦于以下问题:C++ nsACString::Data方法的具体用法?C++ nsACString::Data怎么用?C++ nsACString::Data使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nsACString
的用法示例。
在下文中一共展示了nsACString::Data方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
nsCString
PendingLookup::EscapeFingerprint(const nsACString& aFingerprint)
{
// Google's fingerprint doesn't have colons
nsCString escaped;
escaped.SetCapacity(aFingerprint.Length());
for (unsigned int i = 0; i < aFingerprint.Length(); ++i) {
if (aFingerprint.Data()[i] != ':') {
escaped.Append(aFingerprint.Data()[i]);
}
}
return escaped;
}
示例2: SupportsMimeType
bool AndroidDecoderModule::SupportsMimeType(const nsACString& aMimeType) {
if (jni::GetAPIVersion() < 16) {
return false;
}
if (aMimeType.EqualsLiteral("video/mp4") ||
aMimeType.EqualsLiteral("video/avc")) {
return true;
}
// When checking "audio/x-wav", CreateDecoder can cause a JNI ERROR by
// Accessing a stale local reference leading to a SIGSEGV crash.
// To avoid this we check for wav types here.
if (aMimeType.EqualsLiteral("audio/x-wav") ||
aMimeType.EqualsLiteral("audio/wave; codecs=1") ||
aMimeType.EqualsLiteral("audio/wave; codecs=6") ||
aMimeType.EqualsLiteral("audio/wave; codecs=7") ||
aMimeType.EqualsLiteral("audio/wave; codecs=65534")) {
return false;
}
if ((VPXDecoder::IsVPX(aMimeType, VPXDecoder::VP8) &&
!GetFeatureStatus(nsIGfxInfo::FEATURE_VP8_HW_DECODE)) ||
(VPXDecoder::IsVPX(aMimeType, VPXDecoder::VP9) &&
!GetFeatureStatus(nsIGfxInfo::FEATURE_VP9_HW_DECODE))) {
return false;
}
// Prefer the gecko decoder for opus and vorbis; stagefright crashes
// on content demuxed from mp4.
// Not all android devices support FLAC even when they say they do.
if (OpusDataDecoder::IsOpus(aMimeType) ||
VorbisDataDecoder::IsVorbis(aMimeType) ||
aMimeType.EqualsLiteral("audio/flac")) {
SLOG("Rejecting audio of type %s", aMimeType.Data());
return false;
}
// Prefer the gecko decoder for Theora.
// Not all android devices support Theora even when they say they do.
if (TheoraDecoder::IsTheora(aMimeType)) {
SLOG("Rejecting video of type %s", aMimeType.Data());
return false;
}
return java::HardwareCodecCapabilityUtils::FindDecoderCodecInfoForMimeType(
TranslateMimeType(aMimeType));
}
示例3: memcmp
static bool
StartsWith(const nsACString& string, const char (&prefix)[N])
{
if (N - 1 > string.Length()) {
return false;
}
return memcmp(string.Data(), prefix, N - 1) == 0;
}
示例4: memcpy
void
nsSOCKSSocketInfo::WriteString(const nsACString &str)
{
NS_ABORT_IF_FALSE(mDataLength + str.Length() <= BUFFER_SIZE,
"Can't write that much data!");
memcpy(mData + mDataLength, str.Data(), str.Length());
mDataLength += str.Length();
}
示例5: if
nsCString
PendingLookup::EscapeCertificateAttribute(const nsACString& aAttribute)
{
// Escape '/' because it's a field separator, and '%' because Chrome does
nsCString escaped;
escaped.SetCapacity(aAttribute.Length());
for (unsigned int i = 0; i < aAttribute.Length(); ++i) {
if (aAttribute.Data()[i] == '%') {
escaped.AppendLiteral("%25");
} else if (aAttribute.Data()[i] == '/') {
escaped.AppendLiteral("%2F");
} else if (aAttribute.Data()[i] == ' ') {
escaped.AppendLiteral("%20");
} else {
escaped.Append(aAttribute.Data()[i]);
}
}
return escaped;
}
示例6: mApplicationUID
ProbeManager::ProbeManager(const nsCID &aApplicationUID,
const nsACString &aApplicationName)
: mApplicationUID(aApplicationUID)
, mApplicationName(aApplicationName)
, mSessionHandle(0)
, mRegistrationHandle(0)
{
#if defined(MOZ_LOGGING)
char cidStr[NSID_LENGTH];
aApplicationUID.ToProvidedString(cidStr);
LOG(("ProbeManager::Init for application %s, %s",
aApplicationName.Data(), cidStr));
#endif
}
示例7: LOG
nsresult
PendingDBLookup::LookupSpec(const nsACString& aSpec,
bool aAllowlistOnly)
{
LOG(("Checking principal %s [this=%p]", aSpec.Data(), this));
mSpec = aSpec;
mAllowlistOnly = aAllowlistOnly;
nsresult rv = LookupSpecInternal(aSpec);
if (NS_FAILED(rv)) {
LOG(("Error in LookupSpecInternal"));
return mPendingLookup->OnComplete(false, NS_OK);
}
// LookupSpecInternal has called nsIUrlClassifierCallback.lookup, which is
// guaranteed to call HandleEvent.
return rv;
}
示例8: OriginFilter
void
GeckoMediaPluginServiceParent::ForgetThisSiteOnGMPThread(const nsACString& aSite)
{
MOZ_ASSERT(NS_GetCurrentThread() == mGMPThread);
LOGD(("%s::%s: origin=%s", __CLASS__, __FUNCTION__, aSite.Data()));
struct OriginFilter : public DirectoryFilter {
explicit OriginFilter(const nsACString& aSite) : mSite(aSite) {}
virtual bool operator()(nsIFile* aPath) {
return MatchOrigin(aPath, mSite);
}
private:
const nsACString& mSite;
} filter(aSite);
ClearNodeIdAndPlugin(filter);
}
示例9: IsDocumentElement
/**
* Determines whether or not a string exists as the root element in an XML data
* string buffer.
* @param dataString
* The data being sniffed
* @param substring
* The substring being tested for existence and root-ness.
* @returns true if the substring exists and is the documentElement, false
* otherwise.
*/
static bool
ContainsTopLevelSubstring(nsACString& dataString, const char *substring)
{
nsACString::const_iterator start, end;
dataString.BeginReading(start);
dataString.EndReading(end);
if (!FindInReadable(nsCString(substring), start, end)){
return false;
}
auto offset = start.get() - dataString.Data();
const char *begin = dataString.BeginReading();
// Only do the validation when we find the substring.
return IsDocumentElement(begin, begin + offset);
}
示例10:
static nsresult
WriteDataToFile(nsIFile* aFile, const nsACString& data)
{
nsCOMPtr<nsILocalFile> localFile = do_QueryInterface(aFile);
NS_ENSURE_TRUE(localFile, NS_ERROR_FAILURE);
PRFileDesc* fd;
nsresult rv = localFile->OpenNSPRFileDesc(PR_WRONLY | PR_CREATE_FILE, 00600,
&fd);
NS_ENSURE_SUCCESS(rv, rv);
rv = NS_OK;
if (PR_Write(fd, data.Data(), data.Length()) == -1) {
rv = NS_ERROR_FAILURE;
}
PR_Close(fd);
return rv;
}
示例11:
/* static */ bool
PureOmxPlatformLayer::FindStandardComponent(const nsACString& aMimeType,
nsACString* aComponentName)
{
nsAutoCString role;
if (!GetStandardComponentRole(aMimeType, role))
return false;
OMX_U32 nComponents = 0;
OMX_ERRORTYPE err;
err = OMX_GetComponentsOfRole(const_cast<OMX_STRING>(role.Data()),
&nComponents, nullptr);
if (err != OMX_ErrorNone || nComponents <= 0) {
return false;
}
if (!aComponentName) {
return true;
}
// TODO:
// Only the first component will be used.
// We should detect the most preferred component.
OMX_U8* componentNames[1];
UniquePtr<OMX_U8[]> componentName;
componentName = MakeUniqueFallible<OMX_U8[]>(OMX_MAX_STRINGNAME_SIZE);
componentNames[0] = componentName.get();
nComponents = 1;
err = OMX_GetComponentsOfRole(const_cast<OMX_STRING>(role.Data()),
&nComponents, componentNames);
if (err == OMX_ErrorNone) {
MOZ_LOG(sPDMLog, mozilla::LogLevel::Debug,
("PureOmxPlatformLayer::%s: A component has been found for %s: %s",
__func__, aMimeType.Data(), componentNames[0]));
aComponentName->Assign(reinterpret_cast<char*>(componentNames[0]));
}
return err == OMX_ErrorNone;
}
示例12: promise
void
MediaKeys::OnCDMCreated(PromiseId aId, const nsACString& aNodeId, const nsACString& aPluginId)
{
nsRefPtr<Promise> promise(RetrievePromise(aId));
if (!promise) {
return;
}
mNodeId = aNodeId;
nsRefPtr<MediaKeys> keys(this);
EME_LOG("MediaKeys[%p]::OnCDMCreated() resolve promise id=%d", this, aId);
promise->MaybeResolve(keys);
if (mCreatePromiseId == aId) {
Release();
}
MediaKeySystemAccess::NotifyObservers(mParent,
mKeySystem,
MediaKeySystemStatus::Cdm_created);
if (!aPluginId.IsEmpty()) {
// Prepare plugin crash reporter.
nsRefPtr<gmp::GeckoMediaPluginService> service =
gmp::GeckoMediaPluginService::GetGeckoMediaPluginService();
if (NS_WARN_IF(!service)) {
return;
}
if (NS_WARN_IF(!mParent)) {
return;
}
nsCOMPtr<nsIDocument> doc = mParent->GetExtantDoc();
if (NS_WARN_IF(!doc)) {
return;
}
service->AddPluginCrashCallback(new CrashHandler(aPluginId, mParent, doc));
EME_LOG("MediaKeys[%p]::OnCDMCreated() registered crash handler for pluginId '%s'",
this, aPluginId.Data());
}
}
示例13: GetFile
bool
CreateFile(const nsACString& aData)
{
nsCOMPtr<nsIFile> file = GetFile();
nsCOMPtr<nsIOutputStream> stream;
nsresult rv = NS_NewLocalFileOutputStream(getter_AddRefs(stream), file);
if (NS_WARN_IF(NS_FAILED(rv))) {
return false;
}
uint32_t count;
rv = stream->Write(aData.Data(), aData.Length(), &count);
if (NS_WARN_IF(NS_FAILED(rv))) {
return false;
}
if (count != aData.Length()) {
return false;
}
return true;
}
示例14: LoadContext
nsresult
nsUrlClassifierStreamUpdater::FetchUpdate(nsIURI *aUpdateUrl,
const nsACString & aRequestBody,
const nsACString & aStreamTable)
{
#ifdef DEBUG
{
nsCString spec;
aUpdateUrl->GetSpec(spec);
LOG(("Fetching update %s from %s", aRequestBody.Data(), spec.get()));
}
#endif
nsresult rv;
uint32_t loadFlags = nsIChannel::INHIBIT_CACHING |
nsIChannel::LOAD_BYPASS_CACHE;
rv = NS_NewChannel(getter_AddRefs(mChannel),
aUpdateUrl,
nsContentUtils::GetSystemPrincipal(),
nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL,
nsIContentPolicy::TYPE_OTHER,
nullptr, // aLoadGroup
this, // aInterfaceRequestor
loadFlags);
NS_ENSURE_SUCCESS(rv, rv);
mBeganStream = false;
// If aRequestBody is empty, construct it for the test.
if (!aRequestBody.IsEmpty()) {
rv = AddRequestBody(aRequestBody);
NS_ENSURE_SUCCESS(rv, rv);
}
// Set the appropriate content type for file/data URIs, for unit testing
// purposes.
// This is only used for testing and should be deleted.
bool match;
if ((NS_SUCCEEDED(aUpdateUrl->SchemeIs("file", &match)) && match) ||
(NS_SUCCEEDED(aUpdateUrl->SchemeIs("data", &match)) && match)) {
mChannel->SetContentType(NS_LITERAL_CSTRING("application/vnd.google.safebrowsing-update"));
} else {
// We assume everything else is an HTTP request.
// Disable keepalive.
nsCOMPtr<nsIHttpChannel> httpChannel = do_QueryInterface(mChannel, &rv);
NS_ENSURE_SUCCESS(rv, rv);
rv = httpChannel->SetRequestHeader(NS_LITERAL_CSTRING("Connection"), NS_LITERAL_CSTRING("close"), false);
NS_ENSURE_SUCCESS(rv, rv);
}
// Create a custom LoadContext for SafeBrowsing, so we can use callbacks on
// the channel to query the appId which allows separation of safebrowsing
// cookies in a separate jar.
nsCOMPtr<nsIInterfaceRequestor> sbContext =
new mozilla::LoadContext(NECKO_SAFEBROWSING_APP_ID);
rv = mChannel->SetNotificationCallbacks(sbContext);
NS_ENSURE_SUCCESS(rv, rv);
// Make the request.
rv = mChannel->AsyncOpen2(this);
NS_ENSURE_SUCCESS(rv, rv);
mStreamTable = aStreamTable;
return NS_OK;
}
示例15: FetchUpdate
NS_IMETHODIMP
nsUrlClassifierStreamUpdater::DownloadUpdates(
const nsACString &aRequestTables,
const nsACString &aRequestBody,
const nsACString &aUpdateUrl,
nsIUrlClassifierCallback *aSuccessCallback,
nsIUrlClassifierCallback *aUpdateErrorCallback,
nsIUrlClassifierCallback *aDownloadErrorCallback,
bool *_retval)
{
NS_ENSURE_ARG(aSuccessCallback);
NS_ENSURE_ARG(aUpdateErrorCallback);
NS_ENSURE_ARG(aDownloadErrorCallback);
if (mIsUpdating) {
LOG(("Already updating, queueing update %s from %s", aRequestBody.Data(),
aUpdateUrl.Data()));
*_retval = false;
PendingRequest *request = mPendingRequests.AppendElement();
request->mTables = aRequestTables;
request->mRequest = aRequestBody;
request->mUrl = aUpdateUrl;
request->mSuccessCallback = aSuccessCallback;
request->mUpdateErrorCallback = aUpdateErrorCallback;
request->mDownloadErrorCallback = aDownloadErrorCallback;
return NS_OK;
}
if (aUpdateUrl.IsEmpty()) {
NS_ERROR("updateUrl not set");
return NS_ERROR_NOT_INITIALIZED;
}
nsresult rv;
if (!mInitialized) {
// Add an observer for shutdown so we can cancel any pending list
// downloads. quit-application is the same event that the download
// manager listens for and uses to cancel pending downloads.
nsCOMPtr<nsIObserverService> observerService =
mozilla::services::GetObserverService();
if (!observerService)
return NS_ERROR_FAILURE;
observerService->AddObserver(this, gQuitApplicationMessage, false);
mDBService = do_GetService(NS_URLCLASSIFIERDBSERVICE_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv, rv);
mInitialized = true;
}
rv = mDBService->BeginUpdate(this, aRequestTables);
if (rv == NS_ERROR_NOT_AVAILABLE) {
LOG(("Service busy, already updating, queuing update %s from %s",
aRequestBody.Data(), aUpdateUrl.Data()));
*_retval = false;
PendingRequest *request = mPendingRequests.AppendElement();
request->mTables = aRequestTables;
request->mRequest = aRequestBody;
request->mUrl = aUpdateUrl;
request->mSuccessCallback = aSuccessCallback;
request->mUpdateErrorCallback = aUpdateErrorCallback;
request->mDownloadErrorCallback = aDownloadErrorCallback;
return NS_OK;
}
if (NS_FAILED(rv)) {
return rv;
}
mSuccessCallback = aSuccessCallback;
mUpdateErrorCallback = aUpdateErrorCallback;
mDownloadErrorCallback = aDownloadErrorCallback;
mIsUpdating = true;
*_retval = true;
LOG(("FetchUpdate: %s", aUpdateUrl.Data()));
//LOG(("requestBody: %s", aRequestBody.Data()));
return FetchUpdate(aUpdateUrl, aRequestBody, EmptyCString());
}