| 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/error_translation_util.h" | 5 #import "ios/web/web_state/error_translation_util.h" |
| 6 | 6 |
| 7 #include <CFNetwork/CFNetwork.h> | 7 #include <CFNetwork/CFNetwork.h> |
| 8 | 8 |
| 9 #import "base/ios/ns_error_util.h" | 9 #import "base/ios/ns_error_util.h" |
| 10 #include "base/mac/scoped_nsobject.h" | 10 #include "base/mac/scoped_nsobject.h" |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 base::ios::GetFinalUnderlyingErrorFromError(error); | 150 base::ios::GetFinalUnderlyingErrorFromError(error); |
| 151 | 151 |
| 152 NSInteger net_error_code = net::ERR_FAILED; | 152 NSInteger net_error_code = net::ERR_FAILED; |
| 153 if ([underlying_error.domain isEqualToString:NSURLErrorDomain] || | 153 if ([underlying_error.domain isEqualToString:NSURLErrorDomain] || |
| 154 [underlying_error.domain | 154 [underlying_error.domain |
| 155 isEqualToString:static_cast<NSString*>(kCFErrorDomainCFNetwork)]) { | 155 isEqualToString:static_cast<NSString*>(kCFErrorDomainCFNetwork)]) { |
| 156 // Attempt to translate NSURL and CFNetwork error codes into their | 156 // Attempt to translate NSURL and CFNetwork error codes into their |
| 157 // corresponding net error codes. | 157 // corresponding net error codes. |
| 158 GetNetErrorFromIOSErrorCode(underlying_error.code, &net_error_code); | 158 GetNetErrorFromIOSErrorCode(underlying_error.code, &net_error_code); |
| 159 } | 159 } |
| 160 return NetErrorFromError(error, net_error_code); |
| 161 } |
| 160 | 162 |
| 163 NSError* NetErrorFromError(NSError* error, NSInteger net_error_code) { |
| 164 DCHECK(error); |
| 161 NSString* net_error_domain = | 165 NSString* net_error_domain = |
| 162 [NSString stringWithUTF8String:net::kErrorDomain]; | 166 [NSString stringWithUTF8String:net::kErrorDomain]; |
| 163 NSError* net_error = [NSError errorWithDomain:net_error_domain | 167 NSError* net_error = [NSError errorWithDomain:net_error_domain |
| 164 code:net_error_code | 168 code:net_error_code |
| 165 userInfo:nil]; | 169 userInfo:nil]; |
| 166 return base::ios::ErrorWithAppendedUnderlyingError(error, net_error); | 170 return base::ios::ErrorWithAppendedUnderlyingError(error, net_error); |
| 167 } | 171 } |
| 168 | 172 |
| 169 } // namespace web | 173 } // namespace web |
| OLD | NEW |