| Index: third_party/WebKit/Source/core/html/HTMLCanvasElement.cpp
|
| diff --git a/third_party/WebKit/Source/core/html/HTMLCanvasElement.cpp b/third_party/WebKit/Source/core/html/HTMLCanvasElement.cpp
|
| index 099ed9080c084be9c1987ce7a1e9d5a4746a0cb6..2ac47d8003ccd5f03b40459fab5f713c63bfc992 100644
|
| --- a/third_party/WebKit/Source/core/html/HTMLCanvasElement.cpp
|
| +++ b/third_party/WebKit/Source/core/html/HTMLCanvasElement.cpp
|
| @@ -699,6 +699,30 @@ String HTMLCanvasElement::toDataURLInternal(
|
|
|
| String encodingMimeType = toEncodingMimeType(mimeType, EncodeReasonToDataURL);
|
|
|
| + Optional<ScopedUsHistogramTimer> timer;
|
| + if (encodingMimeType == "image/png") {
|
| + DEFINE_THREAD_SAFE_STATIC_LOCAL(
|
| + CustomCountHistogram, scopedUsCounterPNG,
|
| + new CustomCountHistogram("Blink.Canvas.ToDataURL.PNG", 0, 10000000,
|
| + 50));
|
| + timer.emplace(scopedUsCounterPNG);
|
| + } else if (encodingMimeType == "image/jpeg") {
|
| + DEFINE_THREAD_SAFE_STATIC_LOCAL(
|
| + CustomCountHistogram, scopedUsCounterJPEG,
|
| + new CustomCountHistogram("Blink.Canvas.ToDataURL.JPEG", 0, 10000000,
|
| + 50));
|
| + timer.emplace(scopedUsCounterJPEG);
|
| + } else if (encodingMimeType == "image/webp") {
|
| + DEFINE_THREAD_SAFE_STATIC_LOCAL(
|
| + CustomCountHistogram, scopedUsCounterWEBP,
|
| + new CustomCountHistogram("Blink.Canvas.ToDataURL.WEBP", 0, 10000000,
|
| + 50));
|
| + timer.emplace(scopedUsCounterWEBP);
|
| + } else {
|
| + // Currently we only support three encoding types.
|
| + NOTREACHED();
|
| + }
|
| +
|
| ImageData* imageData = toImageData(sourceBuffer, SnapshotReasonToDataURL);
|
|
|
| if (!imageData) // allocation failure
|
| @@ -722,61 +746,6 @@ String HTMLCanvasElement::toDataURL(const String& mimeType,
|
| exceptionState.throwSecurityError("Tainted canvases may not be exported.");
|
| return String();
|
| }
|
| - Optional<ScopedUsHistogramTimer> timer;
|
| - String lowercaseMimeType = mimeType.lower();
|
| - if (mimeType.isNull())
|
| - lowercaseMimeType = DefaultMimeType;
|
| - if (lowercaseMimeType == "image/png") {
|
| - DEFINE_THREAD_SAFE_STATIC_LOCAL(
|
| - CustomCountHistogram, scopedUsCounterPNG,
|
| - new CustomCountHistogram("Blink.Canvas.ToDataURL.PNG", 0, 10000000,
|
| - 50));
|
| - timer.emplace(scopedUsCounterPNG);
|
| - } else if (lowercaseMimeType == "image/jpeg") {
|
| - DEFINE_THREAD_SAFE_STATIC_LOCAL(
|
| - CustomCountHistogram, scopedUsCounterJPEG,
|
| - new CustomCountHistogram("Blink.Canvas.ToDataURL.JPEG", 0, 10000000,
|
| - 50));
|
| - timer.emplace(scopedUsCounterJPEG);
|
| - } else if (lowercaseMimeType == "image/webp") {
|
| - DEFINE_THREAD_SAFE_STATIC_LOCAL(
|
| - CustomCountHistogram, scopedUsCounterWEBP,
|
| - new CustomCountHistogram("Blink.Canvas.ToDataURL.WEBP", 0, 10000000,
|
| - 50));
|
| - timer.emplace(scopedUsCounterWEBP);
|
| - } else if (lowercaseMimeType == "image/gif") {
|
| - DEFINE_THREAD_SAFE_STATIC_LOCAL(
|
| - CustomCountHistogram, scopedUsCounterGIF,
|
| - new CustomCountHistogram("Blink.Canvas.ToDataURL.GIF", 0, 10000000,
|
| - 50));
|
| - timer.emplace(scopedUsCounterGIF);
|
| - } else if (lowercaseMimeType == "image/bmp" ||
|
| - lowercaseMimeType == "image/x-windows-bmp") {
|
| - DEFINE_THREAD_SAFE_STATIC_LOCAL(
|
| - CustomCountHistogram, scopedUsCounterBMP,
|
| - new CustomCountHistogram("Blink.Canvas.ToDataURL.BMP", 0, 10000000,
|
| - 50));
|
| - timer.emplace(scopedUsCounterBMP);
|
| - } else if (lowercaseMimeType == "image/x-icon") {
|
| - DEFINE_THREAD_SAFE_STATIC_LOCAL(
|
| - CustomCountHistogram, scopedUsCounterICON,
|
| - new CustomCountHistogram("Blink.Canvas.ToDataURL.ICON", 0, 10000000,
|
| - 50));
|
| - timer.emplace(scopedUsCounterICON);
|
| - } else if (lowercaseMimeType == "image/tiff" ||
|
| - lowercaseMimeType == "image/x-tiff") {
|
| - DEFINE_THREAD_SAFE_STATIC_LOCAL(
|
| - CustomCountHistogram, scopedUsCounterTIFF,
|
| - new CustomCountHistogram("Blink.Canvas.ToDataURL.TIFF", 0, 10000000,
|
| - 50));
|
| - timer.emplace(scopedUsCounterTIFF);
|
| - } else {
|
| - DEFINE_THREAD_SAFE_STATIC_LOCAL(
|
| - CustomCountHistogram, scopedUsCounterUnknown,
|
| - new CustomCountHistogram("Blink.Canvas.ToDataURL.Unknown", 0, 10000000,
|
| - 50));
|
| - timer.emplace(scopedUsCounterUnknown);
|
| - }
|
|
|
| double quality = UndefinedQualityValue;
|
| if (!qualityArgument.isEmpty()) {
|
|
|