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

Side by Side Diff: chrome/browser/sync/engine/nigori_util.h

Issue 7795002: [Sync] Gracefully handle writing to a node when the cryptographer is not ready. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Reviewer comments Created 9 years, 3 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 CHROME_BROWSER_SYNC_ENGINE_NIGORI_UTIL_H_
8 #define CHROME_BROWSER_SYNC_ENGINE_NIGORI_UTIL_H_ 8 #define CHROME_BROWSER_SYNC_ENGINE_NIGORI_UTIL_H_
9 #pragma once 9 #pragma once
10 10
11 #include "chrome/browser/sync/protocol/nigori_specifics.pb.h" 11 #include "chrome/browser/sync/protocol/nigori_specifics.pb.h"
12 #include "chrome/browser/sync/syncable/model_type.h" 12 #include "chrome/browser/sync/syncable/model_type.h"
13 13
14 namespace browser_sync { 14 namespace browser_sync {
15 class Cryptographer; 15 class Cryptographer;
16 } 16 }
17 17
18 namespace sync_pb {
19 class EntitySpecifics;
20 }
21
18 namespace syncable { 22 namespace syncable {
19 23
20 const char kEncryptedString[] = "encrypted"; 24 const char kEncryptedString[] = "encrypted";
21 25
22 class BaseTransaction; 26 class BaseTransaction;
27 class Entry;
23 class ReadTransaction; 28 class ReadTransaction;
24 class WriteTransaction; 29 class WriteTransaction;
25 30
26 // Set the encrypted datatypes on the nigori node. 31 // Set the encrypted datatypes on the nigori node.
27 void FillNigoriEncryptedTypes(const ModelTypeSet& types, 32 void FillNigoriEncryptedTypes(const ModelTypeSet& types,
28 sync_pb::NigoriSpecifics* nigori); 33 sync_pb::NigoriSpecifics* nigori);
29 34
30 // Check if our unsyced changes are encrypted if they need to be based on 35 // Check if our unsyced changes are encrypted if they need to be based on
31 // |encrypted_types|. 36 // |encrypted_types|.
32 // Returns: true if all unsynced data that should be encrypted is. 37 // Returns: true if all unsynced data that should be encrypted is.
33 // false if some unsynced changes need to be encrypted. 38 // false if some unsynced changes need to be encrypted.
34 // This method is similar to ProcessUnsyncedChangesForEncryption but does not 39 // This method is similar to ProcessUnsyncedChangesForEncryption but does not
35 // modify the data and does not care if data is unnecessarily encrypted. 40 // modify the data and does not care if data is unnecessarily encrypted.
36 bool VerifyUnsyncedChangesAreEncrypted( 41 bool VerifyUnsyncedChangesAreEncrypted(
37 BaseTransaction* const trans, 42 BaseTransaction* const trans,
38 const ModelTypeSet& encrypted_types); 43 const ModelTypeSet& encrypted_types);
39 44
40 // Processes all unsynced changes and ensures they are appropriately encrypted 45 // Processes all unsynced changes and ensures they are appropriately encrypted
41 // or unencrypted, based on |encrypted_types|. 46 // or unencrypted, based on |encrypted_types|.
42 bool ProcessUnsyncedChangesForEncryption( 47 bool ProcessUnsyncedChangesForEncryption(
43 WriteTransaction* const trans, 48 WriteTransaction* const trans,
44 browser_sync::Cryptographer* cryptographer); 49 browser_sync::Cryptographer* cryptographer);
45 50
51 // Returns true if the entry requires encryption but is not encrypted, false
52 // otherwise. Note: this does not check that already encrypted entries are
53 // encrypted with the proper key.
54 bool EntryNeedsEncryption(const ModelTypeSet& encrypted_types,
55 const Entry& entry);
56
57 // Same as EntryNeedsEncryption, but looks at specifics.
58 bool SpecificsNeedsEncryption(const ModelTypeSet& encrypted_types,
59 const sync_pb::EntitySpecifics& specifics);
60
46 // Verifies all data of type |type| is encrypted appropriately. 61 // Verifies all data of type |type| is encrypted appropriately.
47 bool VerifyDataTypeEncryption(BaseTransaction* const trans, 62 bool VerifyDataTypeEncryption(BaseTransaction* const trans,
48 browser_sync::Cryptographer* cryptographer, 63 browser_sync::Cryptographer* cryptographer,
49 ModelType type, 64 ModelType type,
50 bool is_encrypted); 65 bool is_encrypted);
51 66
52 } // namespace syncable 67 } // namespace syncable
53 68
54 #endif // CHROME_BROWSER_SYNC_ENGINE_NIGORI_UTIL_H_ 69 #endif // CHROME_BROWSER_SYNC_ENGINE_NIGORI_UTIL_H_
OLDNEW
« no previous file with comments | « chrome/browser/sync/engine/get_commit_ids_command.cc ('k') | chrome/browser/sync/engine/nigori_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698