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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 if (m_stopped) | 83 if (m_stopped) |
84 return; | 84 return; |
85 | 85 |
86 DEFINE_THREAD_SAFE_STATIC_LOCAL(CustomCountHistogram, finishedTimeHistogram,
new CustomCountHistogram("Notifications.Icon.LoadFinishTime", 1, 1000 * 60 * 60
/* 1 hour max */, 50 /* buckets */)); | 86 DEFINE_THREAD_SAFE_STATIC_LOCAL(CustomCountHistogram, finishedTimeHistogram,
new CustomCountHistogram("Notifications.Icon.LoadFinishTime", 1, 1000 * 60 * 60
/* 1 hour max */, 50 /* buckets */)); |
87 finishedTimeHistogram.count(monotonicallyIncreasingTimeMS() - m_startTime); | 87 finishedTimeHistogram.count(monotonicallyIncreasingTimeMS() - m_startTime); |
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(m_data, tru
e /* dataComplete */, |
| 94 ImageDecoder::AlphaPremultiplied, ImageDecoder::GammaAndColorProfile
Applied); |
94 if (decoder) { | 95 if (decoder) { |
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 if (imageFrame) { |
99 (*m_imageCallback)(imageFrame->bitmap()); | 99 (*m_imageCallback)(imageFrame->bitmap()); |
100 return; | 100 return; |
101 } | 101 } |
102 } | 102 } |
103 } | 103 } |
104 runCallbackWithEmptyBitmap(); | 104 runCallbackWithEmptyBitmap(); |
105 } | 105 } |
(...skipping 15 matching lines...) Expand all Loading... |
121 { | 121 { |
122 // If this has been stopped it is not desirable to trigger further work, | 122 // If this has been stopped it is not desirable to trigger further work, |
123 // there is a shutdown of some sort in progress. | 123 // there is a shutdown of some sort in progress. |
124 if (m_stopped) | 124 if (m_stopped) |
125 return; | 125 return; |
126 | 126 |
127 (*m_imageCallback)(SkBitmap()); | 127 (*m_imageCallback)(SkBitmap()); |
128 } | 128 } |
129 | 129 |
130 } // namespace blink | 130 } // namespace blink |
OLD | NEW |