| 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 <memory> | 7 #include <memory> |
| 8 #include "core/dom/ExecutionContext.h" | 8 #include "core/dom/ExecutionContext.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/loader/fetch/ResourceError.h" | 12 #include "platform/loader/fetch/ResourceError.h" |
| 13 #include "platform/loader/fetch/ResourceLoadPriority.h" | 13 #include "platform/loader/fetch/ResourceLoadPriority.h" |
| 14 #include "platform/loader/fetch/ResourceLoaderOptions.h" | 14 #include "platform/loader/fetch/ResourceLoaderOptions.h" |
| 15 #include "platform/loader/fetch/ResourceRequest.h" | 15 #include "platform/loader/fetch/ResourceRequest.h" |
| 16 #include "platform/weborigin/KURL.h" | 16 #include "platform/weborigin/KURL.h" |
| 17 #include "public/platform/WebURLRequest.h" | 17 #include "public/platform/WebURLRequest.h" |
| 18 #include "public/platform/modules/notifications/WebNotificationConstants.h" | 18 #include "public/platform/modules/notifications/WebNotificationConstants.h" |
| 19 #include "skia/ext/image_operations.h" | 19 #include "skia/ext/image_operations.h" |
| 20 #include "wtf/CurrentTime.h" | 20 #include "wtf/CurrentTime.h" |
| 21 #include "wtf/Threading.h" | 21 #include "wtf/Threading.h" |
| 22 | 22 |
| 23 #define NOTIFICATION_PER_TYPE_HISTOGRAM_COUNTS(metric, type_name, value, max) \ | 23 #define NOTIFICATION_PER_TYPE_HISTOGRAM_COUNTS(metric, type_name, value, max) \ |
| 24 case NotificationImageLoader::Type::type_name: { \ | 24 case NotificationImageLoader::Type::k##type_name: { \ |
| 25 DEFINE_THREAD_SAFE_STATIC_LOCAL( \ | 25 DEFINE_THREAD_SAFE_STATIC_LOCAL( \ |
| 26 CustomCountHistogram, metric##type_name##Histogram, \ | 26 CustomCountHistogram, metric##type_name##Histogram, \ |
| 27 new CustomCountHistogram("Notifications." #metric "." #type_name, \ | 27 new CustomCountHistogram("Notifications." #metric "." #type_name, \ |
| 28 1 /* min */, max, 50 /* buckets */)); \ | 28 1 /* min */, max, 50 /* buckets */)); \ |
| 29 metric##type_name##Histogram.count(value); \ | 29 metric##type_name##Histogram.count(value); \ |
| 30 break; \ | 30 break; \ |
| 31 } | 31 } |
| 32 | 32 |
| 33 #define NOTIFICATION_HISTOGRAM_COUNTS(metric, type, value, max) \ | 33 #define NOTIFICATION_HISTOGRAM_COUNTS(metric, type, value, max) \ |
| 34 /* DO NOT SUBMIT - conflict resolution helper: |
| 35 * Important to have Image instead of kImage below. */ |
| 34 switch (type) { \ | 36 switch (type) { \ |
| 35 NOTIFICATION_PER_TYPE_HISTOGRAM_COUNTS(metric, Image, value, max) \ | 37 NOTIFICATION_PER_TYPE_HISTOGRAM_COUNTS(metric, Image, value, max) \ |
| 36 NOTIFICATION_PER_TYPE_HISTOGRAM_COUNTS(metric, Icon, value, max) \ | 38 NOTIFICATION_PER_TYPE_HISTOGRAM_COUNTS(metric, Icon, value, max) \ |
| 37 NOTIFICATION_PER_TYPE_HISTOGRAM_COUNTS(metric, Badge, value, max) \ | 39 NOTIFICATION_PER_TYPE_HISTOGRAM_COUNTS(metric, Badge, value, max) \ |
| 40 /* DO NOT SUBMIT - conflict resolution helper: |
| 41 * Important to have ActionIcon instead of kActionIcon below. */ |
| 38 NOTIFICATION_PER_TYPE_HISTOGRAM_COUNTS(metric, ActionIcon, value, max) \ | 42 NOTIFICATION_PER_TYPE_HISTOGRAM_COUNTS(metric, ActionIcon, value, max) \ |
| 39 } | 43 } |
| 40 | 44 |
| 41 namespace { | 45 namespace { |
| 42 | 46 |
| 43 // 99.9% of all images were fetched successfully in 90 seconds. | 47 // 99.9% of all images were fetched successfully in 90 seconds. |
| 44 const unsigned long kImageFetchTimeoutInMs = 90000; | 48 const unsigned long kImageFetchTimeoutInMs = 90000; |
| 45 | 49 |
| 46 } // namespace | 50 } // namespace |
| 47 | 51 |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 void NotificationImageLoader::runCallbackWithEmptyBitmap() { | 192 void NotificationImageLoader::runCallbackWithEmptyBitmap() { |
| 189 // If this has been stopped it is not desirable to trigger further work, | 193 // If this has been stopped it is not desirable to trigger further work, |
| 190 // there is a shutdown of some sort in progress. | 194 // there is a shutdown of some sort in progress. |
| 191 if (m_stopped) | 195 if (m_stopped) |
| 192 return; | 196 return; |
| 193 | 197 |
| 194 (*m_imageCallback)(SkBitmap()); | 198 (*m_imageCallback)(SkBitmap()); |
| 195 } | 199 } |
| 196 | 200 |
| 197 } // namespace blink | 201 } // namespace blink |
| OLD | NEW |