Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(498)

Unified Diff: sync/internal_api/base_transaction.cc

Issue 11533008: Use delete journal to remove bookmarks that are already deleted in sync model (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: sync/internal_api/base_transaction.cc
diff --git a/sync/internal_api/base_transaction.cc b/sync/internal_api/base_transaction.cc
index cbfb246ed6ad6eb38a7f721f2877eab3833a71a7..9a3621b915fa5c062a6228e43bccc02f283349ec 100644
--- a/sync/internal_api/base_transaction.cc
+++ b/sync/internal_api/base_transaction.cc
@@ -5,6 +5,7 @@
#include "sync/internal_api/public/base_transaction.h"
#include "sync/syncable/directory.h"
+#include "sync/syncable/entry_kernel.h"
#include "sync/syncable/nigori_handler.h"
#include "sync/util/cryptographer.h"
@@ -29,4 +30,45 @@ ModelTypeSet BaseTransaction::GetEncryptedTypes() const {
this->GetWrappedTrans());
}
+void BaseTransaction::GetDeletedSyncData(
+ ModelType type, SyncDataList *deleted) const {
+ syncer::syncable::EntryKernelSet deleted_entries;
+ GetDirectory()->GetDeleteJournals(GetWrappedTrans(), type, &deleted_entries);
+ std::set<int64> undecryptable_journal;
+ for (syncer::syncable::EntryKernelSet::const_iterator i =
+ deleted_entries.begin(); i != deleted_entries.end(); ++i) {
+ int64 id = (*i)->ref(syncer::syncable::META_HANDLE);
+ const sync_pb::EntitySpecifics& specifics =
+ (*i)->ref(syncer::syncable::SPECIFICS);
+ bool is_folder = (*i)->ref(syncer::syncable::IS_DIR);
+ if (!specifics.has_encrypted()) {
+ deleted->push_back(syncer::SyncData::CreateRemoteData(id, specifics,
+ is_folder));
+ } else {
+ const sync_pb::EncryptedData& encrypted = specifics.encrypted();
+ std::string plaintext_data =
+ GetCryptographer()->DecryptToString(encrypted);
+ sync_pb::EntitySpecifics unencrypted_data;
+ if (plaintext_data.length() == 0 ||
+ !unencrypted_data.ParseFromString(plaintext_data)) {
+ // Fail to decrypt, purge this delete journal.
+ undecryptable_journal.insert(id);
+ } else {
+ deleted->push_back(syncer::SyncData::CreateRemoteData(id,
+ unencrypted_data,
+ is_folder));
+ }
+ }
+ }
+
+ if (!undecryptable_journal.empty()) {
+ GetDirectory()->PurgeDeleteJournals(GetWrappedTrans(),
+ undecryptable_journal);
+ }
+}
+
+void BaseTransaction::PurgeDeletedSyncData(const std::set<int64>& ids) {
+ GetDirectory()->PurgeDeleteJournals(GetWrappedTrans(), ids);
+}
+
} // namespace syncer

Powered by Google App Engine
This is Rietveld 408576698