| 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 syncer::syncable::EntryKernelSet deleted_entries; | 19 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 (syncer::syncable::EntryKernelSet::const_iterator i = | 23 for (syncable::EntryKernelSet::const_iterator i = deleted_entries.begin(); |
| 24 deleted_entries.begin(); | |
| 25 i != deleted_entries.end(); ++i) { | 24 i != deleted_entries.end(); ++i) { |
| 26 delete_journal_list->push_back(BookmarkDeleteJournal()); | 25 delete_journal_list->push_back(BookmarkDeleteJournal()); |
| 27 delete_journal_list->back().id = (*i)->ref(syncer::syncable::META_HANDLE); | 26 delete_journal_list->back().id = (*i)->ref(syncable::META_HANDLE); |
| 28 delete_journal_list->back().external_id = | 27 delete_journal_list->back().external_id = |
| 29 (*i)->ref(syncer::syncable::LOCAL_EXTERNAL_ID); | 28 (*i)->ref(syncable::LOCAL_EXTERNAL_ID); |
| 30 delete_journal_list->back().is_folder = (*i)->ref(syncer::syncable::IS_DIR); | 29 delete_journal_list->back().is_folder = (*i)->ref(syncable::IS_DIR); |
| 31 | 30 |
| 32 const sync_pb::EntitySpecifics& specifics = | 31 const sync_pb::EntitySpecifics& specifics = (*i)->ref(syncable::SPECIFICS); |
| 33 (*i)->ref(syncer::syncable::SPECIFICS); | |
| 34 if (!specifics.has_encrypted()) { | 32 if (!specifics.has_encrypted()) { |
| 35 delete_journal_list->back().specifics = specifics; | 33 delete_journal_list->back().specifics = specifics; |
| 36 } else { | 34 } else { |
| 37 std::string plaintext_data = | 35 std::string plaintext_data = |
| 38 trans->GetCryptographer()->DecryptToString(specifics.encrypted()); | 36 trans->GetCryptographer()->DecryptToString(specifics.encrypted()); |
| 39 sync_pb::EntitySpecifics unencrypted_data; | 37 sync_pb::EntitySpecifics unencrypted_data; |
| 40 if (plaintext_data.length() == 0 || | 38 if (plaintext_data.length() == 0 || |
| 41 !unencrypted_data.ParseFromString(plaintext_data)) { | 39 !unencrypted_data.ParseFromString(plaintext_data)) { |
| 42 // Fail to decrypt, Add this delete journal to purge. | 40 // Fail to decrypt, Add this delete journal to purge. |
| 43 undecryptable_journal.insert(delete_journal_list->back().id); | 41 undecryptable_journal.insert(delete_journal_list->back().id); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 55 } | 53 } |
| 56 | 54 |
| 57 // static | 55 // static |
| 58 void DeleteJournal::PurgeDeleteJournals(BaseTransaction* trans, | 56 void DeleteJournal::PurgeDeleteJournals(BaseTransaction* trans, |
| 59 const std::set<int64_t>& ids) { | 57 const std::set<int64_t>& ids) { |
| 60 trans->GetDirectory()->delete_journal()->PurgeDeleteJournals( | 58 trans->GetDirectory()->delete_journal()->PurgeDeleteJournals( |
| 61 trans->GetWrappedTrans(), ids); | 59 trans->GetWrappedTrans(), ids); |
| 62 } | 60 } |
| 63 | 61 |
| 64 } // namespace syncer | 62 } // namespace syncer |
| OLD | NEW |