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

Side by Side Diff: components/sync/syncable/nigori_util.h

Issue 2240613002: [Sync] Convert sync to a static library. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Try getting rid of sync_core source set. Created 4 years, 4 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
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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 // Various utility methods for nigori-based multi-type encryption. 5 // Various utility methods for nigori-based multi-type encryption.
6 6
7 #ifndef COMPONENTS_SYNC_SYNCABLE_NIGORI_UTIL_H_ 7 #ifndef COMPONENTS_SYNC_SYNCABLE_NIGORI_UTIL_H_
8 #define COMPONENTS_SYNC_SYNCABLE_NIGORI_UTIL_H_ 8 #define COMPONENTS_SYNC_SYNCABLE_NIGORI_UTIL_H_
9 9
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
11 #include "components/sync/base/model_type.h" 11 #include "components/sync/base/model_type.h"
12 #include "components/sync/base/sync_export.h"
13 #include "components/sync/protocol/nigori_specifics.pb.h" 12 #include "components/sync/protocol/nigori_specifics.pb.h"
14 13
15 namespace sync_pb { 14 namespace sync_pb {
16 class EntitySpecifics; 15 class EntitySpecifics;
17 } 16 }
18 17
19 namespace syncer { 18 namespace syncer {
20 class Cryptographer; 19 class Cryptographer;
21 20
22 namespace syncable { 21 namespace syncable {
23 22
24 const char kEncryptedString[] = "encrypted"; 23 const char kEncryptedString[] = "encrypted";
25 24
26 class BaseTransaction; 25 class BaseTransaction;
27 class Entry; 26 class Entry;
28 class MutableEntry; 27 class MutableEntry;
29 class WriteTransaction; 28 class WriteTransaction;
30 29
31 // Check if our unsyced changes are encrypted if they need to be based on 30 // Check if our unsyced changes are encrypted if they need to be based on
32 // |encrypted_types|. 31 // |encrypted_types|.
33 // Returns: true if all unsynced data that should be encrypted is. 32 // Returns: true if all unsynced data that should be encrypted is.
34 // false if some unsynced changes need to be encrypted. 33 // false if some unsynced changes need to be encrypted.
35 // This method is similar to ProcessUnsyncedChangesForEncryption but does not 34 // This method is similar to ProcessUnsyncedChangesForEncryption but does not
36 // modify the data and does not care if data is unnecessarily encrypted. 35 // modify the data and does not care if data is unnecessarily encrypted.
37 SYNC_EXPORT bool VerifyUnsyncedChangesAreEncrypted( 36 bool VerifyUnsyncedChangesAreEncrypted(BaseTransaction* const trans,
38 BaseTransaction* const trans, 37 ModelTypeSet encrypted_types);
39 ModelTypeSet encrypted_types);
40 38
41 // Processes all unsynced changes and ensures they are appropriately encrypted 39 // Processes all unsynced changes and ensures they are appropriately encrypted
42 // or unencrypted, based on |encrypted_types|. 40 // or unencrypted, based on |encrypted_types|.
43 bool ProcessUnsyncedChangesForEncryption(WriteTransaction* const trans); 41 bool ProcessUnsyncedChangesForEncryption(WriteTransaction* const trans);
44 42
45 // Returns true if the entry requires encryption but is not encrypted, false 43 // Returns true if the entry requires encryption but is not encrypted, false
46 // otherwise. Note: this does not check that already encrypted entries are 44 // otherwise. Note: this does not check that already encrypted entries are
47 // encrypted with the proper key. 45 // encrypted with the proper key.
48 bool EntryNeedsEncryption(ModelTypeSet encrypted_types, const Entry& entry); 46 bool EntryNeedsEncryption(ModelTypeSet encrypted_types, const Entry& entry);
49 47
50 // Same as EntryNeedsEncryption, but looks at specifics. 48 // Same as EntryNeedsEncryption, but looks at specifics.
51 SYNC_EXPORT bool SpecificsNeedsEncryption( 49 bool SpecificsNeedsEncryption(ModelTypeSet encrypted_types,
52 ModelTypeSet encrypted_types, 50 const sync_pb::EntitySpecifics& specifics);
53 const sync_pb::EntitySpecifics& specifics);
54 51
55 // Verifies all data of type |type| is encrypted appropriately. 52 // Verifies all data of type |type| is encrypted appropriately.
56 SYNC_EXPORT bool VerifyDataTypeEncryptionForTest(BaseTransaction* const trans, 53 bool VerifyDataTypeEncryptionForTest(BaseTransaction* const trans,
57 ModelType type, 54 ModelType type,
58 bool is_encrypted) 55 bool is_encrypted) WARN_UNUSED_RESULT;
59 WARN_UNUSED_RESULT;
60 56
61 // Stores |new_specifics| into |entry|, encrypting if necessary. 57 // Stores |new_specifics| into |entry|, encrypting if necessary.
62 // Returns false if an error encrypting occurred (does not modify |entry|). 58 // Returns false if an error encrypting occurred (does not modify |entry|).
63 // Note: gracefully handles new_specifics aliasing with entry->GetSpecifics(). 59 // Note: gracefully handles new_specifics aliasing with entry->GetSpecifics().
64 bool UpdateEntryWithEncryption(BaseTransaction* const trans, 60 bool UpdateEntryWithEncryption(BaseTransaction* const trans,
65 const sync_pb::EntitySpecifics& new_specifics, 61 const sync_pb::EntitySpecifics& new_specifics,
66 MutableEntry* entry); 62 MutableEntry* entry);
67 63
68 // Updates |nigori| to match the encryption state specified by |encrypted_types| 64 // Updates |nigori| to match the encryption state specified by |encrypted_types|
69 // and |encrypt_everything|. 65 // and |encrypt_everything|.
70 SYNC_EXPORT void UpdateNigoriFromEncryptedTypes( 66 void UpdateNigoriFromEncryptedTypes(ModelTypeSet encrypted_types,
71 ModelTypeSet encrypted_types, 67 bool encrypt_everything,
72 bool encrypt_everything, 68 sync_pb::NigoriSpecifics* nigori);
73 sync_pb::NigoriSpecifics* nigori);
74 69
75 // Extracts the set of encrypted types from a nigori node. 70 // Extracts the set of encrypted types from a nigori node.
76 ModelTypeSet GetEncryptedTypesFromNigori( 71 ModelTypeSet GetEncryptedTypesFromNigori(
77 const sync_pb::NigoriSpecifics& nigori); 72 const sync_pb::NigoriSpecifics& nigori);
78 73
79 } // namespace syncable 74 } // namespace syncable
80 } // namespace syncer 75 } // namespace syncer
81 76
82 #endif // COMPONENTS_SYNC_SYNCABLE_NIGORI_UTIL_H_ 77 #endif // COMPONENTS_SYNC_SYNCABLE_NIGORI_UTIL_H_
OLDNEW
« no previous file with comments | « components/sync/syncable/nigori_handler.h ('k') | components/sync/syncable/on_disk_directory_backing_store.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698