本文整理汇总了C++中Sequence::AppendElement方法的典型用法代码示例。如果您正苦于以下问题:C++ Sequence::AppendElement方法的具体用法?C++ Sequence::AppendElement怎么用?C++ Sequence::AppendElement使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sequence
的用法示例。
在下文中一共展示了Sequence::AppendElement方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
// 3.1.2.2, step 12
// Follow the steps for the first matching condition from the following list:
// If the sessionTypes member is present in candidate configuration.
// Let session types be candidate configuration's sessionTypes member.
// Otherwise let session types be ["temporary"].
// Note: This returns an empty array on malloc failure.
static Sequence<nsString>
UnboxSessionTypes(const Optional<Sequence<nsString>>& aSessionTypes)
{
Sequence<nsString> sessionTypes;
if (aSessionTypes.WasPassed()) {
sessionTypes = aSessionTypes.Value();
} else {
using MediaKeySessionTypeValues::strings;
const char* temporary = strings[static_cast<uint32_t>(MediaKeySessionType::Temporary)].value;
// Note: fallible. Results in an empty array.
sessionTypes.AppendElement(NS_ConvertUTF8toUTF16(nsDependentCString(temporary)), mozilla::fallible);
}
return sessionTypes;
}
示例2: TVProgram
nsresult
TVSource::NotifyEITBroadcasted(nsITVChannelData* aChannelData,
nsITVProgramData** aProgramDataList,
uint32_t aCount)
{
RefPtr<TVChannel> channel = TVChannel::Create(GetOwner(), this, aChannelData);
Sequence<OwningNonNull<TVProgram>> programs;
for (uint32_t i = 0; i < aCount; i++) {
RefPtr<TVProgram> program =
new TVProgram(GetOwner(), channel, aProgramDataList[i]);
*programs.AppendElement(fallible) = program;
}
return DispatchEITBroadcastedEvent(programs);
}
示例3: OnGetLogging_m
static void OnGetLogging_m(
nsMainThreadPtrHandle<WebrtcGlobalLoggingCallback> aLoggingCallback,
const std::string& aPattern,
nsAutoPtr<std::deque<std::string>> aLogList)
{
ErrorResult rv;
if (!aLogList->empty()) {
Sequence<nsString> nsLogs;
for (auto l = aLogList->begin(); l != aLogList->end(); ++l) {
nsLogs.AppendElement(NS_ConvertUTF8toUTF16(l->c_str()));
}
aLoggingCallback.get()->Call(nsLogs, rv);
}
if (rv.Failed()) {
CSFLogError(logTag, "Error firing logging observer callback");
}
}
示例4: global
already_AddRefed<WebSocket>
FlyWebPublishedServer::OnWebSocketAccept(InternalRequest* aConnectRequest,
const Optional<nsAString>& aProtocol,
ErrorResult& aRv)
{
MOZ_ASSERT(aConnectRequest);
LOG_I("FlyWebPublishedServer::OnWebSocketAccept(%p)", this);
nsCOMPtr<nsITransportProvider> provider =
OnWebSocketAcceptInternal(aConnectRequest,
aProtocol,
aRv);
if (aRv.Failed()) {
return nullptr;
}
MOZ_ASSERT(provider);
nsCOMPtr<nsPIDOMWindowInner> window = do_QueryInterface(GetOwner());
AutoJSContext cx;
GlobalObject global(cx, nsGlobalWindow::Cast(window)->FastGetGlobalJSObject());
nsAutoCString extensions, negotiatedExtensions;
aConnectRequest->Headers()->
GetFirst(NS_LITERAL_CSTRING("Sec-WebSocket-Extensions"), extensions, aRv);
mozilla::net::ProcessServerWebSocketExtensions(extensions,
negotiatedExtensions);
nsCString url;
aConnectRequest->GetURL(url);
Sequence<nsString> protocols;
if (aProtocol.WasPassed() &&
!protocols.AppendElement(aProtocol.Value(), fallible)) {
aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
return nullptr;
}
return WebSocket::ConstructorCommon(global,
NS_ConvertUTF8toUTF16(url),
protocols,
provider,
negotiatedExtensions,
aRv);
}
示例5: Move
// 3.1.2.3 Get Supported Capabilities for Audio/Video Type
static Sequence<MediaKeySystemMediaCapability>
GetSupportedCapabilities(const CodecType aCodecType,
mozIGeckoMediaPluginService* aGMPService,
const nsTArray<MediaKeySystemMediaCapability>& aRequestedCapabilities,
const MediaKeySystemConfiguration& aPartialConfig,
const KeySystemConfig& aKeySystem,
DecoderDoctorDiagnostics* aDiagnostics)
{
// Let local accumulated configuration be a local copy of partial configuration.
// (Note: It's not necessary for us to maintain a local copy, as we don't need
// to test whether capabilites from previous calls to this algorithm work with
// the capabilities currently being considered in this call. )
// Let supported media capabilities be an empty sequence of
// MediaKeySystemMediaCapability dictionaries.
Sequence<MediaKeySystemMediaCapability> supportedCapabilities;
// For each requested media capability in requested media capabilities:
for (const MediaKeySystemMediaCapability& capabilities : aRequestedCapabilities) {
// Let content type be requested media capability's contentType member.
const nsString& contentType = capabilities.mContentType;
// Let robustness be requested media capability's robustness member.
const nsString& robustness = capabilities.mRobustness;
// If content type is the empty string, return null.
if (contentType.IsEmpty()) {
EME_LOG("MediaKeySystemConfiguration (label='%s') "
"MediaKeySystemMediaCapability('%s','%s') rejected; "
"audio or video capability has empty contentType.",
NS_ConvertUTF16toUTF8(aPartialConfig.mLabel).get(),
NS_ConvertUTF16toUTF8(contentType).get(),
NS_ConvertUTF16toUTF8(robustness).get());
return Sequence<MediaKeySystemMediaCapability>();
}
// If content type is an invalid or unrecognized MIME type, continue
// to the next iteration.
nsAutoString container;
nsTArray<nsString> codecStrings;
if (!ParseMIMETypeString(contentType, container, codecStrings)) {
EME_LOG("MediaKeySystemConfiguration (label='%s') "
"MediaKeySystemMediaCapability('%s','%s') unsupported; "
"failed to parse contentType as MIME type.",
NS_ConvertUTF16toUTF8(aPartialConfig.mLabel).get(),
NS_ConvertUTF16toUTF8(contentType).get(),
NS_ConvertUTF16toUTF8(robustness).get());
continue;
}
bool invalid = false;
nsTArray<GMPCodecString> codecs;
for (const nsString& codecString : codecStrings) {
GMPCodecString gmpCodec = ToGMPAPICodecString(codecString);
if (gmpCodec.IsEmpty()) {
invalid = true;
EME_LOG("MediaKeySystemConfiguration (label='%s') "
"MediaKeySystemMediaCapability('%s','%s') unsupported; "
"'%s' is an invalid codec string.",
NS_ConvertUTF16toUTF8(aPartialConfig.mLabel).get(),
NS_ConvertUTF16toUTF8(contentType).get(),
NS_ConvertUTF16toUTF8(robustness).get(),
NS_ConvertUTF16toUTF8(codecString).get());
break;
}
codecs.AppendElement(gmpCodec);
}
if (invalid) {
continue;
}
// If the user agent does not support container, continue to the next iteration.
// The case-sensitivity of string comparisons is determined by the appropriate RFC.
// (Note: Per RFC 6838 [RFC6838], "Both top-level type and subtype names are
// case-insensitive."'. We're using nsContentTypeParser and that is
// case-insensitive and converts all its parameter outputs to lower case.)
NS_ConvertUTF16toUTF8 container_utf8(container);
const bool isMP4 = DecoderTraits::IsMP4TypeAndEnabled(container_utf8, aDiagnostics);
if (isMP4 && !aKeySystem.mMP4.IsSupported()) {
EME_LOG("MediaKeySystemConfiguration (label='%s') "
"MediaKeySystemMediaCapability('%s','%s') unsupported; "
"MP4 requested but unsupported.",
NS_ConvertUTF16toUTF8(aPartialConfig.mLabel).get(),
NS_ConvertUTF16toUTF8(contentType).get(),
NS_ConvertUTF16toUTF8(robustness).get());
continue;
}
const bool isWebM = DecoderTraits::IsWebMTypeAndEnabled(container_utf8);
if (isWebM && !aKeySystem.mWebM.IsSupported()) {
EME_LOG("MediaKeySystemConfiguration (label='%s') "
"MediaKeySystemMediaCapability('%s','%s') unsupported; "
"WebM requested but unsupported.",
NS_ConvertUTF16toUTF8(aPartialConfig.mLabel).get(),
NS_ConvertUTF16toUTF8(contentType).get(),
NS_ConvertUTF16toUTF8(robustness).get());
continue;
}
if (!isMP4 && !isWebM) {
EME_LOG("MediaKeySystemConfiguration (label='%s') "
"MediaKeySystemMediaCapability('%s','%s') unsupported; "
"Unsupported or unrecognized container requested.",
NS_ConvertUTF16toUTF8(aPartialConfig.mLabel).get(),
NS_ConvertUTF16toUTF8(contentType).get(),
//.........这里部分代码省略.........
示例6: GetAsFileWithPrincipal
already_AddRefed<FileSystemEntry>
DataTransferItem::GetAsEntryWithPrincipal(nsIPrincipal* aPrincipal,
ErrorResult& aRv)
{
RefPtr<File> file = GetAsFileWithPrincipal(aPrincipal, aRv);
if (NS_WARN_IF(aRv.Failed()) || !file) {
return nullptr;
}
nsCOMPtr<nsIGlobalObject> global;
// This is annoying, but DataTransfer may have various things as parent.
nsCOMPtr<EventTarget> target =
do_QueryInterface(mDataTransfer->GetParentObject());
if (target) {
global = target->GetOwnerGlobal();
} else {
nsCOMPtr<nsIDOMEvent> event =
do_QueryInterface(mDataTransfer->GetParentObject());
if (event) {
global = event->InternalDOMEvent()->GetParentObject();
}
}
if (!global) {
return nullptr;
}
RefPtr<FileSystem> fs = FileSystem::Create(global);
RefPtr<FileSystemEntry> entry;
BlobImpl* impl = file->Impl();
MOZ_ASSERT(impl);
if (impl->IsDirectory()) {
nsAutoString fullpath;
impl->GetMozFullPathInternal(fullpath, aRv);
if (aRv.Failed()) {
aRv.SuppressException();
return nullptr;
}
nsCOMPtr<nsIFile> directoryFile;
nsresult rv = NS_NewNativeLocalFile(NS_ConvertUTF16toUTF8(fullpath),
true, getter_AddRefs(directoryFile));
if (NS_WARN_IF(NS_FAILED(rv))) {
return nullptr;
}
RefPtr<Directory> directory = Directory::Create(global, directoryFile);
entry = new FileSystemDirectoryEntry(global, directory, fs);
} else {
entry = new FileSystemFileEntry(global, file, fs);
}
Sequence<RefPtr<FileSystemEntry>> entries;
if (!entries.AppendElement(entry, fallible)) {
return nullptr;
}
fs->CreateRoot(entries);
return entry.forget();
}