OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2015 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 "components/history/content/browser/download_constants_utils.h" | |
6 | |
7 #include "base/logging.h" | |
8 #include "components/history/core/browser/download_constants.h" | |
9 | |
10 namespace history { | |
11 | |
12 content::DownloadItem::DownloadState ToContentDownloadState( | |
13 DownloadState state) { | |
14 switch (state) { | |
15 case DownloadState::IN_PROGRESS: | |
16 return content::DownloadItem::IN_PROGRESS; | |
17 case DownloadState::COMPLETE: | |
18 return content::DownloadItem::COMPLETE; | |
19 case DownloadState::CANCELLED: | |
20 return content::DownloadItem::CANCELLED; | |
21 case DownloadState::INTERRUPTED: | |
22 return content::DownloadItem::INTERRUPTED; | |
23 case DownloadState::INVALID: | |
24 case DownloadState::BUG_140687: | |
25 NOTREACHED(); | |
26 return content::DownloadItem::MAX_DOWNLOAD_STATE; | |
27 } | |
28 NOTREACHED(); | |
droger
2015/01/06 10:22:18
Optional: remove this, as all the cases are handle
sdefresne
2015/01/06 10:51:17
I cannot remove this as otherwise I get compilatio
| |
29 return content::DownloadItem::MAX_DOWNLOAD_STATE; | |
30 } | |
31 | |
32 DownloadState ToHistoryDownloadState( | |
33 content::DownloadItem::DownloadState state) { | |
34 switch (state) { | |
35 case content::DownloadItem::IN_PROGRESS: | |
36 return DownloadState::IN_PROGRESS; | |
37 case content::DownloadItem::COMPLETE: | |
38 return DownloadState::COMPLETE; | |
39 case content::DownloadItem::CANCELLED: | |
40 return DownloadState::CANCELLED; | |
41 case content::DownloadItem::INTERRUPTED: | |
42 return DownloadState::INTERRUPTED; | |
43 case content::DownloadItem::MAX_DOWNLOAD_STATE: | |
44 NOTREACHED(); | |
45 return DownloadState::INVALID; | |
46 } | |
47 NOTREACHED(); | |
48 return DownloadState::INVALID; | |
49 } | |
50 | |
51 content::DownloadDangerType ToContentDownloadDangerType( | |
52 DownloadDangerType danger_type) { | |
53 switch (danger_type) { | |
54 case DownloadDangerType::NOT_DANGEROUS: | |
55 return content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS; | |
56 case DownloadDangerType::DANGEROUS_FILE: | |
57 return content::DOWNLOAD_DANGER_TYPE_DANGEROUS_FILE; | |
58 case DownloadDangerType::DANGEROUS_URL: | |
59 return content::DOWNLOAD_DANGER_TYPE_DANGEROUS_URL; | |
60 case DownloadDangerType::DANGEROUS_CONTENT: | |
61 return content::DOWNLOAD_DANGER_TYPE_DANGEROUS_CONTENT; | |
62 case DownloadDangerType::MAYBE_DANGEROUS_CONTENT: | |
63 return content::DOWNLOAD_DANGER_TYPE_MAYBE_DANGEROUS_CONTENT; | |
64 case DownloadDangerType::UNCOMMON_CONTENT: | |
65 return content::DOWNLOAD_DANGER_TYPE_UNCOMMON_CONTENT; | |
66 case DownloadDangerType::USER_VALIDATED: | |
67 return content::DOWNLOAD_DANGER_TYPE_USER_VALIDATED; | |
68 case DownloadDangerType::DANGEROUS_HOST: | |
69 return content::DOWNLOAD_DANGER_TYPE_DANGEROUS_HOST; | |
70 case DownloadDangerType::POTENTIALLY_UNWANTED: | |
71 return content::DOWNLOAD_DANGER_TYPE_POTENTIALLY_UNWANTED; | |
72 case DownloadDangerType::INVALID: | |
73 NOTREACHED(); | |
74 return content::DOWNLOAD_DANGER_TYPE_MAX; | |
75 } | |
76 NOTREACHED(); | |
77 return content::DOWNLOAD_DANGER_TYPE_MAX; | |
78 } | |
79 | |
80 DownloadDangerType ToHistoryDownloadDangerType( | |
81 content::DownloadDangerType danger_type) { | |
82 switch (danger_type) { | |
83 case content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS: | |
84 return DownloadDangerType::NOT_DANGEROUS; | |
85 case content::DOWNLOAD_DANGER_TYPE_DANGEROUS_FILE: | |
86 return DownloadDangerType::DANGEROUS_FILE; | |
87 case content::DOWNLOAD_DANGER_TYPE_DANGEROUS_URL: | |
88 return DownloadDangerType::DANGEROUS_URL; | |
89 case content::DOWNLOAD_DANGER_TYPE_DANGEROUS_CONTENT: | |
90 return DownloadDangerType::DANGEROUS_CONTENT; | |
91 case content::DOWNLOAD_DANGER_TYPE_MAYBE_DANGEROUS_CONTENT: | |
92 return DownloadDangerType::MAYBE_DANGEROUS_CONTENT; | |
93 case content::DOWNLOAD_DANGER_TYPE_UNCOMMON_CONTENT: | |
94 return DownloadDangerType::UNCOMMON_CONTENT; | |
95 case content::DOWNLOAD_DANGER_TYPE_USER_VALIDATED: | |
96 return DownloadDangerType::USER_VALIDATED; | |
97 case content::DOWNLOAD_DANGER_TYPE_DANGEROUS_HOST: | |
98 return DownloadDangerType::DANGEROUS_HOST; | |
99 case content::DOWNLOAD_DANGER_TYPE_POTENTIALLY_UNWANTED: | |
100 return DownloadDangerType::POTENTIALLY_UNWANTED; | |
101 default: | |
102 NOTREACHED(); | |
103 return DownloadDangerType::INVALID; | |
104 } | |
105 NOTREACHED(); | |
106 return DownloadDangerType::INVALID; | |
107 } | |
108 | |
109 content::DownloadInterruptReason ToContentDownloadInterruptReason( | |
110 DownloadInterruptReason interrupt_reason) { | |
111 return static_cast<content::DownloadInterruptReason>(interrupt_reason); | |
112 } | |
113 | |
114 DownloadInterruptReason ToHistoryDownloadInterruptReason( | |
115 content::DownloadInterruptReason interrupt_reason) { | |
116 return static_cast<DownloadInterruptReason>(interrupt_reason); | |
117 } | |
118 | |
119 uint32 ToContentDownloadId(DownloadId id) { | |
120 DCHECK_NE(id, kInvalidDownloadId); | |
121 return static_cast<uint32>(id); | |
122 } | |
123 | |
124 DownloadId ToHistoryDownloadId(uint32 id) { | |
125 DCHECK_NE(id, content::DownloadItem::kInvalidId); | |
126 return static_cast<DownloadId>(id); | |
127 } | |
128 | |
129 } // namespace history | |
OLD | NEW |