本文整理汇总了C++中nsAutoPtr::Init方法的典型用法代码示例。如果您正苦于以下问题:C++ nsAutoPtr::Init方法的具体用法?C++ nsAutoPtr::Init怎么用?C++ nsAutoPtr::Init使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nsAutoPtr
的用法示例。
在下文中一共展示了nsAutoPtr::Init方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: LOG
NS_IMETHODIMP
nsUrlClassifierDBServiceWorker::BeginStream(const nsACString &table,
const nsACString &serverMAC)
{
LOG(("nsUrlClassifierDBServiceWorker::BeginStream"));
if (gShuttingDownThread)
return NS_ERROR_NOT_INITIALIZED;
NS_ENSURE_STATE(mUpdateObserver);
NS_ENSURE_STATE(!mInStream);
mInStream = true;
NS_ASSERTION(!mProtocolParser, "Should not have a protocol parser.");
mProtocolParser = new ProtocolParser(mHashKey);
if (!mProtocolParser)
return NS_ERROR_OUT_OF_MEMORY;
mProtocolParser->Init(mCryptoHash);
nsresult rv;
// If we're expecting a MAC, create the nsICryptoHMAC component now.
if (!mUpdateClientKey.IsEmpty()) {
LOG(("Expecting MAC in this stream"));
rv = mProtocolParser->InitHMAC(mUpdateClientKey, serverMAC);
NS_ENSURE_SUCCESS(rv, rv);
} else {
LOG(("No MAC in this stream"));
}
if (!table.IsEmpty()) {
mProtocolParser->SetCurrentTable(table);
}
return NS_OK;
}
示例2: BluetoothEventObserverTable
nsresult
StartBluetoothConnection()
{
if (sDBusConnection) {
NS_WARNING("DBusConnection already established, skipping");
return NS_OK;
}
sBluetoothEventObserverTable = new BluetoothEventObserverTable();
sBluetoothEventObserverTable->Init(100);
sDBusConnection = new RawDBusConnection();
sDBusConnection->EstablishDBusConnection();
// Add a filter for all incoming messages_base
if (!dbus_connection_add_filter(sDBusConnection->mConnection, EventFilter,
NULL, NULL)) {
NS_WARNING("Cannot create DBus Event Filter for DBus Thread!");
return NS_ERROR_FAILURE;
}
return NS_OK;
}
示例3: val
bool
WaveReader::LoadListChunk(uint32_t aChunkSize,
nsAutoPtr<nsHTMLMediaElement::MetadataTags> &aTags)
{
// List chunks are always word (two byte) aligned.
NS_ABORT_IF_FALSE(mDecoder->GetResource()->Tell() % 2 == 0,
"LoadListChunk called with unaligned resource");
static const unsigned int MAX_CHUNK_SIZE = 1 << 16;
PR_STATIC_ASSERT(MAX_CHUNK_SIZE < UINT_MAX / sizeof(char));
if (aChunkSize > MAX_CHUNK_SIZE) {
return false;
}
nsAutoArrayPtr<char> chunk(new char[aChunkSize]);
if (!ReadAll(chunk.get(), aChunkSize)) {
return false;
}
static const uint32_t INFO_LIST_MAGIC = 0x494e464f;
const char *p = chunk.get();
if (ReadUint32BE(&p) != INFO_LIST_MAGIC) {
return false;
}
const waveIdToName ID_TO_NAME[] = {
{ 0x49415254, NS_LITERAL_CSTRING("artist") }, // IART
{ 0x49434d54, NS_LITERAL_CSTRING("comments") }, // ICMT
{ 0x49474e52, NS_LITERAL_CSTRING("genre") }, // IGNR
{ 0x494e414d, NS_LITERAL_CSTRING("name") }, // INAM
};
const char* const end = chunk.get() + aChunkSize;
aTags = new nsHTMLMediaElement::MetadataTags;
aTags->Init();
while (p + 8 < end) {
uint32_t id = ReadUint32BE(&p);
// Uppercase tag id, inspired by GStreamer's Wave parser.
id &= 0xDFDFDFDF;
uint32_t length = ReadUint32LE(&p);
// Subchunk shall not exceed parent chunk.
if (p + length > end) {
break;
}
nsCString val(p, length);
if (val[length - 1] == '\0') {
val.SetLength(length - 1);
}
// Chunks in List::INFO are always word (two byte) aligned. So round up if
// necessary.
length += length % 2;
p += length;
if (!IsUTF8(val)) {
continue;
}
for (size_t i = 0; i < mozilla::ArrayLength(ID_TO_NAME); ++i) {
if (id == ID_TO_NAME[i].id) {
aTags->Put(ID_TO_NAME[i].name, val);
break;
}
}
}
return true;
}