本文整理汇总了C++中NotNull::Complete方法的典型用法代码示例。如果您正苦于以下问题:C++ NotNull::Complete方法的具体用法?C++ NotNull::Complete怎么用?C++ NotNull::Complete使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NotNull
的用法示例。
在下文中一共展示了NotNull::Complete方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: WithSingleChunkDecode
void WithSingleChunkDecode(const ImageTestCase& aTestCase,
const Maybe<IntSize>& aOutputSize,
Func aResultChecker)
{
nsCOMPtr<nsIInputStream> inputStream = LoadFile(aTestCase.mPath);
ASSERT_TRUE(inputStream != nullptr);
// Figure out how much data we have.
uint64_t length;
nsresult rv = inputStream->Available(&length);
ASSERT_TRUE(NS_SUCCEEDED(rv));
// Write the data into a SourceBuffer.
NotNull<RefPtr<SourceBuffer>> sourceBuffer = WrapNotNull(new SourceBuffer());
sourceBuffer->ExpectLength(length);
rv = sourceBuffer->AppendFromInputStream(inputStream, length);
ASSERT_TRUE(NS_SUCCEEDED(rv));
sourceBuffer->Complete(NS_OK);
// Create a decoder.
DecoderType decoderType =
DecoderFactory::GetDecoderType(aTestCase.mMimeType);
RefPtr<Decoder> decoder =
DecoderFactory::CreateAnonymousDecoder(decoderType, sourceBuffer, aOutputSize,
DefaultSurfaceFlags());
ASSERT_TRUE(decoder != nullptr);
RefPtr<IDecodingTask> task = new AnonymousDecodingTask(WrapNotNull(decoder));
// Run the full decoder synchronously.
task->Run();
// Call the lambda to verify the expected results.
aResultChecker(decoder);
}
示例2: LoadFile
static void
CheckDecoderMultiChunk(const ImageTestCase& aTestCase)
{
nsCOMPtr<nsIInputStream> inputStream = LoadFile(aTestCase.mPath);
ASSERT_TRUE(inputStream != nullptr);
// Figure out how much data we have.
uint64_t length;
nsresult rv = inputStream->Available(&length);
ASSERT_TRUE(NS_SUCCEEDED(rv));
// Create a SourceBuffer and a decoder.
NotNull<RefPtr<SourceBuffer>> sourceBuffer = WrapNotNull(new SourceBuffer());
sourceBuffer->ExpectLength(length);
DecoderType decoderType =
DecoderFactory::GetDecoderType(aTestCase.mMimeType);
RefPtr<Decoder> decoder =
DecoderFactory::CreateAnonymousDecoder(decoderType, sourceBuffer, Nothing(),
DefaultSurfaceFlags());
ASSERT_TRUE(decoder != nullptr);
RefPtr<IDecodingTask> task = new AnonymousDecodingTask(WrapNotNull(decoder));
for (uint64_t read = 0; read < length ; ++read) {
uint64_t available = 0;
rv = inputStream->Available(&available);
ASSERT_TRUE(available > 0);
ASSERT_TRUE(NS_SUCCEEDED(rv));
rv = sourceBuffer->AppendFromInputStream(inputStream, 1);
ASSERT_TRUE(NS_SUCCEEDED(rv));
task->Run();
}
sourceBuffer->Complete(NS_OK);
task->Run();
CheckDecoderResults(aTestCase, decoder);
}