Chromium Code Reviews| Index: components/offline_pages/offline_page_metadata_store_impl.cc |
| diff --git a/components/offline_pages/offline_page_metadata_store_impl.cc b/components/offline_pages/offline_page_metadata_store_impl.cc |
| index 52620639a023ea8e0b9a0370e1d79ec91727804f..5a1f4f93ee3ff6789d83b04855f430950e404035 100644 |
| --- a/components/offline_pages/offline_page_metadata_store_impl.cc |
| +++ b/components/offline_pages/offline_page_metadata_store_impl.cc |
| @@ -41,7 +41,9 @@ void OfflinePageItemToEntry(const OfflinePageItem& item, |
| offline_pages::OfflinePageEntry* item_proto) { |
| DCHECK(item_proto); |
| item_proto->set_url(item.url.spec()); |
| - item_proto->set_bookmark_id(item.bookmark_id); |
| + // TODO(bburns): switch this to offline id when we stop passing bookmark |
| + // id down. |
| + item_proto->set_deprecated_bookmark_id(item.offline_id); |
| item_proto->set_version(item.version); |
| std::string path_string; |
| #if defined(OS_POSIX) |
| @@ -56,17 +58,19 @@ void OfflinePageItemToEntry(const OfflinePageItem& item, |
| item_proto->set_access_count(item.access_count); |
| item_proto->set_flags( |
| static_cast<::offline_pages::OfflinePageEntry_Flags>(item.flags)); |
| + item_proto->set_client_id_name_space(item.client_id_name_space); |
| + item_proto->set_client_id(item.client_id); |
| } |
| bool OfflinePageItemFromEntry(const offline_pages::OfflinePageEntry& item_proto, |
| OfflinePageItem* item) { |
| DCHECK(item); |
| - if (!item_proto.has_url() || !item_proto.has_bookmark_id() || |
| + if (!item_proto.has_url() || !item_proto.has_offline_id() || |
| !item_proto.has_version() || !item_proto.has_file_path()) { |
| return false; |
| } |
| item->url = GURL(item_proto.url()); |
| - item->bookmark_id = item_proto.bookmark_id(); |
| + item->offline_id = item_proto.offline_id(); |
| item->version = item_proto.version(); |
| #if defined(OS_POSIX) |
| item->file_path = base::FilePath(item_proto.file_path()); |
| @@ -90,6 +94,18 @@ bool OfflinePageItemFromEntry(const offline_pages::OfflinePageEntry& item_proto, |
| if (item_proto.has_flags()) { |
| item->flags = static_cast<OfflinePageItem::Flags>(item_proto.flags()); |
| } |
| + item->client_id_name_space = item_proto.client_id_name_space(); |
| + item->client_id = item_proto.client_id(); |
| + |
| + // Legacy storage. |
| + if (item->client_id_name_space == "" |
| + && item_proto.deprecated_bookmark_id() != 0) { |
|
fgorski
2016/02/23 17:15:30
we need to check for has_deprecated_bookmark_id, a
bburns
2016/02/23 19:25:38
Done.
|
| + item->client_id_name_space = "bookmark"; |
|
fgorski
2016/02/23 17:15:30
refer to const for bookmarks namespace
bburns
2016/02/23 19:25:38
Done.
|
| + item->client_id = base::Int64ToString(item_proto.deprecated_bookmark_id()); |
| + if (item->offline_id == 0) { |
| + item->offline_id = item_proto.deprecated_bookmark_id(); |
| + } |
| + } |
| return true; |
| } |
| @@ -187,7 +203,7 @@ void OfflinePageMetadataStoreImpl::AddOrUpdateOfflinePage( |
| OfflinePageEntry offline_page_proto; |
| OfflinePageItemToEntry(offline_page_item, &offline_page_proto); |
| entries_to_save->push_back( |
| - std::make_pair(base::Int64ToString(offline_page_item.bookmark_id), |
| + std::make_pair(base::Int64ToString(offline_page_item.offline_id), |
| offline_page_proto)); |
| UpdateEntries(std::move(entries_to_save), std::move(keys_to_remove), |
| @@ -195,14 +211,14 @@ void OfflinePageMetadataStoreImpl::AddOrUpdateOfflinePage( |
| } |
| void OfflinePageMetadataStoreImpl::RemoveOfflinePages( |
| - const std::vector<int64_t>& bookmark_ids, |
| + const std::vector<int64_t>& offline_ids, |
| const UpdateCallback& callback) { |
| scoped_ptr<ProtoDatabase<OfflinePageEntry>::KeyEntryVector> entries_to_save( |
| new ProtoDatabase<OfflinePageEntry>::KeyEntryVector()); |
| scoped_ptr<std::vector<std::string>> keys_to_remove( |
| new std::vector<std::string>()); |
| - for (int64_t id : bookmark_ids) |
| + for (int64_t id : offline_ids) |
| keys_to_remove->push_back(base::Int64ToString(id)); |
| UpdateEntries(std::move(entries_to_save), std::move(keys_to_remove), |