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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "sync/internal_api/public/base_transaction.h" 5 #include "sync/internal_api/public/base_transaction.h"
6 6
7 #include "sync/syncable/directory.h" 7 #include "sync/syncable/directory.h"
8 #include "sync/syncable/entry_kernel.h"
8 #include "sync/syncable/nigori_handler.h" 9 #include "sync/syncable/nigori_handler.h"
9 #include "sync/util/cryptographer.h" 10 #include "sync/util/cryptographer.h"
10 11
11 namespace syncer { 12 namespace syncer {
12 13
13 ////////////////////////////////////////////////////////////////////////// 14 //////////////////////////////////////////////////////////////////////////
14 // BaseTransaction member definitions 15 // BaseTransaction member definitions
15 BaseTransaction::BaseTransaction(UserShare* share) 16 BaseTransaction::BaseTransaction(UserShare* share)
16 : user_share_(share) { 17 : user_share_(share) {
17 DCHECK(share && share->directory.get()); 18 DCHECK(share && share->directory.get());
18 } 19 }
19 20
20 BaseTransaction::~BaseTransaction() { 21 BaseTransaction::~BaseTransaction() {
21 } 22 }
22 23
23 Cryptographer* BaseTransaction::GetCryptographer() const { 24 Cryptographer* BaseTransaction::GetCryptographer() const {
24 return GetDirectory()->GetCryptographer(this->GetWrappedTrans()); 25 return GetDirectory()->GetCryptographer(this->GetWrappedTrans());
25 } 26 }
26 27
27 ModelTypeSet BaseTransaction::GetEncryptedTypes() const { 28 ModelTypeSet BaseTransaction::GetEncryptedTypes() const {
28 return GetDirectory()->GetNigoriHandler()->GetEncryptedTypes( 29 return GetDirectory()->GetNigoriHandler()->GetEncryptedTypes(
29 this->GetWrappedTrans()); 30 this->GetWrappedTrans());
30 } 31 }
31 32
33 void BaseTransaction::GetDeletedSyncData(
34 ModelType type, SyncDataList *deleted) const {
35 syncer::syncable::EntryKernelSet deleted_entries;
36 GetDirectory()->GetDeleteJournals(GetWrappedTrans(), type, &deleted_entries);
37 std::set<int64> undecryptable_journal;
38 for (syncer::syncable::EntryKernelSet::const_iterator i =
39 deleted_entries.begin(); i != deleted_entries.end(); ++i) {
40 int64 id = (*i)->ref(syncer::syncable::META_HANDLE);
41 const sync_pb::EntitySpecifics& specifics =
42 (*i)->ref(syncer::syncable::SPECIFICS);
43 bool is_folder = (*i)->ref(syncer::syncable::IS_DIR);
44 if (!specifics.has_encrypted()) {
45 deleted->push_back(syncer::SyncData::CreateRemoteData(id, specifics,
46 is_folder));
47 } else {
48 const sync_pb::EncryptedData& encrypted = specifics.encrypted();
49 std::string plaintext_data =
50 GetCryptographer()->DecryptToString(encrypted);
51 sync_pb::EntitySpecifics unencrypted_data;
52 if (plaintext_data.length() == 0 ||
53 !unencrypted_data.ParseFromString(plaintext_data)) {
54 // Fail to decrypt, purge this delete journal.
55 undecryptable_journal.insert(id);
56 } else {
57 deleted->push_back(syncer::SyncData::CreateRemoteData(id,
58 unencrypted_data,
59 is_folder));
60 }
61 }
62 }
63
64 if (!undecryptable_journal.empty()) {
65 GetDirectory()->PurgeDeleteJournals(GetWrappedTrans(),
66 undecryptable_journal);
67 }
68 }
69
70 void BaseTransaction::PurgeDeletedSyncData(const std::set<int64>& ids) {
71 GetDirectory()->PurgeDeleteJournals(GetWrappedTrans(), ids);
72 }
73
32 } // namespace syncer 74 } // namespace syncer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698