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

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

Issue 2050123002: Remove OwnPtr from Blink. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: First attempt to land. Created 4 years, 6 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"
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>
20 21
21 namespace blink { 22 namespace blink {
22 23
23 NotificationImageLoader::NotificationImageLoader() 24 NotificationImageLoader::NotificationImageLoader()
24 : m_stopped(false), m_startTime(0.0) 25 : m_stopped(false), m_startTime(0.0)
25 { 26 {
26 } 27 }
27 28
28 NotificationImageLoader::~NotificationImageLoader() 29 NotificationImageLoader::~NotificationImageLoader()
29 { 30 {
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 if (m_stopped) 87 if (m_stopped)
87 return; 88 return;
88 89
89 DEFINE_THREAD_SAFE_STATIC_LOCAL(CustomCountHistogram, finishedTimeHistogram, new CustomCountHistogram("Notifications.Icon.LoadFinishTime", 1, 1000 * 60 * 60 /* 1 hour max */, 50 /* buckets */)); 90 DEFINE_THREAD_SAFE_STATIC_LOCAL(CustomCountHistogram, finishedTimeHistogram, new CustomCountHistogram("Notifications.Icon.LoadFinishTime", 1, 1000 * 60 * 60 /* 1 hour max */, 50 /* buckets */));
90 finishedTimeHistogram.count(monotonicallyIncreasingTimeMS() - m_startTime); 91 finishedTimeHistogram.count(monotonicallyIncreasingTimeMS() - m_startTime);
91 92
92 if (m_data) { 93 if (m_data) {
93 DEFINE_THREAD_SAFE_STATIC_LOCAL(CustomCountHistogram, fileSizeHistogram, new CustomCountHistogram("Notifications.Icon.FileSize", 1, 10000000 /* ~10mb ma x */, 50 /* buckets */)); 94 DEFINE_THREAD_SAFE_STATIC_LOCAL(CustomCountHistogram, fileSizeHistogram, new CustomCountHistogram("Notifications.Icon.FileSize", 1, 10000000 /* ~10mb ma x */, 50 /* buckets */));
94 fileSizeHistogram.count(m_data->size()); 95 fileSizeHistogram.count(m_data->size());
95 96
96 OwnPtr<ImageDecoder> decoder = ImageDecoder::create(*m_data.get(), Image Decoder::AlphaPremultiplied, ImageDecoder::GammaAndColorProfileApplied); 97 std::unique_ptr<ImageDecoder> decoder = ImageDecoder::create(*m_data.get (), ImageDecoder::AlphaPremultiplied, ImageDecoder::GammaAndColorProfileApplied) ;
97 if (decoder) { 98 if (decoder) {
98 decoder->setData(m_data.get(), true /* allDataReceived */); 99 decoder->setData(m_data.get(), true /* allDataReceived */);
99 // The |ImageFrame*| is owned by the decoder. 100 // The |ImageFrame*| is owned by the decoder.
100 ImageFrame* imageFrame = decoder->frameBufferAtIndex(0); 101 ImageFrame* imageFrame = decoder->frameBufferAtIndex(0);
101 if (imageFrame) { 102 if (imageFrame) {
102 (*m_imageCallback)(imageFrame->bitmap()); 103 (*m_imageCallback)(imageFrame->bitmap());
103 return; 104 return;
104 } 105 }
105 } 106 }
106 } 107 }
(...skipping 17 matching lines...) Expand all
124 { 125 {
125 // If this has been stopped it is not desirable to trigger further work, 126 // If this has been stopped it is not desirable to trigger further work,
126 // there is a shutdown of some sort in progress. 127 // there is a shutdown of some sort in progress.
127 if (m_stopped) 128 if (m_stopped)
128 return; 129 return;
129 130
130 (*m_imageCallback)(SkBitmap()); 131 (*m_imageCallback)(SkBitmap());
131 } 132 }
132 133
133 } // namespace blink 134 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698