OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/browser/download/download_interrupt_reasons_impl.h" | 5 #include "content/browser/download/download_interrupt_reasons_impl.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 | 8 |
9 namespace content { | 9 namespace content { |
10 | 10 |
11 DownloadInterruptReason ConvertFileErrorToInterruptReason( | |
12 base::File::Error file_error) { | |
13 switch (file_error) { | |
14 case base::File::FILE_OK: | |
15 return DOWNLOAD_INTERRUPT_REASON_NONE; | |
16 | |
17 case base::File::FILE_ERROR_IN_USE: | |
18 return DOWNLOAD_INTERRUPT_REASON_FILE_TRANSIENT_ERROR; | |
19 | |
20 case base::File::FILE_ERROR_ACCESS_DENIED: | |
21 return DOWNLOAD_INTERRUPT_REASON_FILE_ACCESS_DENIED; | |
22 | |
23 case base::File::FILE_ERROR_TOO_MANY_OPENED: | |
24 return DOWNLOAD_INTERRUPT_REASON_FILE_TRANSIENT_ERROR; | |
25 | |
26 case base::File::FILE_ERROR_NO_MEMORY: | |
27 return DOWNLOAD_INTERRUPT_REASON_FILE_TRANSIENT_ERROR; | |
28 | |
29 case base::File::FILE_ERROR_NO_SPACE: | |
30 return DOWNLOAD_INTERRUPT_REASON_FILE_NO_SPACE; | |
31 | |
32 case base::File::FILE_ERROR_SECURITY: | |
33 return DOWNLOAD_INTERRUPT_REASON_FILE_ACCESS_DENIED; | |
34 | |
35 default: | |
36 return DOWNLOAD_INTERRUPT_REASON_FILE_FAILED; | |
37 } | |
38 } | |
39 | |
40 DownloadInterruptReason ConvertNetErrorToInterruptReason( | 11 DownloadInterruptReason ConvertNetErrorToInterruptReason( |
41 net::Error net_error, DownloadInterruptSource source) { | 12 net::Error net_error, DownloadInterruptSource source) { |
42 switch (net_error) { | 13 switch (net_error) { |
43 case net::OK: | 14 case net::OK: |
44 return DOWNLOAD_INTERRUPT_REASON_NONE; | 15 return DOWNLOAD_INTERRUPT_REASON_NONE; |
45 | 16 |
46 // File errors. | 17 // File errors. |
47 | 18 |
48 // The file is too large. | 19 // The file is too large. |
49 case net::ERR_FILE_TOO_BIG: | 20 case net::ERR_FILE_TOO_BIG: |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 default: | 101 default: |
131 break; | 102 break; |
132 } | 103 } |
133 | 104 |
134 #undef INTERRUPT_REASON | 105 #undef INTERRUPT_REASON |
135 | 106 |
136 return "Unknown error"; | 107 return "Unknown error"; |
137 } | 108 } |
138 | 109 |
139 } // namespace content | 110 } // namespace content |
OLD | NEW |