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 // Various utility methods for nigori-based multi-type encryption. | 5 // Various utility methods for nigori-based multi-type encryption. |
6 | 6 |
7 #ifndef CHROME_BROWSER_SYNC_ENGINE_NIGORI_UTIL_H_ | 7 #ifndef SYNC_ENGINE_NIGORI_UTIL_H_ |
8 #define CHROME_BROWSER_SYNC_ENGINE_NIGORI_UTIL_H_ | 8 #define SYNC_ENGINE_NIGORI_UTIL_H_ |
9 #pragma once | 9 #pragma once |
10 | 10 |
11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
12 #include "chrome/browser/sync/syncable/model_type.h" | |
13 #include "sync/protocol/nigori_specifics.pb.h" | 12 #include "sync/protocol/nigori_specifics.pb.h" |
| 13 #include "sync/syncable/model_type.h" |
14 | 14 |
15 namespace browser_sync { | 15 namespace browser_sync { |
16 class Cryptographer; | 16 class Cryptographer; |
17 } | 17 } |
18 | 18 |
19 namespace sync_pb { | 19 namespace sync_pb { |
20 class EntitySpecifics; | 20 class EntitySpecifics; |
21 } | 21 } |
22 | 22 |
23 namespace syncable { | 23 namespace syncable { |
24 | 24 |
25 const char kEncryptedString[] = "encrypted"; | 25 const char kEncryptedString[] = "encrypted"; |
26 | 26 |
27 class BaseTransaction; | 27 class BaseTransaction; |
28 class Entry; | 28 class Entry; |
| 29 class MutableEntry; |
29 class WriteTransaction; | 30 class WriteTransaction; |
30 | 31 |
31 // Check if our unsyced changes are encrypted if they need to be based on | 32 // Check if our unsyced changes are encrypted if they need to be based on |
32 // |encrypted_types|. | 33 // |encrypted_types|. |
33 // Returns: true if all unsynced data that should be encrypted is. | 34 // Returns: true if all unsynced data that should be encrypted is. |
34 // false if some unsynced changes need to be encrypted. | 35 // false if some unsynced changes need to be encrypted. |
35 // This method is similar to ProcessUnsyncedChangesForEncryption but does not | 36 // This method is similar to ProcessUnsyncedChangesForEncryption but does not |
36 // modify the data and does not care if data is unnecessarily encrypted. | 37 // modify the data and does not care if data is unnecessarily encrypted. |
37 bool VerifyUnsyncedChangesAreEncrypted( | 38 bool VerifyUnsyncedChangesAreEncrypted( |
38 BaseTransaction* const trans, | 39 BaseTransaction* const trans, |
(...skipping 15 matching lines...) Expand all Loading... |
54 bool SpecificsNeedsEncryption(ModelTypeSet encrypted_types, | 55 bool SpecificsNeedsEncryption(ModelTypeSet encrypted_types, |
55 const sync_pb::EntitySpecifics& specifics); | 56 const sync_pb::EntitySpecifics& specifics); |
56 | 57 |
57 // Verifies all data of type |type| is encrypted appropriately. | 58 // Verifies all data of type |type| is encrypted appropriately. |
58 bool VerifyDataTypeEncryptionForTest( | 59 bool VerifyDataTypeEncryptionForTest( |
59 BaseTransaction* const trans, | 60 BaseTransaction* const trans, |
60 browser_sync::Cryptographer* cryptographer, | 61 browser_sync::Cryptographer* cryptographer, |
61 ModelType type, | 62 ModelType type, |
62 bool is_encrypted) WARN_UNUSED_RESULT; | 63 bool is_encrypted) WARN_UNUSED_RESULT; |
63 | 64 |
| 65 // Stores |new_specifics| into |entry|, encrypting if necessary. |
| 66 // Returns false if an error encrypting occurred (does not modify |entry|). |
| 67 // Note: gracefully handles new_specifics aliasing with entry->Get(SPECIFICS). |
| 68 bool UpdateEntryWithEncryption( |
| 69 browser_sync::Cryptographer* cryptographer, |
| 70 const sync_pb::EntitySpecifics& new_specifics, |
| 71 MutableEntry* entry); |
| 72 |
64 } // namespace syncable | 73 } // namespace syncable |
65 | 74 |
66 #endif // CHROME_BROWSER_SYNC_ENGINE_NIGORI_UTIL_H_ | 75 #endif // SYNC_ENGINE_NIGORI_UTIL_H_ |
OLD | NEW |