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

Side by Side Diff: components/sync/core/delete_journal.cc

Issue 2407163004: [Sync] Move some directory-related things from core/ to syncable/. (Closed)
Patch Set: Created 4 years, 2 months 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
« no previous file with comments | « components/sync/core/delete_journal.h ('k') | components/sync/core/read_node.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "components/sync/core/delete_journal.h"
6
7 #include <string>
8
9 #include "components/sync/core/base_transaction.h"
10 #include "components/sync/syncable/directory.h"
11 #include "components/sync/syncable/syncable_base_transaction.h"
12
13 namespace syncer {
14
15 // static
16 void DeleteJournal::GetBookmarkDeleteJournals(
17 BaseTransaction* trans,
18 BookmarkDeleteJournalList* delete_journal_list) {
19 syncable::EntryKernelSet deleted_entries;
20 trans->GetDirectory()->delete_journal()->GetDeleteJournals(
21 trans->GetWrappedTrans(), BOOKMARKS, &deleted_entries);
22 std::set<int64_t> undecryptable_journal;
23 for (syncable::EntryKernelSet::const_iterator i = deleted_entries.begin();
24 i != deleted_entries.end(); ++i) {
25 delete_journal_list->push_back(BookmarkDeleteJournal());
26 delete_journal_list->back().id = (*i)->ref(syncable::META_HANDLE);
27 delete_journal_list->back().external_id =
28 (*i)->ref(syncable::LOCAL_EXTERNAL_ID);
29 delete_journal_list->back().is_folder = (*i)->ref(syncable::IS_DIR);
30
31 const sync_pb::EntitySpecifics& specifics = (*i)->ref(syncable::SPECIFICS);
32 if (!specifics.has_encrypted()) {
33 delete_journal_list->back().specifics = specifics;
34 } else {
35 std::string plaintext_data =
36 trans->GetCryptographer()->DecryptToString(specifics.encrypted());
37 sync_pb::EntitySpecifics unencrypted_data;
38 if (plaintext_data.length() == 0 ||
39 !unencrypted_data.ParseFromString(plaintext_data)) {
40 // Fail to decrypt, Add this delete journal to purge.
41 undecryptable_journal.insert(delete_journal_list->back().id);
42 delete_journal_list->pop_back();
43 } else {
44 delete_journal_list->back().specifics = unencrypted_data;
45 }
46 }
47 }
48
49 if (!undecryptable_journal.empty()) {
50 trans->GetDirectory()->delete_journal()->PurgeDeleteJournals(
51 trans->GetWrappedTrans(), undecryptable_journal);
52 }
53 }
54
55 // static
56 void DeleteJournal::PurgeDeleteJournals(BaseTransaction* trans,
57 const std::set<int64_t>& ids) {
58 trans->GetDirectory()->delete_journal()->PurgeDeleteJournals(
59 trans->GetWrappedTrans(), ids);
60 }
61
62 } // namespace syncer
OLDNEW
« no previous file with comments | « components/sync/core/delete_journal.h ('k') | components/sync/core/read_node.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698