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 |
11 DownloadInterruptReason ConvertNetErrorToInterruptReason( | 40 DownloadInterruptReason ConvertNetErrorToInterruptReason( |
12 net::Error net_error, DownloadInterruptSource source) { | 41 net::Error net_error, DownloadInterruptSource source) { |
13 switch (net_error) { | 42 switch (net_error) { |
14 case net::OK: | 43 case net::OK: |
15 return DOWNLOAD_INTERRUPT_REASON_NONE; | 44 return DOWNLOAD_INTERRUPT_REASON_NONE; |
16 | 45 |
17 // File errors. | 46 // File errors. |
18 | 47 |
19 // The file is too large. | 48 // The file is too large. |
20 case net::ERR_FILE_TOO_BIG: | 49 case net::ERR_FILE_TOO_BIG: |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 default: | 130 default: |
102 break; | 131 break; |
103 } | 132 } |
104 | 133 |
105 #undef INTERRUPT_REASON | 134 #undef INTERRUPT_REASON |
106 | 135 |
107 return "Unknown error"; | 136 return "Unknown error"; |
108 } | 137 } |
109 | 138 |
110 } // namespace content | 139 } // namespace content |
OLD | NEW |