本文整理汇总了C++中nsAutoPtr::empty方法的典型用法代码示例。如果您正苦于以下问题:C++ nsAutoPtr::empty方法的具体用法?C++ nsAutoPtr::empty怎么用?C++ nsAutoPtr::empty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nsAutoPtr
的用法示例。
在下文中一共展示了nsAutoPtr::empty方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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");
}
}
示例2: PushLayers
// This is all-or-nothing.
nsresult TransportFlow::PushLayers(nsAutoPtr<std::queue<TransportLayer *> > layers) {
MOZ_ASSERT(!layers->empty());
if (layers->empty()) {
MOZ_MTLOG(PR_LOG_ERROR, id_ << ": Can't call PushLayers with empty layers");
return NS_ERROR_INVALID_ARG;
}
// Don't allow pushes once we are in error state.
if (state_ == TransportLayer::TS_ERROR) {
MOZ_MTLOG(PR_LOG_ERROR, id_ << ": Can't call PushLayers in error state for flow ");
return NS_ERROR_FAILURE;
}
nsresult rv = NS_OK;
// Disconnect all the old signals.
disconnect_all();
TransportLayer *layer;
while (!layers->empty()) {
TransportLayer *old_layer = layers_.empty() ? nullptr : layers_.front();
layer = layers->front();
rv = layer->Init();
if (NS_FAILED(rv)) {
MOZ_MTLOG(PR_LOG_ERROR, id_ << ": Layer initialization failed; invalidating flow ");
break;
}
// Push the layer onto the queue.
layers_.push_front(layer);
layers->pop();
layer->Inserted(this, old_layer);
}
if (NS_FAILED(rv)) {
// Destroy any layers we could not push.
while (!layers->empty()) {
delete layers->front();
layers->pop();
}
// Now destroy the rest of the flow, because it's no longer
// in an acceptable state.
while (!layers_.empty()) {
delete layers_.front();
layers_.pop_front();
}
// Set ourselves to have failed.
StateChangeInt(TransportLayer::TS_ERROR);
// Return failure.
return rv;
}
// Finally, attach ourselves to the top layer.
layer->SignalStateChange.connect(this, &TransportFlow::StateChange);
layer->SignalPacketReceived.connect(this, &TransportFlow::PacketReceived);
StateChangeInt(layer->state()); // Signals if the state changes.
return NS_OK;
}