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 <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 OfflinePageEntry offline_page_proto; | 185 OfflinePageEntry offline_page_proto; |
186 OfflinePageItemToEntry(offline_page_item, &offline_page_proto); | 186 OfflinePageItemToEntry(offline_page_item, &offline_page_proto); |
187 entries_to_save->push_back( | 187 entries_to_save->push_back( |
188 std::make_pair(base::Int64ToString(offline_page_item.bookmark_id), | 188 std::make_pair(base::Int64ToString(offline_page_item.bookmark_id), |
189 offline_page_proto)); | 189 offline_page_proto)); |
190 | 190 |
191 UpdateEntries(entries_to_save.Pass(), keys_to_remove.Pass(), callback); | 191 UpdateEntries(entries_to_save.Pass(), keys_to_remove.Pass(), callback); |
192 } | 192 } |
193 | 193 |
194 void OfflinePageMetadataStoreImpl::RemoveOfflinePages( | 194 void OfflinePageMetadataStoreImpl::RemoveOfflinePages( |
195 const std::vector<int64>& bookmark_ids, | 195 const std::vector<int64_t>& bookmark_ids, |
196 const UpdateCallback& callback) { | 196 const UpdateCallback& callback) { |
197 scoped_ptr<ProtoDatabase<OfflinePageEntry>::KeyEntryVector> entries_to_save( | 197 scoped_ptr<ProtoDatabase<OfflinePageEntry>::KeyEntryVector> entries_to_save( |
198 new ProtoDatabase<OfflinePageEntry>::KeyEntryVector()); | 198 new ProtoDatabase<OfflinePageEntry>::KeyEntryVector()); |
199 scoped_ptr<std::vector<std::string>> keys_to_remove( | 199 scoped_ptr<std::vector<std::string>> keys_to_remove( |
200 new std::vector<std::string>()); | 200 new std::vector<std::string>()); |
201 | 201 |
202 for (int64 id : bookmark_ids) | 202 for (int64_t id : bookmark_ids) |
203 keys_to_remove->push_back(base::Int64ToString(id)); | 203 keys_to_remove->push_back(base::Int64ToString(id)); |
204 | 204 |
205 UpdateEntries(entries_to_save.Pass(), keys_to_remove.Pass(), callback); | 205 UpdateEntries(entries_to_save.Pass(), keys_to_remove.Pass(), callback); |
206 } | 206 } |
207 | 207 |
208 void OfflinePageMetadataStoreImpl::UpdateEntries( | 208 void OfflinePageMetadataStoreImpl::UpdateEntries( |
209 scoped_ptr<ProtoDatabase<OfflinePageEntry>::KeyEntryVector> entries_to_save, | 209 scoped_ptr<ProtoDatabase<OfflinePageEntry>::KeyEntryVector> entries_to_save, |
210 scoped_ptr<std::vector<std::string>> keys_to_remove, | 210 scoped_ptr<std::vector<std::string>> keys_to_remove, |
211 const UpdateCallback& callback) { | 211 const UpdateCallback& callback) { |
212 if (!database_.get()) { | 212 if (!database_.get()) { |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
247 | 247 |
248 void OfflinePageMetadataStoreImpl::ResetDone( | 248 void OfflinePageMetadataStoreImpl::ResetDone( |
249 const ResetCallback& callback, | 249 const ResetCallback& callback, |
250 bool success) { | 250 bool success) { |
251 database_.reset(); | 251 database_.reset(); |
252 weak_ptr_factory_.InvalidateWeakPtrs(); | 252 weak_ptr_factory_.InvalidateWeakPtrs(); |
253 callback.Run(success); | 253 callback.Run(success); |
254 } | 254 } |
255 | 255 |
256 } // namespace offline_pages | 256 } // namespace offline_pages |
OLD | NEW |