Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "modules/notifications/NotificationImageLoader.h" | 5 #include "modules/notifications/NotificationImageLoader.h" |
| 6 | 6 |
| 7 #include "core/dom/ExecutionContext.h" | 7 #include "core/dom/ExecutionContext.h" |
| 8 #include "core/fetch/ResourceLoaderOptions.h" | 8 #include "core/fetch/ResourceLoaderOptions.h" |
| 9 #include "platform/Histogram.h" | 9 #include "platform/Histogram.h" |
| 10 #include "platform/image-decoders/ImageDecoder.h" | 10 #include "platform/image-decoders/ImageDecoder.h" |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 88 | 88 |
| 89 if (m_data) { | 89 if (m_data) { |
| 90 DEFINE_THREAD_SAFE_STATIC_LOCAL(CustomCountHistogram, fileSizeHistogram, new CustomCountHistogram("Notifications.Icon.FileSize", 1, 10000000 /* ~10mb ma x */, 50 /* buckets */)); | 90 DEFINE_THREAD_SAFE_STATIC_LOCAL(CustomCountHistogram, fileSizeHistogram, new CustomCountHistogram("Notifications.Icon.FileSize", 1, 10000000 /* ~10mb ma x */, 50 /* buckets */)); |
| 91 fileSizeHistogram.count(m_data->size()); | 91 fileSizeHistogram.count(m_data->size()); |
| 92 | 92 |
| 93 std::unique_ptr<ImageDecoder> decoder = ImageDecoder::create(ImageDecode r::determineImageType(*m_data.get()), ImageDecoder::AlphaPremultiplied, ImageDec oder::GammaAndColorProfileApplied); | 93 std::unique_ptr<ImageDecoder> decoder = ImageDecoder::create(ImageDecode r::determineImageType(*m_data.get()), ImageDecoder::AlphaPremultiplied, ImageDec oder::GammaAndColorProfileApplied); |
| 94 if (decoder) { | 94 if (decoder) { |
| 95 decoder->setData(m_data.get(), true /* allDataReceived */); | 95 decoder->setData(m_data.get(), true /* allDataReceived */); |
| 96 // The |ImageFrame*| is owned by the decoder. | 96 // The |ImageFrame*| is owned by the decoder. |
| 97 ImageFrame* imageFrame = decoder->frameBufferAtIndex(0); | 97 ImageFrame* imageFrame = decoder->frameBufferAtIndex(0); |
| 98 if (imageFrame) { | 98 DCHECK(decoder->failed() || imageFrame->getStatus() == ImageFrame::F rameComplete); |
|
Peter Kasting
2016/08/30 06:59:40
This check isn't safe if somehow failed() is false
aleksandar.stojiljkovic
2016/09/21 20:56:57
Done. Reverted. As allDataReceived is set to true
| |
| 99 (*m_imageCallback)(imageFrame->bitmap()); | 99 if (imageFrame && imageFrame->getStatus() == ImageFrame::FrameComple te) { |
| 100 SkBitmap bitmap = imageFrame->bitmap(); | |
| 101 bitmap.setImmutable(); | |
|
Peter Kasting
2016/08/30 06:59:40
Why is setting the bitmap as immutable here import
aleksandar.stojiljkovic
2016/09/21 20:56:57
That was my plan too, with all the cases where SkB
aleksandar.stojiljkovic
2016/09/21 20:56:57
Reverted this to original implementation - in Imag
Peter Kasting
2016/09/21 21:54:49
Blink is Chrome's fork, so we assume that we only
aleksandar.stojiljkovic
2016/09/22 09:41:19
Checked in details - a lot of layout tests are usi
| |
| 102 (*m_imageCallback)(bitmap); | |
| 100 return; | 103 return; |
| 101 } | 104 } |
| 102 } | 105 } |
| 103 } | 106 } |
| 104 runCallbackWithEmptyBitmap(); | 107 runCallbackWithEmptyBitmap(); |
| 105 } | 108 } |
| 106 | 109 |
| 107 void NotificationImageLoader::didFail(const ResourceError& error) | 110 void NotificationImageLoader::didFail(const ResourceError& error) |
| 108 { | 111 { |
| 109 DEFINE_THREAD_SAFE_STATIC_LOCAL(CustomCountHistogram, failedTimeHistogram, n ew CustomCountHistogram("Notifications.Icon.LoadFailTime", 1, 1000 * 60 * 60 /* 1 hour max */, 50 /* buckets */)); | 112 DEFINE_THREAD_SAFE_STATIC_LOCAL(CustomCountHistogram, failedTimeHistogram, n ew CustomCountHistogram("Notifications.Icon.LoadFailTime", 1, 1000 * 60 * 60 /* 1 hour max */, 50 /* buckets */)); |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 121 { | 124 { |
| 122 // If this has been stopped it is not desirable to trigger further work, | 125 // If this has been stopped it is not desirable to trigger further work, |
| 123 // there is a shutdown of some sort in progress. | 126 // there is a shutdown of some sort in progress. |
| 124 if (m_stopped) | 127 if (m_stopped) |
| 125 return; | 128 return; |
| 126 | 129 |
| 127 (*m_imageCallback)(SkBitmap()); | 130 (*m_imageCallback)(SkBitmap()); |
| 128 } | 131 } |
| 129 | 132 |
| 130 } // namespace blink | 133 } // namespace blink |
| OLD | NEW |