| 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 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 NOTIFICATION_HISTOGRAM_COUNTS(LoadFinishTime, m_type, | 153 NOTIFICATION_HISTOGRAM_COUNTS(LoadFinishTime, m_type, |
| 154 monotonicallyIncreasingTimeMS() - m_startTime, | 154 monotonicallyIncreasingTimeMS() - m_startTime, |
| 155 1000 * 60 * 60 /* 1 hour max */); | 155 1000 * 60 * 60 /* 1 hour max */); |
| 156 | 156 |
| 157 if (m_data) { | 157 if (m_data) { |
| 158 NOTIFICATION_HISTOGRAM_COUNTS(LoadFileSize, m_type, m_data->size(), | 158 NOTIFICATION_HISTOGRAM_COUNTS(LoadFileSize, m_type, m_data->size(), |
| 159 10000000 /* ~10mb max */); | 159 10000000 /* ~10mb max */); |
| 160 | 160 |
| 161 std::unique_ptr<ImageDecoder> decoder = ImageDecoder::create( | 161 std::unique_ptr<ImageDecoder> decoder = ImageDecoder::create( |
| 162 m_data, true /* dataComplete */, ImageDecoder::AlphaPremultiplied, | 162 m_data, true /* dataComplete */, ImageDecoder::AlphaPremultiplied, |
| 163 ImageDecoder::ColorSpaceTransformed, | 163 ColorBehavior::transformToGlobalTarget()); |
| 164 ImageDecoder::globalTargetColorSpace()); | |
| 165 if (decoder) { | 164 if (decoder) { |
| 166 // The |ImageFrame*| is owned by the decoder. | 165 // The |ImageFrame*| is owned by the decoder. |
| 167 ImageFrame* imageFrame = decoder->frameBufferAtIndex(0); | 166 ImageFrame* imageFrame = decoder->frameBufferAtIndex(0); |
| 168 if (imageFrame) { | 167 if (imageFrame) { |
| 169 (*m_imageCallback)(imageFrame->bitmap()); | 168 (*m_imageCallback)(imageFrame->bitmap()); |
| 170 return; | 169 return; |
| 171 } | 170 } |
| 172 } | 171 } |
| 173 } | 172 } |
| 174 runCallbackWithEmptyBitmap(); | 173 runCallbackWithEmptyBitmap(); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 189 void NotificationImageLoader::runCallbackWithEmptyBitmap() { | 188 void NotificationImageLoader::runCallbackWithEmptyBitmap() { |
| 190 // If this has been stopped it is not desirable to trigger further work, | 189 // If this has been stopped it is not desirable to trigger further work, |
| 191 // there is a shutdown of some sort in progress. | 190 // there is a shutdown of some sort in progress. |
| 192 if (m_stopped) | 191 if (m_stopped) |
| 193 return; | 192 return; |
| 194 | 193 |
| 195 (*m_imageCallback)(SkBitmap()); | 194 (*m_imageCallback)(SkBitmap()); |
| 196 } | 195 } |
| 197 | 196 |
| 198 } // namespace blink | 197 } // namespace blink |
| OLD | NEW |