xref: /aosp_15_r20/external/cronet/components/cronet/android/url_request_error.cc (revision 6777b5387eb2ff775bb5750e3f5d96f37fb7352b)
1 // Copyright 2016 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #include "components/cronet/android/url_request_error.h"
6 
7 #include "net/base/net_errors.h"
8 
9 namespace cronet {
10 
NetErrorToUrlRequestError(int net_error)11 UrlRequestError NetErrorToUrlRequestError(int net_error) {
12   switch (net_error) {
13     case net::ERR_NAME_NOT_RESOLVED:
14       return HOSTNAME_NOT_RESOLVED;
15     case net::ERR_INTERNET_DISCONNECTED:
16       return INTERNET_DISCONNECTED;
17     case net::ERR_NETWORK_CHANGED:
18       return NETWORK_CHANGED;
19     case net::ERR_TIMED_OUT:
20       return TIMED_OUT;
21     case net::ERR_CONNECTION_CLOSED:
22       return CONNECTION_CLOSED;
23     case net::ERR_CONNECTION_TIMED_OUT:
24       return CONNECTION_TIMED_OUT;
25     case net::ERR_CONNECTION_REFUSED:
26       return CONNECTION_REFUSED;
27     case net::ERR_CONNECTION_RESET:
28       return CONNECTION_RESET;
29     case net::ERR_ADDRESS_UNREACHABLE:
30       return ADDRESS_UNREACHABLE;
31     case net::ERR_QUIC_PROTOCOL_ERROR:
32       return QUIC_PROTOCOL_FAILED;
33     default:
34       return OTHER;
35   }
36 }
37 
38 }  // namespace cronet
39