OLD | NEW |
---|---|
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 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 "components/offline_pages/offline_page_metadata_store_impl.h" | 5 #include "components/offline_pages/offline_page_metadata_store_impl.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <utility> | 8 #include <utility> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
161 // We don't want to fail the entire database if one item is corrupt, | 161 // We don't want to fail the entire database if one item is corrupt, |
162 // so log error and keep going. | 162 // so log error and keep going. |
163 if (!OfflinePageItemFromEntry(entry, &item)) { | 163 if (!OfflinePageItemFromEntry(entry, &item)) { |
164 LOG(ERROR) << "failed to parse entry: " << entry.url() << " skipping."; | 164 LOG(ERROR) << "failed to parse entry: " << entry.url() << " skipping."; |
165 continue; | 165 continue; |
166 } | 166 } |
167 // Legacy storage. We upgrade them to the new offline_id keyed storage. | 167 // Legacy storage. We upgrade them to the new offline_id keyed storage. |
168 // TODO(bburns): Remove this eventually when we are sure everyone is | 168 // TODO(bburns): Remove this eventually when we are sure everyone is |
169 // upgraded. | 169 // upgraded. |
170 if (!entry.has_offline_id()) { | 170 if (!entry.has_offline_id()) { |
171 entry.set_offline_id(OfflinePageModel::GenerateOfflineId()); | 171 item.offline_id = OfflinePageModel::GenerateOfflineId(); |
172 item.offline_id = entry.offline_id(); | |
173 | 172 |
174 if (!entry.has_deprecated_bookmark_id()) { | 173 if (!entry.has_deprecated_bookmark_id()) { |
175 LOG(ERROR) << "unexpected entry missing bookmark id"; | 174 LOG(ERROR) << "unexpected entry missing bookmark id"; |
176 continue; | 175 continue; |
177 } | 176 } |
178 item.client_id.name_space = offline_pages::BOOKMARK_NAMESPACE; | 177 item.client_id.name_space = offline_pages::BOOKMARK_NAMESPACE; |
179 item.client_id.id = base::Int64ToString(entry.deprecated_bookmark_id()); | 178 item.client_id.id = base::Int64ToString(entry.deprecated_bookmark_id()); |
180 | 179 |
180 OfflinePageEntry upgraded_entry; | |
181 OfflinePageItemToEntry(item, &upgraded_entry); | |
181 entries_to_update->push_back( | 182 entries_to_update->push_back( |
182 std::make_pair(base::Int64ToString(entry.offline_id()), entry)); | 183 std::make_pair(base::Int64ToString(upgraded_entry.offline_id()), |
184 upgraded_entry)); | |
183 keys_to_remove->push_back(item.client_id.id); | 185 keys_to_remove->push_back(item.client_id.id); |
fgorski
2016/04/08 05:09:58
nit: Add a comment that his is removing the old en
| |
184 } | 186 } |
185 result.push_back(item); | 187 result.push_back(item); |
186 } | 188 } |
187 } else { | 189 } else { |
188 status = STORE_LOAD_FAILED; | 190 status = STORE_LOAD_FAILED; |
189 } | 191 } |
190 | 192 |
191 // If we couldn't load _anything_ report a parse failure. | 193 // If we couldn't load _anything_ report a parse failure. |
192 if (entries->size() > 0 && result.size() == 0) { | 194 if (entries->size() > 0 && result.size() == 0) { |
193 status = DATA_PARSING_FAILED; | 195 status = DATA_PARSING_FAILED; |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
306 bool success) { | 308 bool success) { |
307 // If the update failed, log and keep going. We'll try to | 309 // If the update failed, log and keep going. We'll try to |
308 // update next time. | 310 // update next time. |
309 if (!success) { | 311 if (!success) { |
310 LOG(ERROR) << "Failed to update database"; | 312 LOG(ERROR) << "Failed to update database"; |
311 } | 313 } |
312 NotifyLoadResult(cb, status, result); | 314 NotifyLoadResult(cb, status, result); |
313 } | 315 } |
314 | 316 |
315 } // namespace offline_pages | 317 } // namespace offline_pages |
OLD | NEW |