Commit 3ec92ab7 authored by bugsnash's avatar bugsnash Committed by Commit bot

Replaced RefPtr::release with std::move in Source/platform.

Part of the removal of PassRefPtr.

Replaces many of the calls to RefPtr::release with a std::move wrap,
which returns a RefPtr instead of a PassRefPtr. As the code currently
stands, most methods still expect a PassRefPtr and so the PassRefPtr
initialising constructor will be called passing in the RefPtr rvalue,
which calls RefPtr::release anyway.

Future patches will see these variables changed from PassRefPtr to
RefPtr type then RefPtr::release will not be used at all.

Does not handle RefPtr::release of non member variables in return
statements as these cases sometimes default to move (in the case of
returning a local variable). These will be handled in future patches.

BUG=494719

Review-Url: https://codereview.chromium.org/2628773002
Cr-Commit-Position: refs/heads/master@{#443416}
parent 026f2d66
...@@ -156,7 +156,7 @@ void BlobData::appendText(const String& text, ...@@ -156,7 +156,7 @@ void BlobData::appendText(const String& text,
} }
if (data) if (data)
m_items.push_back(BlobDataItem(data.release())); m_items.push_back(BlobDataItem(std::move(data)));
} }
void BlobData::appendBytes(const void* bytes, size_t length) { void BlobData::appendBytes(const void* bytes, size_t length) {
...@@ -170,7 +170,7 @@ void BlobData::appendBytes(const void* bytes, size_t length) { ...@@ -170,7 +170,7 @@ void BlobData::appendBytes(const void* bytes, size_t length) {
RefPtr<RawData> data = RawData::create(); RefPtr<RawData> data = RawData::create();
Vector<char>* buffer = data->mutableData(); Vector<char>* buffer = data->mutableData();
buffer->append(static_cast<const char*>(bytes), length); buffer->append(static_cast<const char*>(bytes), length);
m_items.push_back(BlobDataItem(data.release())); m_items.push_back(BlobDataItem(std::move(data)));
} }
long long BlobData::length() const { long long BlobData::length() const {
......
...@@ -139,7 +139,7 @@ WebURLLoadTiming WebURLResponse::loadTiming() { ...@@ -139,7 +139,7 @@ WebURLLoadTiming WebURLResponse::loadTiming() {
void WebURLResponse::setLoadTiming(const WebURLLoadTiming& timing) { void WebURLResponse::setLoadTiming(const WebURLLoadTiming& timing) {
RefPtr<ResourceLoadTiming> loadTiming = RefPtr<ResourceLoadTiming> loadTiming =
PassRefPtr<ResourceLoadTiming>(timing); PassRefPtr<ResourceLoadTiming>(timing);
m_resourceResponse->setResourceLoadTiming(loadTiming.release()); m_resourceResponse->setResourceLoadTiming(std::move(loadTiming));
} }
WebHTTPLoadInfo WebURLResponse::httpLoadInfo() { WebHTTPLoadInfo WebURLResponse::httpLoadInfo() {
......
...@@ -76,7 +76,7 @@ inline bool operator!=(const FontFamily& a, const FontFamily& b) { ...@@ -76,7 +76,7 @@ inline bool operator!=(const FontFamily& a, const FontFamily& b) {
} }
inline FontFamily::~FontFamily() { inline FontFamily::~FontFamily() {
RefPtr<SharedFontFamily> reaper = m_next.release(); RefPtr<SharedFontFamily> reaper = std::move(m_next);
while (reaper && reaper->hasOneRef()) { while (reaper && reaper->hasOneRef()) {
// implicitly protects reaper->next, then derefs reaper // implicitly protects reaper->next, then derefs reaper
reaper = reaper->releaseNext(); reaper = reaper->releaseNext();
...@@ -92,7 +92,7 @@ inline void FontFamily::appendFamily(PassRefPtr<SharedFontFamily> family) { ...@@ -92,7 +92,7 @@ inline void FontFamily::appendFamily(PassRefPtr<SharedFontFamily> family) {
} }
inline PassRefPtr<SharedFontFamily> FontFamily::releaseNext() { inline PassRefPtr<SharedFontFamily> FontFamily::releaseNext() {
return m_next.release(); return std::move(m_next);
} }
} // namespace blink } // namespace blink
......
...@@ -74,7 +74,7 @@ static inline float shapeResultsForRun( ...@@ -74,7 +74,7 @@ static inline float shapeResultsForRun(
totalWidth += wordResult->width(); totalWidth += wordResult->width();
if (fallbackFonts) if (fallbackFonts)
wordResult->fallbackFonts(fallbackFonts); wordResult->fallbackFonts(fallbackFonts);
resultsBuffer->appendResult(wordResult.release()); resultsBuffer->appendResult(std::move(wordResult));
} }
} }
return totalWidth; return totalWidth;
......
...@@ -74,7 +74,7 @@ std::unique_ptr<DeferredImageDecoder> DeferredImageDecoder::create( ...@@ -74,7 +74,7 @@ std::unique_ptr<DeferredImageDecoder> DeferredImageDecoder::create(
// Since we've just instantiated a fresh decoder, there's no need to reset its // Since we've just instantiated a fresh decoder, there's no need to reset its
// data. // data.
decoder->setDataInternal(data.release(), dataComplete, false); decoder->setDataInternal(std::move(data), dataComplete, false);
return decoder; return decoder;
} }
...@@ -329,8 +329,8 @@ sk_sp<SkImage> DeferredImageDecoder::createFrameImageAtIndex( ...@@ -329,8 +329,8 @@ sk_sp<SkImage> DeferredImageDecoder::createFrameImageAtIndex(
m_colorSpaceForSkImages); m_colorSpaceForSkImages);
DecodingImageGenerator* generator = new DecodingImageGenerator( DecodingImageGenerator* generator = new DecodingImageGenerator(
m_frameGenerator, info, segmentReader.release(), m_allDataReceived, index, m_frameGenerator, info, std::move(segmentReader), m_allDataReceived,
m_frameData[index].m_uniqueID); index, m_frameData[index].m_uniqueID);
sk_sp<SkImage> image = SkImage::MakeFromGenerator( sk_sp<SkImage> image = SkImage::MakeFromGenerator(
generator); // SkImage takes ownership of the generator. generator); // SkImage takes ownership of the generator.
if (!image) if (!image)
......
...@@ -52,7 +52,7 @@ bool ImageSource::setData(PassRefPtr<SharedBuffer> passData, ...@@ -52,7 +52,7 @@ bool ImageSource::setData(PassRefPtr<SharedBuffer> passData,
m_allDataReceived = allDataReceived; m_allDataReceived = allDataReceived;
if (m_decoder) { if (m_decoder) {
m_decoder->setData(data.release(), allDataReceived); m_decoder->setData(std::move(data), allDataReceived);
// If the decoder is pre-instantiated, it means we've already validated the // If the decoder is pre-instantiated, it means we've already validated the
// data/signature at some point. // data/signature at some point.
return true; return true;
......
...@@ -66,7 +66,7 @@ class SkiaImageDecoder final : public SkImageDeserializer { ...@@ -66,7 +66,7 @@ class SkiaImageDecoder final : public SkImageDeserializer {
RefPtr<SegmentReader> segmentReader = RefPtr<SegmentReader> segmentReader =
SegmentReader::createFromSkData(SkData::MakeWithoutCopy(data, length)); SegmentReader::createFromSkData(SkData::MakeWithoutCopy(data, length));
std::unique_ptr<ImageDecoder> imageDecoder = ImageDecoder::create( std::unique_ptr<ImageDecoder> imageDecoder = ImageDecoder::create(
segmentReader.release(), true, ImageDecoder::AlphaPremultiplied, std::move(segmentReader), true, ImageDecoder::AlphaPremultiplied,
ColorBehavior::ignore()); ColorBehavior::ignore());
if (!imageDecoder) if (!imageDecoder)
return nullptr; return nullptr;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment