Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(82)

Side by Side Diff: third_party/WebKit/Source/core/html/canvas/CanvasAsyncBlobCreator.cpp

Issue 2051993002: Drop unecessary use of CrossThreadPersistent by CanvasAsyncBlobCreator. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/WebKit/Source/core/html/canvas/CanvasAsyncBlobCreator.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "core/html/canvas/CanvasAsyncBlobCreator.h" 5 #include "core/html/canvas/CanvasAsyncBlobCreator.h"
6 6
7 #include "core/fileapi/Blob.h" 7 #include "core/fileapi/Blob.h"
8 #include "platform/ThreadSafeFunctional.h" 8 #include "platform/ThreadSafeFunctional.h"
9 #include "platform/graphics/ImageBuffer.h" 9 #include "platform/graphics/ImageBuffer.h"
10 #include "platform/image-encoders/JPEGImageEncoder.h" 10 #include "platform/image-encoders/JPEGImageEncoder.h"
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 } 249 }
250 250
251 this->signalAlternativeCodePathFinishedForTesting(); 251 this->signalAlternativeCodePathFinishedForTesting();
252 } 252 }
253 253
254 void CanvasAsyncBlobCreator::createBlobAndInvokeCallback() 254 void CanvasAsyncBlobCreator::createBlobAndInvokeCallback()
255 { 255 {
256 ASSERT(isMainThread()); 256 ASSERT(isMainThread());
257 Blob* resultBlob = Blob::create(m_encodedImage->data(), m_encodedImage->size (), convertMimeTypeEnumToString(m_mimeType)); 257 Blob* resultBlob = Blob::create(m_encodedImage->data(), m_encodedImage->size (), convertMimeTypeEnumToString(m_mimeType));
258 Platform::current()->mainThread()->getWebTaskRunner()->postTask(BLINK_FROM_H ERE, bind(&BlobCallback::handleEvent, m_callback, resultBlob)); 258 Platform::current()->mainThread()->getWebTaskRunner()->postTask(BLINK_FROM_H ERE, bind(&BlobCallback::handleEvent, m_callback, resultBlob));
259 // Since toBlob is done, timeout events are no longer needed. So we clear
sof 2016/06/13 06:15:26 This CL may have introduced some leaks https://b
260 // non-GC members to allow teardown of CanvasAsyncBlobCreator.
261 m_data.clear();
262 m_callback.clear();
263 } 259 }
264 260
265 void CanvasAsyncBlobCreator::createNullAndInvokeCallback() 261 void CanvasAsyncBlobCreator::createNullAndInvokeCallback()
266 { 262 {
267 ASSERT(isMainThread()); 263 ASSERT(isMainThread());
268 Platform::current()->mainThread()->getWebTaskRunner()->postTask(BLINK_FROM_H ERE, bind(&BlobCallback::handleEvent, m_callback, nullptr)); 264 Platform::current()->mainThread()->getWebTaskRunner()->postTask(BLINK_FROM_H ERE, bind(&BlobCallback::handleEvent, m_callback, nullptr));
269 // Since toBlob is done (failed), timeout events are no longer needed. So we
270 // clear non-GC members to allow teardown of CanvasAsyncBlobCreator.
271 m_data.clear();
272 m_callback.clear();
273 } 265 }
274 266
275 void CanvasAsyncBlobCreator::encodeImageOnEncoderThread(double quality) 267 void CanvasAsyncBlobCreator::encodeImageOnEncoderThread(double quality)
276 { 268 {
277 ASSERT(!isMainThread()); 269 ASSERT(!isMainThread());
278 ASSERT(m_mimeType == MimeTypeWebp); 270 ASSERT(m_mimeType == MimeTypeWebp);
279 271
280 if (!ImageDataBuffer(m_size, m_data->data()).encodeImage("image/webp", quali ty, m_encodedImage.get())) { 272 if (!ImageDataBuffer(m_size, m_data->data()).encodeImage("image/webp", quali ty, m_encodedImage.get())) {
281 Platform::current()->mainThread()->getWebTaskRunner()->postTask(BLINK_FR OM_HERE, threadSafeBind(&BlobCallback::handleEvent, wrapCrossThreadPersistent(m_ callback.get()), nullptr)); 273 Platform::current()->mainThread()->getWebTaskRunner()->postTask(BLINK_FR OM_HERE, threadSafeBind(&BlobCallback::handleEvent, wrapCrossThreadPersistent(m_ callback.get()), nullptr));
282 return; 274 return;
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
361 } 353 }
362 } 354 }
363 355
364 void CanvasAsyncBlobCreator::postDelayedTaskToMainThread(const WebTraceLocation& location, std::unique_ptr<SameThreadClosure> task, double delayMs) 356 void CanvasAsyncBlobCreator::postDelayedTaskToMainThread(const WebTraceLocation& location, std::unique_ptr<SameThreadClosure> task, double delayMs)
365 { 357 {
366 DCHECK(isMainThread()); 358 DCHECK(isMainThread());
367 Platform::current()->mainThread()->getWebTaskRunner()->postDelayedTask(locat ion, std::move(task), delayMs); 359 Platform::current()->mainThread()->getWebTaskRunner()->postDelayedTask(locat ion, std::move(task), delayMs);
368 } 360 }
369 361
370 } // namespace blink 362 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/html/canvas/CanvasAsyncBlobCreator.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698