| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/sync/core/delete_journal.h" | 5 #include "components/sync/core/delete_journal.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "components/sync/core/base_transaction.h" | 9 #include "components/sync/core/base_transaction.h" |
| 10 #include "components/sync/syncable/directory.h" | 10 #include "components/sync/syncable/directory.h" |
| 11 #include "components/sync/syncable/syncable_base_transaction.h" | 11 #include "components/sync/syncable/syncable_base_transaction.h" |
| 12 | 12 |
| 13 namespace syncer { | 13 namespace syncer { |
| 14 | 14 |
| 15 // static | 15 // static |
| 16 void DeleteJournal::GetBookmarkDeleteJournals( | 16 void DeleteJournal::GetBookmarkDeleteJournals( |
| 17 BaseTransaction* trans, | 17 BaseTransaction* trans, |
| 18 BookmarkDeleteJournalList* delete_journal_list) { | 18 BookmarkDeleteJournalList* delete_journal_list) { |
| 19 syncable::EntryKernelSet deleted_entries; | 19 syncer::syncable::EntryKernelSet deleted_entries; |
| 20 trans->GetDirectory()->delete_journal()->GetDeleteJournals( | 20 trans->GetDirectory()->delete_journal()->GetDeleteJournals( |
| 21 trans->GetWrappedTrans(), BOOKMARKS, &deleted_entries); | 21 trans->GetWrappedTrans(), BOOKMARKS, &deleted_entries); |
| 22 std::set<int64_t> undecryptable_journal; | 22 std::set<int64_t> undecryptable_journal; |
| 23 for (syncable::EntryKernelSet::const_iterator i = deleted_entries.begin(); | 23 for (syncer::syncable::EntryKernelSet::const_iterator i = |
| 24 deleted_entries.begin(); |
| 24 i != deleted_entries.end(); ++i) { | 25 i != deleted_entries.end(); ++i) { |
| 25 delete_journal_list->push_back(BookmarkDeleteJournal()); | 26 delete_journal_list->push_back(BookmarkDeleteJournal()); |
| 26 delete_journal_list->back().id = (*i)->ref(syncable::META_HANDLE); | 27 delete_journal_list->back().id = (*i)->ref(syncer::syncable::META_HANDLE); |
| 27 delete_journal_list->back().external_id = | 28 delete_journal_list->back().external_id = |
| 28 (*i)->ref(syncable::LOCAL_EXTERNAL_ID); | 29 (*i)->ref(syncer::syncable::LOCAL_EXTERNAL_ID); |
| 29 delete_journal_list->back().is_folder = (*i)->ref(syncable::IS_DIR); | 30 delete_journal_list->back().is_folder = (*i)->ref(syncer::syncable::IS_DIR); |
| 30 | 31 |
| 31 const sync_pb::EntitySpecifics& specifics = (*i)->ref(syncable::SPECIFICS); | 32 const sync_pb::EntitySpecifics& specifics = |
| 33 (*i)->ref(syncer::syncable::SPECIFICS); |
| 32 if (!specifics.has_encrypted()) { | 34 if (!specifics.has_encrypted()) { |
| 33 delete_journal_list->back().specifics = specifics; | 35 delete_journal_list->back().specifics = specifics; |
| 34 } else { | 36 } else { |
| 35 std::string plaintext_data = | 37 std::string plaintext_data = |
| 36 trans->GetCryptographer()->DecryptToString(specifics.encrypted()); | 38 trans->GetCryptographer()->DecryptToString(specifics.encrypted()); |
| 37 sync_pb::EntitySpecifics unencrypted_data; | 39 sync_pb::EntitySpecifics unencrypted_data; |
| 38 if (plaintext_data.length() == 0 || | 40 if (plaintext_data.length() == 0 || |
| 39 !unencrypted_data.ParseFromString(plaintext_data)) { | 41 !unencrypted_data.ParseFromString(plaintext_data)) { |
| 40 // Fail to decrypt, Add this delete journal to purge. | 42 // Fail to decrypt, Add this delete journal to purge. |
| 41 undecryptable_journal.insert(delete_journal_list->back().id); | 43 undecryptable_journal.insert(delete_journal_list->back().id); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 53 } | 55 } |
| 54 | 56 |
| 55 // static | 57 // static |
| 56 void DeleteJournal::PurgeDeleteJournals(BaseTransaction* trans, | 58 void DeleteJournal::PurgeDeleteJournals(BaseTransaction* trans, |
| 57 const std::set<int64_t>& ids) { | 59 const std::set<int64_t>& ids) { |
| 58 trans->GetDirectory()->delete_journal()->PurgeDeleteJournals( | 60 trans->GetDirectory()->delete_journal()->PurgeDeleteJournals( |
| 59 trans->GetWrappedTrans(), ids); | 61 trans->GetWrappedTrans(), ids); |
| 60 } | 62 } |
| 61 | 63 |
| 62 } // namespace syncer | 64 } // namespace syncer |
| OLD | NEW |