Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(519)

Side by Side Diff: content/browser/download/interrupt_reasons.cc

Issue 9639001: Move download interrupt reasons to content\public (the enum that's used by chrome). The rest keep i… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: nits Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « content/browser/download/interrupt_reasons.h ('k') | content/content_browser.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "content/browser/download/interrupt_reasons.h"
6
7 #include "base/logging.h"
8
9 #define FILE_ERROR_TO_INTERRUPT_REASON(n, d) \
10 case net::ERR_##n: return DOWNLOAD_INTERRUPT_REASON_FILE_##d;
11
12 #define NET_ERROR_TO_INTERRUPT_REASON(n, d) \
13 case net::ERR_##n: return DOWNLOAD_INTERRUPT_REASON_NETWORK_##d;
14
15 #define SERVER_ERROR_TO_INTERRUPT_REASON(n, d) \
16 case net::ERR_##n: return DOWNLOAD_INTERRUPT_REASON_SERVER_##d;
17
18 InterruptReason ConvertNetErrorToInterruptReason(
19 net::Error net_error, DownloadInterruptSource source) {
20 switch (net_error) {
21 // File errors.
22 case net::OK: return DOWNLOAD_INTERRUPT_REASON_NONE;
23
24 // The file is too large.
25 FILE_ERROR_TO_INTERRUPT_REASON(FILE_TOO_BIG, TOO_LARGE)
26
27 // Permission to access a resource, other than the network, was denied.
28 FILE_ERROR_TO_INTERRUPT_REASON(ACCESS_DENIED, ACCESS_DENIED)
29
30 // There were not enough resources to complete the operation.
31 FILE_ERROR_TO_INTERRUPT_REASON(INSUFFICIENT_RESOURCES, TRANSIENT_ERROR)
32
33 // Memory allocation failed.
34 FILE_ERROR_TO_INTERRUPT_REASON(OUT_OF_MEMORY, TRANSIENT_ERROR)
35
36 // The path or file name is too long.
37 FILE_ERROR_TO_INTERRUPT_REASON(FILE_PATH_TOO_LONG, NAME_TOO_LONG)
38
39 // Not enough room left on the disk.
40 FILE_ERROR_TO_INTERRUPT_REASON(FILE_NO_SPACE, NO_SPACE)
41
42 // The file has a virus.
43 FILE_ERROR_TO_INTERRUPT_REASON(FILE_VIRUS_INFECTED, VIRUS_INFECTED)
44
45 // Network errors.
46
47 // The network operation timed out.
48 NET_ERROR_TO_INTERRUPT_REASON(TIMED_OUT, TIMEOUT)
49
50 // The network connection has been lost.
51 NET_ERROR_TO_INTERRUPT_REASON(INTERNET_DISCONNECTED, DISCONNECTED)
52
53 // The server has gone down.
54 NET_ERROR_TO_INTERRUPT_REASON(CONNECTION_FAILED, SERVER_DOWN)
55
56 // The server has terminated the connection.
57 // NET_ERROR_TO_INTERRUPT_REASON(CONNECTION_RESET, SERVER_DISCONNECTED)
58
59 // The server has aborted the connection.
60 // NET_ERROR_TO_INTERRUPT_REASON(CONNECTION_ABORTED, SERVER_ABORTED)
61
62 // Server responses.
63
64 // The server does not support range requests.
65 SERVER_ERROR_TO_INTERRUPT_REASON(REQUEST_RANGE_NOT_SATISFIABLE, NO_RANGE)
66
67 default: break;
68 }
69
70 // Handle errors that don't have mappings, depending on the source.
71 switch (source) {
72 case DOWNLOAD_INTERRUPT_FROM_DISK:
73 return DOWNLOAD_INTERRUPT_REASON_FILE_FAILED;
74 case DOWNLOAD_INTERRUPT_FROM_NETWORK:
75 return DOWNLOAD_INTERRUPT_REASON_NETWORK_FAILED;
76 case DOWNLOAD_INTERRUPT_FROM_SERVER:
77 return DOWNLOAD_INTERRUPT_REASON_SERVER_FAILED;
78 default:
79 break;
80 }
81
82 NOTREACHED();
83
84 return DOWNLOAD_INTERRUPT_REASON_NONE;
85 }
86
87 #undef FILE_ERROR_TO_INTERRUPT_REASON
88 #undef NET_ERROR_TO_INTERRUPT_REASON
89 #undef SERVER_ERROR_TO_INTERRUPT_REASON
90
91 std::string InterruptReasonDebugString(InterruptReason error) {
92
93 #define INTERRUPT_REASON(name, value) \
94 case DOWNLOAD_INTERRUPT_REASON_##name: return #name;
95
96 switch (error) {
97 INTERRUPT_REASON(NONE, 0)
98
99 #include "content/browser/download/interrupt_reason_values.h"
100
101 default:
102 break;
103 }
104
105 #undef INTERRUPT_REASON
106
107 return "Unknown error";
108 }
OLDNEW
« no previous file with comments | « content/browser/download/interrupt_reasons.h ('k') | content/content_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698