OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/interrupt_reasons.h" | 5 #include "content/browser/download/interrupt_reasons.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 | 8 |
9 #define FILE_ERROR_TO_INTERRUPT_REASON(n, d) \ | 9 #define FILE_ERROR_TO_INTERRUPT_REASON(n, d) \ |
10 case net::ERR_##n: return DOWNLOAD_INTERRUPT_REASON_FILE_##d; | 10 case net::ERR_##n: return DOWNLOAD_INTERRUPT_REASON_FILE_##d; |
11 | 11 |
12 #define NET_ERROR_TO_INTERRUPT_REASON(n, d) \ | 12 #define NET_ERROR_TO_INTERRUPT_REASON(n, d) \ |
13 case net::ERR_##n: return DOWNLOAD_INTERRUPT_REASON_NETWORK_##d; | 13 case net::ERR_##n: return DOWNLOAD_INTERRUPT_REASON_NETWORK_##d; |
14 | 14 |
15 #define SERVER_ERROR_TO_INTERRUPT_REASON(n, d) \ | 15 #define SERVER_ERROR_TO_INTERRUPT_REASON(n, d) \ |
16 case net::ERR_##n: return DOWNLOAD_INTERRUPT_REASON_SERVER_##d; | 16 case net::ERR_##n: return DOWNLOAD_INTERRUPT_REASON_SERVER_##d; |
17 | 17 |
18 InterruptReason ConvertNetErrorToInterruptReason( | 18 InterruptReason ConvertNetErrorToInterruptReason( |
19 net::Error net_error, DownloadInterruptSource source) { | 19 net::Error net_error, DownloadInterruptSource source) { |
20 switch (net_error) { | 20 switch (net_error) { |
21 // File errors. | 21 // File errors. |
| 22 case net::OK: return DOWNLOAD_INTERRUPT_REASON_NONE; |
22 | 23 |
23 // The file is too large. | 24 // The file is too large. |
24 FILE_ERROR_TO_INTERRUPT_REASON(FILE_TOO_BIG, TOO_LARGE) | 25 FILE_ERROR_TO_INTERRUPT_REASON(FILE_TOO_BIG, TOO_LARGE) |
25 | 26 |
26 // Permission to access a resource, other than the network, was denied. | 27 // Permission to access a resource, other than the network, was denied. |
27 FILE_ERROR_TO_INTERRUPT_REASON(ACCESS_DENIED, ACCESS_DENIED) | 28 FILE_ERROR_TO_INTERRUPT_REASON(ACCESS_DENIED, ACCESS_DENIED) |
28 | 29 |
29 // There were not enough resources to complete the operation. | 30 // There were not enough resources to complete the operation. |
30 FILE_ERROR_TO_INTERRUPT_REASON(INSUFFICIENT_RESOURCES, TRANSIENT_ERROR) | 31 FILE_ERROR_TO_INTERRUPT_REASON(INSUFFICIENT_RESOURCES, TRANSIENT_ERROR) |
31 | 32 |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 #undef FILE_ERROR_TO_INTERRUPT_REASON | 87 #undef FILE_ERROR_TO_INTERRUPT_REASON |
87 #undef NET_ERROR_TO_INTERRUPT_REASON | 88 #undef NET_ERROR_TO_INTERRUPT_REASON |
88 #undef SERVER_ERROR_TO_INTERRUPT_REASON | 89 #undef SERVER_ERROR_TO_INTERRUPT_REASON |
89 | 90 |
90 std::string InterruptReasonDebugString(InterruptReason error) { | 91 std::string InterruptReasonDebugString(InterruptReason error) { |
91 | 92 |
92 #define INTERRUPT_REASON(name, value) \ | 93 #define INTERRUPT_REASON(name, value) \ |
93 case DOWNLOAD_INTERRUPT_REASON_##name: return #name; | 94 case DOWNLOAD_INTERRUPT_REASON_##name: return #name; |
94 | 95 |
95 switch (error) { | 96 switch (error) { |
| 97 INTERRUPT_REASON(NONE, 0) |
| 98 |
96 #include "content/browser/download/interrupt_reason_values.h" | 99 #include "content/browser/download/interrupt_reason_values.h" |
| 100 |
97 default: | 101 default: |
98 break; | 102 break; |
99 } | 103 } |
100 | 104 |
101 #undef INTERRUPT_REASON | 105 #undef INTERRUPT_REASON |
102 | 106 |
103 return "Unknown error"; | 107 return "Unknown error"; |
104 } | 108 } |
OLD | NEW |