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" |
11 #include "platform/image-decoders/ImageFrame.h" | 11 #include "platform/image-decoders/ImageFrame.h" |
12 #include "platform/network/ResourceError.h" | 12 #include "platform/network/ResourceError.h" |
13 #include "platform/network/ResourceLoadPriority.h" | 13 #include "platform/network/ResourceLoadPriority.h" |
14 #include "platform/network/ResourceRequest.h" | 14 #include "platform/network/ResourceRequest.h" |
15 #include "platform/weborigin/KURL.h" | 15 #include "platform/weborigin/KURL.h" |
16 #include "public/platform/WebURLRequest.h" | 16 #include "public/platform/WebURLRequest.h" |
17 #include "third_party/skia/include/core/SkBitmap.h" | 17 #include "third_party/skia/include/core/SkBitmap.h" |
18 #include "wtf/CurrentTime.h" | 18 #include "wtf/CurrentTime.h" |
19 #include "wtf/Threading.h" | 19 #include "wtf/Threading.h" |
20 #include <memory> | |
21 | 20 |
22 namespace blink { | 21 namespace blink { |
23 | 22 |
24 NotificationImageLoader::NotificationImageLoader() | 23 NotificationImageLoader::NotificationImageLoader() |
25 : m_stopped(false), m_startTime(0.0) | 24 : m_stopped(false), m_startTime(0.0) |
26 { | 25 { |
27 } | 26 } |
28 | 27 |
29 NotificationImageLoader::~NotificationImageLoader() | 28 NotificationImageLoader::~NotificationImageLoader() |
30 { | 29 { |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 if (m_stopped) | 86 if (m_stopped) |
88 return; | 87 return; |
89 | 88 |
90 DEFINE_THREAD_SAFE_STATIC_LOCAL(CustomCountHistogram, finishedTimeHistogram,
new CustomCountHistogram("Notifications.Icon.LoadFinishTime", 1, 1000 * 60 * 60
/* 1 hour max */, 50 /* buckets */)); | 89 DEFINE_THREAD_SAFE_STATIC_LOCAL(CustomCountHistogram, finishedTimeHistogram,
new CustomCountHistogram("Notifications.Icon.LoadFinishTime", 1, 1000 * 60 * 60
/* 1 hour max */, 50 /* buckets */)); |
91 finishedTimeHistogram.count(monotonicallyIncreasingTimeMS() - m_startTime); | 90 finishedTimeHistogram.count(monotonicallyIncreasingTimeMS() - m_startTime); |
92 | 91 |
93 if (m_data) { | 92 if (m_data) { |
94 DEFINE_THREAD_SAFE_STATIC_LOCAL(CustomCountHistogram, fileSizeHistogram,
new CustomCountHistogram("Notifications.Icon.FileSize", 1, 10000000 /* ~10mb ma
x */, 50 /* buckets */)); | 93 DEFINE_THREAD_SAFE_STATIC_LOCAL(CustomCountHistogram, fileSizeHistogram,
new CustomCountHistogram("Notifications.Icon.FileSize", 1, 10000000 /* ~10mb ma
x */, 50 /* buckets */)); |
95 fileSizeHistogram.count(m_data->size()); | 94 fileSizeHistogram.count(m_data->size()); |
96 | 95 |
97 std::unique_ptr<ImageDecoder> decoder = ImageDecoder::create(*m_data.get
(), ImageDecoder::AlphaPremultiplied, ImageDecoder::GammaAndColorProfileApplied)
; | 96 OwnPtr<ImageDecoder> decoder = ImageDecoder::create(*m_data.get(), Image
Decoder::AlphaPremultiplied, ImageDecoder::GammaAndColorProfileApplied); |
98 if (decoder) { | 97 if (decoder) { |
99 decoder->setData(m_data.get(), true /* allDataReceived */); | 98 decoder->setData(m_data.get(), true /* allDataReceived */); |
100 // The |ImageFrame*| is owned by the decoder. | 99 // The |ImageFrame*| is owned by the decoder. |
101 ImageFrame* imageFrame = decoder->frameBufferAtIndex(0); | 100 ImageFrame* imageFrame = decoder->frameBufferAtIndex(0); |
102 if (imageFrame) { | 101 if (imageFrame) { |
103 (*m_imageCallback)(imageFrame->bitmap()); | 102 (*m_imageCallback)(imageFrame->bitmap()); |
104 return; | 103 return; |
105 } | 104 } |
106 } | 105 } |
107 } | 106 } |
(...skipping 17 matching lines...) Expand all Loading... |
125 { | 124 { |
126 // 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, |
127 // there is a shutdown of some sort in progress. | 126 // there is a shutdown of some sort in progress. |
128 if (m_stopped) | 127 if (m_stopped) |
129 return; | 128 return; |
130 | 129 |
131 (*m_imageCallback)(SkBitmap()); | 130 (*m_imageCallback)(SkBitmap()); |
132 } | 131 } |
133 | 132 |
134 } // namespace blink | 133 } // namespace blink |
OLD | NEW |