зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1490235
- Use nsDependentCSubstring in AltDataOutputStreamChild::WriteDataInChunks r=mayhemer
Simply replace the nsCString with nsDependentCSubstring to avoid copying the data. In this way, we can also avoid the potential OOM crash. Differential Revision: https://phabricator.services.mozilla.com/D6685 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
1c46cdfb02
Коммит
dc8eeee6b9
|
@ -59,7 +59,7 @@ AltDataOutputStreamChild::ReleaseIPDLReference()
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
AltDataOutputStreamChild::WriteDataInChunks(const nsCString& data)
|
AltDataOutputStreamChild::WriteDataInChunks(const nsDependentCSubstring& data)
|
||||||
{
|
{
|
||||||
const uint32_t kChunkSize = 128*1024;
|
const uint32_t kChunkSize = 128*1024;
|
||||||
uint32_t next = std::min(data.Length(), kChunkSize);
|
uint32_t next = std::min(data.Length(), kChunkSize);
|
||||||
|
@ -110,7 +110,7 @@ AltDataOutputStreamChild::Write(const char * aBuf, uint32_t aCount, uint32_t *_r
|
||||||
if (NS_FAILED(mError)) {
|
if (NS_FAILED(mError)) {
|
||||||
return mError;
|
return mError;
|
||||||
}
|
}
|
||||||
if (WriteDataInChunks(nsCString(aBuf, aCount))) {
|
if (WriteDataInChunks(nsDependentCSubstring(aBuf, aCount))) {
|
||||||
*_retval = aCount;
|
*_retval = aCount;
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,7 @@ public:
|
||||||
private:
|
private:
|
||||||
virtual ~AltDataOutputStreamChild() = default;
|
virtual ~AltDataOutputStreamChild() = default;
|
||||||
// Sends data to the parent process in 256k chunks.
|
// Sends data to the parent process in 256k chunks.
|
||||||
bool WriteDataInChunks(const nsCString& data);
|
bool WriteDataInChunks(const nsDependentCSubstring& data);
|
||||||
|
|
||||||
bool mIPCOpen;
|
bool mIPCOpen;
|
||||||
// If there was an error opening the output stream or writing to it on the
|
// If there was an error opening the output stream or writing to it on the
|
||||||
|
|
Загрузка…
Ссылка в новой задаче