| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 #import "ios/web/web_state/crw_pass_kit_downloader.h" | 5 #import "ios/web/web_state/crw_pass_kit_downloader.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #import "base/ios/weak_nsobject.h" | 9 #import "base/ios/weak_nsobject.h" |
| 10 #include "base/mac/scoped_block.h" | 10 #include "base/mac/scoped_block.h" |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "base/metrics/histogram.h" | 12 #include "base/metrics/histogram.h" |
| 13 #include "base/strings/sys_string_conversions.h" | 13 #include "base/strings/sys_string_conversions.h" |
| 14 #import "ios/web/crw_network_activity_indicator_manager.h" | 14 #import "ios/web/crw_network_activity_indicator_manager.h" |
| 15 #include "net/http/http_response_headers.h" | 15 #include "net/http/http_response_headers.h" |
| 16 #include "net/url_request/url_fetcher.h" | 16 #include "net/url_request/url_fetcher.h" |
| 17 #include "net/url_request/url_fetcher_delegate.h" | 17 #include "net/url_request/url_fetcher_delegate.h" |
| 18 #include "net/url_request/url_request_context_getter.h" | 18 #include "net/url_request/url_request_context_getter.h" |
| 19 | 19 |
| 20 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 21 #error "This file requires ARC support." |
| 22 #endif |
| 23 |
| 20 using net::URLFetcher; | 24 using net::URLFetcher; |
| 21 using net::URLFetcherDelegate; | 25 using net::URLFetcherDelegate; |
| 22 using net::URLRequestContextGetter; | 26 using net::URLRequestContextGetter; |
| 23 | 27 |
| 24 namespace { | 28 namespace { |
| 25 | 29 |
| 26 // Key of the UMA Download.IOSDownloadPassKitResult histogram. | 30 // Key of the UMA Download.IOSDownloadPassKitResult histogram. |
| 27 const char kUMADownloadPassKitResult[] = "Download.IOSDownloadPassKitResult"; | 31 const char kUMADownloadPassKitResult[] = "Download.IOSDownloadPassKitResult"; |
| 28 | 32 |
| 29 // Enum for the Download.IOSDownloadPassKitResult UMA histogram to report the | 33 // Enum for the Download.IOSDownloadPassKitResult UMA histogram to report the |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 } | 121 } |
| 118 | 122 |
| 119 - (instancetype)init { | 123 - (instancetype)init { |
| 120 NOTREACHED(); | 124 NOTREACHED(); |
| 121 return nil; | 125 return nil; |
| 122 } | 126 } |
| 123 | 127 |
| 124 - (void)dealloc { | 128 - (void)dealloc { |
| 125 [[CRWNetworkActivityIndicatorManager sharedInstance] | 129 [[CRWNetworkActivityIndicatorManager sharedInstance] |
| 126 clearNetworkTasksForGroup:[self networkActivityKey]]; | 130 clearNetworkTasksForGroup:[self networkActivityKey]]; |
| 127 [super dealloc]; | |
| 128 } | 131 } |
| 129 | 132 |
| 130 - (BOOL)isMIMETypePassKitType:(NSString*)MIMEType { | 133 - (BOOL)isMIMETypePassKitType:(NSString*)MIMEType { |
| 131 return [MIMEType isEqualToString:@"application/vnd.apple.pkpass"]; | 134 return [MIMEType isEqualToString:@"application/vnd.apple.pkpass"]; |
| 132 } | 135 } |
| 133 | 136 |
| 134 - (void)downloadPassKitFileWithURL:(const GURL&)URL { | 137 - (void)downloadPassKitFileWithURL:(const GURL&)URL { |
| 135 _fetcher = URLFetcher::Create(URL, URLFetcher::GET, _fetcherDelegate.get()); | 138 _fetcher = URLFetcher::Create(URL, URLFetcher::GET, _fetcherDelegate.get()); |
| 136 _fetcher->SetRequestContext(_requestContextGetter.get()); | 139 _fetcher->SetRequestContext(_requestContextGetter.get()); |
| 137 CRWNetworkActivityIndicatorManager* sharedManager = | 140 CRWNetworkActivityIndicatorManager* sharedManager = |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 stringWithFormat:@"PassKitDownloader.NetworkActivityIndicatorKey.%d", | 197 stringWithFormat:@"PassKitDownloader.NetworkActivityIndicatorKey.%d", |
| 195 _passKitDownloaderID]; | 198 _passKitDownloaderID]; |
| 196 } | 199 } |
| 197 | 200 |
| 198 - (void)reportUMAPassKitResult:(DownloadPassKitResult)result { | 201 - (void)reportUMAPassKitResult:(DownloadPassKitResult)result { |
| 199 UMA_HISTOGRAM_ENUMERATION(kUMADownloadPassKitResult, result, | 202 UMA_HISTOGRAM_ENUMERATION(kUMADownloadPassKitResult, result, |
| 200 DOWNLOAD_PASS_KIT_RESULT_COUNT); | 203 DOWNLOAD_PASS_KIT_RESULT_COUNT); |
| 201 } | 204 } |
| 202 | 205 |
| 203 @end | 206 @end |
| OLD | NEW |