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

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

Issue 2387093002: Reflow comments in canvas-related folders (Closed)
Patch Set: More fix Created 4 years, 2 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
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/dom/Document.h" 7 #include "core/dom/Document.h"
8 #include "core/dom/TaskRunnerHelper.h" 8 #include "core/dom/TaskRunnerHelper.h"
9 #include "core/fileapi/Blob.h" 9 #include "core/fileapi/Blob.h"
10 #include "platform/CrossThreadFunctional.h" 10 #include "platform/CrossThreadFunctional.h"
(...skipping 13 matching lines...) Expand all
24 24
25 namespace blink { 25 namespace blink {
26 26
27 namespace { 27 namespace {
28 28
29 const double SlackBeforeDeadline = 29 const double SlackBeforeDeadline =
30 0.001; // a small slack period between deadline and current time for safety 30 0.001; // a small slack period between deadline and current time for safety
31 const int NumChannelsPng = 4; 31 const int NumChannelsPng = 4;
32 const int LongTaskImageSizeThreshold = 32 const int LongTaskImageSizeThreshold =
33 1000 * 33 1000 *
34 1000; // The max image size we expect to encode in 14ms on Linux in PNG for mat 34 1000; // The max image size we expect to encode in 14ms on Linux in PNG
35 // format
35 36
36 // The encoding task is highly likely to switch from idle task to alternative 37 // The encoding task is highly likely to switch from idle task to alternative
37 // code path when the startTimeoutDelay is set to be below 150ms. As we want the 38 // code path when the startTimeoutDelay is set to be below 150ms. As we want the
38 // majority of encoding tasks to take the usual async idle task, we set a 39 // majority of encoding tasks to take the usual async idle task, we set a
39 // lenient limit -- 200ms here. This limit still needs to be short enough for 40 // lenient limit -- 200ms here. This limit still needs to be short enough for
40 // the latency to be negligible to the user. 41 // the latency to be negligible to the user.
41 const double IdleTaskStartTimeoutDelay = 200.0; 42 const double IdleTaskStartTimeoutDelay = 200.0;
42 // We should be more lenient on completion timeout delay to ensure that the 43 // We should be more lenient on completion timeout delay to ensure that the
43 // switch from idle to main thread only happens to a minority of toBlob calls 44 // switch from idle to main thread only happens to a minority of toBlob calls
44 #if !OS(ANDROID) 45 #if !OS(ANDROID)
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 ASSERT(isMainThread()); 137 ASSERT(isMainThread());
137 138
138 if (canUseIdlePeriodScheduling) { 139 if (canUseIdlePeriodScheduling) {
139 m_idleTaskStatus = IdleTaskNotStarted; 140 m_idleTaskStatus = IdleTaskNotStarted;
140 if (m_mimeType == MimeTypePng) { 141 if (m_mimeType == MimeTypePng) {
141 this->scheduleInitiatePngEncoding(); 142 this->scheduleInitiatePngEncoding();
142 } else if (m_mimeType == MimeTypeJpeg) { 143 } else if (m_mimeType == MimeTypeJpeg) {
143 this->scheduleInitiateJpegEncoding(quality); 144 this->scheduleInitiateJpegEncoding(quality);
144 } else { 145 } else {
145 // Progressive encoding is only applicable to png and jpeg image format, 146 // Progressive encoding is only applicable to png and jpeg image format,
146 // and thus idle tasks scheduling can only be applied to these image forma ts. 147 // and thus idle tasks scheduling can only be applied to these image
147 // TODO(xlai): Progressive encoding on webp image formats (crbug.com/57139 9) 148 // formats.
149 // TODO(xlai): Progressive encoding on webp image formats
150 // (crbug.com/571399)
148 ASSERT_NOT_REACHED(); 151 ASSERT_NOT_REACHED();
149 } 152 }
150 // We post the below task to check if the above idle task isn't late. 153 // We post the below task to check if the above idle task isn't late.
151 // There's no risk of concurrency as both tasks are on main thread. 154 // There's no risk of concurrency as both tasks are on main thread.
152 this->postDelayedTaskToMainThread( 155 this->postDelayedTaskToMainThread(
153 BLINK_FROM_HERE, 156 BLINK_FROM_HERE,
154 WTF::bind(&CanvasAsyncBlobCreator::idleTaskStartTimeoutEvent, 157 WTF::bind(&CanvasAsyncBlobCreator::idleTaskStartTimeoutEvent,
155 wrapPersistent(this), quality), 158 wrapPersistent(this), quality),
156 IdleTaskStartTimeoutDelay); 159 IdleTaskStartTimeoutDelay);
157 } else if (m_mimeType == MimeTypeWebp) { 160 } else if (m_mimeType == MimeTypeWebp) {
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after
507 } 510 }
508 511
509 DEFINE_TRACE(CanvasAsyncBlobCreator) { 512 DEFINE_TRACE(CanvasAsyncBlobCreator) {
510 visitor->trace(m_document); 513 visitor->trace(m_document);
511 visitor->trace(m_data); 514 visitor->trace(m_data);
512 visitor->trace(m_callback); 515 visitor->trace(m_callback);
513 visitor->trace(m_parentFrameTaskRunner); 516 visitor->trace(m_parentFrameTaskRunner);
514 } 517 }
515 518
516 } // namespace blink 519 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698