Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(13)

Side by Side Diff: third_party/WebKit/Source/modules/notifications/NotificationImageLoader.cpp

Issue 2257513002: Refactor ImageDecoder factories (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: review Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698