Backed out changeset ba730a1d259a (bug 1371699) for failing wpt webvtt/parsing/cue-text-parsing/tests/entities.html on Linux

--HG--
extra : histedit_source : 5357e0cb4f0f4dc850cc25287bc4ad75ff55c4f8
This commit is contained in:
Sebastian Hengst 2018-01-31 20:30:57 +02:00
Родитель e33e198739
Коммит b27faafcd2
2 изменённых файлов: 4 добавлений и 66 удалений

Просмотреть файл

@ -162,46 +162,12 @@ NonBlockingAsyncInputStream::Read(char* aBuffer, uint32_t aCount,
return mInputStream->Read(aBuffer, aCount, aReadCount); return mInputStream->Read(aBuffer, aCount, aReadCount);
} }
namespace {
class MOZ_RAII ReadSegmentsData
{
public:
ReadSegmentsData(NonBlockingAsyncInputStream* aStream,
nsWriteSegmentFun aFunc,
void* aClosure)
: mStream(aStream)
, mFunc(aFunc)
, mClosure(aClosure)
{}
NonBlockingAsyncInputStream* mStream;
nsWriteSegmentFun mFunc;
void* mClosure;
};
nsresult
ReadSegmentsWriter(nsIInputStream* aInStream,
void* aClosure,
const char* aFromSegment,
uint32_t aToOffset,
uint32_t aCount,
uint32_t* aWriteCount)
{
ReadSegmentsData* data = static_cast<ReadSegmentsData*>(aClosure);
return data->mFunc(data->mStream, data->mClosure, aFromSegment, aToOffset,
aCount, aWriteCount);
}
} // anonymous
NS_IMETHODIMP NS_IMETHODIMP
NonBlockingAsyncInputStream::ReadSegments(nsWriteSegmentFun aWriter, NonBlockingAsyncInputStream::ReadSegments(nsWriteSegmentFun aWriter,
void* aClosure, uint32_t aCount, void* aClosure, uint32_t aCount,
uint32_t* aResult) uint32_t *aResult)
{ {
ReadSegmentsData data(this, aWriter, aClosure); return mInputStream->ReadSegments(aWriter, aClosure, aCount, aResult);
return mInputStream->ReadSegments(ReadSegmentsWriter, &data, aCount, aResult);
} }
NS_IMETHODIMP NS_IMETHODIMP
@ -317,7 +283,7 @@ NonBlockingAsyncInputStream::Seek(int32_t aWhence, int64_t aOffset)
} }
NS_IMETHODIMP NS_IMETHODIMP
NonBlockingAsyncInputStream::Tell(int64_t* aResult) NonBlockingAsyncInputStream::Tell(int64_t *aResult)
{ {
NS_ENSURE_STATE(mWeakSeekableInputStream); NS_ENSURE_STATE(mWeakSeekableInputStream);
return mWeakSeekableInputStream->Tell(aResult); return mWeakSeekableInputStream->Tell(aResult);

Просмотреть файл

@ -47,33 +47,6 @@ TEST(TestNonBlockingAsyncInputStream, Simple) {
ASSERT_TRUE(data.Equals(nsCString(buffer, read))); ASSERT_TRUE(data.Equals(nsCString(buffer, read)));
} }
class ReadSegmentsData
{
public:
ReadSegmentsData(nsIInputStream* aStream, char* aBuffer)
: mStream(aStream)
, mBuffer(aBuffer)
{}
nsIInputStream* mStream;
char* mBuffer;
};
nsresult
ReadSegmentsFunction(nsIInputStream* aInStr,
void* aClosure,
const char* aBuffer,
uint32_t aOffset,
uint32_t aCount,
uint32_t* aCountWritten)
{
ReadSegmentsData* data = static_cast<ReadSegmentsData*>(aClosure);
if (aInStr != data->mStream) return NS_ERROR_FAILURE;
memcpy(&data->mBuffer[aOffset], aBuffer, aCount);
*aCountWritten = aCount;
return NS_OK;
}
TEST(TestNonBlockingAsyncInputStream, ReadSegments) { TEST(TestNonBlockingAsyncInputStream, ReadSegments) {
nsCOMPtr<nsIInputStream> stream; nsCOMPtr<nsIInputStream> stream;
@ -91,8 +64,7 @@ TEST(TestNonBlockingAsyncInputStream, ReadSegments) {
// Read works fine. // Read works fine.
char buffer[1024]; char buffer[1024];
uint32_t read = 0; uint32_t read = 0;
ReadSegmentsData closure(async, buffer); ASSERT_EQ(NS_OK, async->ReadSegments(NS_CopySegmentToBuffer, buffer,
ASSERT_EQ(NS_OK, async->ReadSegments(ReadSegmentsFunction, &closure,
sizeof(buffer), &read)); sizeof(buffer), &read));
ASSERT_EQ(data.Length(), read); ASSERT_EQ(data.Length(), read);
ASSERT_TRUE(data.Equals(nsCString(buffer, read))); ASSERT_TRUE(data.Equals(nsCString(buffer, read)));