OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "chrome/browser/sync_file_system/sync_status_code.h" | 5 #include "chrome/browser/sync_file_system/sync_status_code.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "third_party/leveldatabase/src/include/leveldb/db.h" | 8 #include "third_party/leveldatabase/src/include/leveldb/db.h" |
9 | 9 |
10 namespace sync_file_system { | 10 namespace sync_file_system { |
11 | 11 |
12 const char* SyncStatusCodeToString(SyncStatusCode status) { | 12 const char* SyncStatusCodeToString(SyncStatusCode status) { |
13 switch (status) { | 13 switch (status) { |
14 case SYNC_STATUS_OK: | 14 case SYNC_STATUS_OK: |
15 return "OK."; | 15 return "OK."; |
16 case SYNC_STATUS_UNKNOWN: | 16 case SYNC_STATUS_UNKNOWN: |
17 return "Unknown sync status."; | 17 return "Unknown sync status."; |
18 case SYNC_STATUS_FAILED: | 18 case SYNC_STATUS_FAILED: |
19 return "Failed."; | 19 return "Failed."; |
20 | 20 |
21 // PlatformFile related errors. | 21 // PlatformFile related errors. |
22 // TODO(nhiroki): add stringize function for PlatformFileError into base/. | 22 // TODO(nhiroki): add stringize function for File::Error into base/. |
23 case SYNC_FILE_ERROR_FAILED: | 23 case SYNC_FILE_ERROR_FAILED: |
24 return "File operation failed."; | 24 return "File operation failed."; |
25 case SYNC_FILE_ERROR_IN_USE: | 25 case SYNC_FILE_ERROR_IN_USE: |
26 return "File currently in use."; | 26 return "File currently in use."; |
27 case SYNC_FILE_ERROR_EXISTS: | 27 case SYNC_FILE_ERROR_EXISTS: |
28 return "File already exists."; | 28 return "File already exists."; |
29 case SYNC_FILE_ERROR_NOT_FOUND: | 29 case SYNC_FILE_ERROR_NOT_FOUND: |
30 return "File not found."; | 30 return "File not found."; |
31 case SYNC_FILE_ERROR_ACCESS_DENIED: | 31 case SYNC_FILE_ERROR_ACCESS_DENIED: |
32 return "File access denied."; | 32 return "File access denied."; |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 else if (status.IsNotFound()) | 101 else if (status.IsNotFound()) |
102 return SYNC_DATABASE_ERROR_NOT_FOUND; | 102 return SYNC_DATABASE_ERROR_NOT_FOUND; |
103 else if (status.IsCorruption()) | 103 else if (status.IsCorruption()) |
104 return SYNC_DATABASE_ERROR_CORRUPTION; | 104 return SYNC_DATABASE_ERROR_CORRUPTION; |
105 else if (status.IsIOError()) | 105 else if (status.IsIOError()) |
106 return SYNC_DATABASE_ERROR_IO_ERROR; | 106 return SYNC_DATABASE_ERROR_IO_ERROR; |
107 else | 107 else |
108 return SYNC_DATABASE_ERROR_FAILED; | 108 return SYNC_DATABASE_ERROR_FAILED; |
109 } | 109 } |
110 | 110 |
111 SyncStatusCode PlatformFileErrorToSyncStatusCode( | 111 SyncStatusCode FileErrorToSyncStatusCode( |
112 base::PlatformFileError file_error) { | 112 base::File::Error file_error) { |
113 switch (file_error) { | 113 switch (file_error) { |
114 case base::PLATFORM_FILE_OK: | 114 case base::File::FILE_OK: |
115 return SYNC_STATUS_OK; | 115 return SYNC_STATUS_OK; |
116 case base::PLATFORM_FILE_ERROR_FAILED: | 116 case base::File::FILE_ERROR_FAILED: |
117 return SYNC_FILE_ERROR_FAILED; | 117 return SYNC_FILE_ERROR_FAILED; |
118 case base::PLATFORM_FILE_ERROR_IN_USE: | 118 case base::File::FILE_ERROR_IN_USE: |
119 return SYNC_FILE_ERROR_IN_USE; | 119 return SYNC_FILE_ERROR_IN_USE; |
120 case base::PLATFORM_FILE_ERROR_EXISTS: | 120 case base::File::FILE_ERROR_EXISTS: |
121 return SYNC_FILE_ERROR_EXISTS; | 121 return SYNC_FILE_ERROR_EXISTS; |
122 case base::PLATFORM_FILE_ERROR_NOT_FOUND: | 122 case base::File::FILE_ERROR_NOT_FOUND: |
123 return SYNC_FILE_ERROR_NOT_FOUND; | 123 return SYNC_FILE_ERROR_NOT_FOUND; |
124 case base::PLATFORM_FILE_ERROR_ACCESS_DENIED: | 124 case base::File::FILE_ERROR_ACCESS_DENIED: |
125 return SYNC_FILE_ERROR_ACCESS_DENIED; | 125 return SYNC_FILE_ERROR_ACCESS_DENIED; |
126 case base::PLATFORM_FILE_ERROR_TOO_MANY_OPENED: | 126 case base::File::FILE_ERROR_TOO_MANY_OPENED: |
127 return SYNC_FILE_ERROR_TOO_MANY_OPENED; | 127 return SYNC_FILE_ERROR_TOO_MANY_OPENED; |
128 case base::PLATFORM_FILE_ERROR_NO_MEMORY: | 128 case base::File::FILE_ERROR_NO_MEMORY: |
129 return SYNC_FILE_ERROR_NO_MEMORY; | 129 return SYNC_FILE_ERROR_NO_MEMORY; |
130 case base::PLATFORM_FILE_ERROR_NO_SPACE: | 130 case base::File::FILE_ERROR_NO_SPACE: |
131 return SYNC_FILE_ERROR_NO_SPACE; | 131 return SYNC_FILE_ERROR_NO_SPACE; |
132 case base::PLATFORM_FILE_ERROR_NOT_A_DIRECTORY: | 132 case base::File::FILE_ERROR_NOT_A_DIRECTORY: |
133 return SYNC_FILE_ERROR_NOT_A_DIRECTORY; | 133 return SYNC_FILE_ERROR_NOT_A_DIRECTORY; |
134 case base::PLATFORM_FILE_ERROR_INVALID_OPERATION: | 134 case base::File::FILE_ERROR_INVALID_OPERATION: |
135 return SYNC_FILE_ERROR_INVALID_OPERATION; | 135 return SYNC_FILE_ERROR_INVALID_OPERATION; |
136 case base::PLATFORM_FILE_ERROR_SECURITY: | 136 case base::File::FILE_ERROR_SECURITY: |
137 return SYNC_FILE_ERROR_SECURITY; | 137 return SYNC_FILE_ERROR_SECURITY; |
138 case base::PLATFORM_FILE_ERROR_ABORT: | 138 case base::File::FILE_ERROR_ABORT: |
139 return SYNC_FILE_ERROR_ABORT; | 139 return SYNC_FILE_ERROR_ABORT; |
140 case base::PLATFORM_FILE_ERROR_NOT_A_FILE: | 140 case base::File::FILE_ERROR_NOT_A_FILE: |
141 return SYNC_FILE_ERROR_NOT_A_FILE; | 141 return SYNC_FILE_ERROR_NOT_A_FILE; |
142 case base::PLATFORM_FILE_ERROR_NOT_EMPTY: | 142 case base::File::FILE_ERROR_NOT_EMPTY: |
143 return SYNC_FILE_ERROR_NOT_EMPTY; | 143 return SYNC_FILE_ERROR_NOT_EMPTY; |
144 case base::PLATFORM_FILE_ERROR_INVALID_URL: | 144 case base::File::FILE_ERROR_INVALID_URL: |
145 return SYNC_FILE_ERROR_INVALID_URL; | 145 return SYNC_FILE_ERROR_INVALID_URL; |
146 case base::PLATFORM_FILE_ERROR_IO: | 146 case base::File::FILE_ERROR_IO: |
147 return SYNC_FILE_ERROR_IO; | 147 return SYNC_FILE_ERROR_IO; |
148 case base::PLATFORM_FILE_ERROR_MAX: | 148 case base::File::FILE_ERROR_MAX: |
149 NOTREACHED(); | 149 NOTREACHED(); |
150 return SYNC_FILE_ERROR_FAILED; | 150 return SYNC_FILE_ERROR_FAILED; |
151 } | 151 } |
152 // Return the value as is, so the value converted by | 152 // Return the value as is, so the value converted by |
153 // SyncStatusCodeToPlatformFileError could be restored. | 153 // SyncStatusCodeToFileError could be restored. |
154 return static_cast<SyncStatusCode>(file_error); | 154 return static_cast<SyncStatusCode>(file_error); |
155 } | 155 } |
156 | 156 |
157 base::PlatformFileError SyncStatusCodeToPlatformFileError( | 157 base::File::Error SyncStatusCodeToFileError( |
158 SyncStatusCode status) { | 158 SyncStatusCode status) { |
159 switch (status) { | 159 switch (status) { |
160 case SYNC_STATUS_OK: | 160 case SYNC_STATUS_OK: |
161 return base::PLATFORM_FILE_OK; | 161 return base::File::FILE_OK; |
162 case SYNC_FILE_ERROR_FAILED: | 162 case SYNC_FILE_ERROR_FAILED: |
163 return base::PLATFORM_FILE_ERROR_FAILED; | 163 return base::File::FILE_ERROR_FAILED; |
164 case SYNC_FILE_ERROR_IN_USE: | 164 case SYNC_FILE_ERROR_IN_USE: |
165 return base::PLATFORM_FILE_ERROR_IN_USE; | 165 return base::File::FILE_ERROR_IN_USE; |
166 case SYNC_FILE_ERROR_EXISTS: | 166 case SYNC_FILE_ERROR_EXISTS: |
167 return base::PLATFORM_FILE_ERROR_EXISTS; | 167 return base::File::FILE_ERROR_EXISTS; |
168 case SYNC_FILE_ERROR_NOT_FOUND: | 168 case SYNC_FILE_ERROR_NOT_FOUND: |
169 return base::PLATFORM_FILE_ERROR_NOT_FOUND; | 169 return base::File::FILE_ERROR_NOT_FOUND; |
170 case SYNC_FILE_ERROR_ACCESS_DENIED: | 170 case SYNC_FILE_ERROR_ACCESS_DENIED: |
171 return base::PLATFORM_FILE_ERROR_ACCESS_DENIED; | 171 return base::File::FILE_ERROR_ACCESS_DENIED; |
172 case SYNC_FILE_ERROR_TOO_MANY_OPENED: | 172 case SYNC_FILE_ERROR_TOO_MANY_OPENED: |
173 return base::PLATFORM_FILE_ERROR_TOO_MANY_OPENED; | 173 return base::File::FILE_ERROR_TOO_MANY_OPENED; |
174 case SYNC_FILE_ERROR_NO_MEMORY: | 174 case SYNC_FILE_ERROR_NO_MEMORY: |
175 return base::PLATFORM_FILE_ERROR_NO_MEMORY; | 175 return base::File::FILE_ERROR_NO_MEMORY; |
176 case SYNC_FILE_ERROR_NO_SPACE: | 176 case SYNC_FILE_ERROR_NO_SPACE: |
177 return base::PLATFORM_FILE_ERROR_NO_SPACE; | 177 return base::File::FILE_ERROR_NO_SPACE; |
178 case SYNC_FILE_ERROR_NOT_A_DIRECTORY: | 178 case SYNC_FILE_ERROR_NOT_A_DIRECTORY: |
179 return base::PLATFORM_FILE_ERROR_NOT_A_DIRECTORY; | 179 return base::File::FILE_ERROR_NOT_A_DIRECTORY; |
180 case SYNC_FILE_ERROR_INVALID_OPERATION: | 180 case SYNC_FILE_ERROR_INVALID_OPERATION: |
181 return base::PLATFORM_FILE_ERROR_INVALID_OPERATION; | 181 return base::File::FILE_ERROR_INVALID_OPERATION; |
182 case SYNC_FILE_ERROR_SECURITY: | 182 case SYNC_FILE_ERROR_SECURITY: |
183 return base::PLATFORM_FILE_ERROR_SECURITY; | 183 return base::File::FILE_ERROR_SECURITY; |
184 case SYNC_FILE_ERROR_ABORT: | 184 case SYNC_FILE_ERROR_ABORT: |
185 return base::PLATFORM_FILE_ERROR_ABORT; | 185 return base::File::FILE_ERROR_ABORT; |
186 case SYNC_FILE_ERROR_NOT_A_FILE: | 186 case SYNC_FILE_ERROR_NOT_A_FILE: |
187 return base::PLATFORM_FILE_ERROR_NOT_A_FILE; | 187 return base::File::FILE_ERROR_NOT_A_FILE; |
188 case SYNC_FILE_ERROR_NOT_EMPTY: | 188 case SYNC_FILE_ERROR_NOT_EMPTY: |
189 return base::PLATFORM_FILE_ERROR_NOT_EMPTY; | 189 return base::File::FILE_ERROR_NOT_EMPTY; |
190 case SYNC_FILE_ERROR_INVALID_URL: | 190 case SYNC_FILE_ERROR_INVALID_URL: |
191 return base::PLATFORM_FILE_ERROR_INVALID_URL; | 191 return base::File::FILE_ERROR_INVALID_URL; |
192 case SYNC_FILE_ERROR_IO: | 192 case SYNC_FILE_ERROR_IO: |
193 return base::PLATFORM_FILE_ERROR_IO; | 193 return base::File::FILE_ERROR_IO; |
194 default: | 194 default: |
195 // Return the value as is, so that caller may be able to | 195 // Return the value as is, so that caller may be able to |
196 // restore the information. | 196 // restore the information. |
197 return static_cast<base::PlatformFileError>(status); | 197 return static_cast<base::File::Error>(status); |
198 } | 198 } |
199 } | 199 } |
200 | 200 |
201 } // namespace sync_file_system | 201 } // namespace sync_file_system |
OLD | NEW |