| 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" |
| 11 #include "net/base/net_errors.h" | 11 #include "net/base/net_errors.h" |
| 12 | 12 |
| 13 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 14 #error "This file requires ARC support." |
| 15 #endif |
| 16 |
| 13 namespace web { | 17 namespace web { |
| 14 | 18 |
| 15 namespace { | 19 namespace { |
| 16 // Translates an iOS error to a net error using |net_error_code| as an | 20 // Translates an iOS error to a net error using |net_error_code| as an |
| 17 // out-parameter. Returns true if a valid translation was found. | 21 // out-parameter. Returns true if a valid translation was found. |
| 18 bool GetNetErrorFromIOSErrorCode(NSInteger ios_error_code, | 22 bool GetNetErrorFromIOSErrorCode(NSInteger ios_error_code, |
| 19 NSInteger* net_error_code) { | 23 NSInteger* net_error_code) { |
| 20 DCHECK(net_error_code); | 24 DCHECK(net_error_code); |
| 21 bool translation_success = true; | 25 bool translation_success = true; |
| 22 switch (ios_error_code) { | 26 switch (ios_error_code) { |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 DCHECK(error); | 168 DCHECK(error); |
| 165 NSString* net_error_domain = | 169 NSString* net_error_domain = |
| 166 [NSString stringWithUTF8String:net::kErrorDomain]; | 170 [NSString stringWithUTF8String:net::kErrorDomain]; |
| 167 NSError* net_error = [NSError errorWithDomain:net_error_domain | 171 NSError* net_error = [NSError errorWithDomain:net_error_domain |
| 168 code:net_error_code | 172 code:net_error_code |
| 169 userInfo:nil]; | 173 userInfo:nil]; |
| 170 return base::ios::ErrorWithAppendedUnderlyingError(error, net_error); | 174 return base::ios::ErrorWithAppendedUnderlyingError(error, net_error); |
| 171 } | 175 } |
| 172 | 176 |
| 173 } // namespace web | 177 } // namespace web |
| OLD | NEW |