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

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

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 #include "chrome/browser/sync/engine/nigori_util.h" 5 #include "chrome/browser/sync/engine/nigori_util.h"
6 6
7 #include <queue> 7 #include <queue>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 BaseTransaction* const trans, 56 BaseTransaction* const trans,
57 const ModelTypeSet& encrypted_types) { 57 const ModelTypeSet& encrypted_types) {
58 std::vector<int64> handles; 58 std::vector<int64> handles;
59 browser_sync::SyncerUtil::GetUnsyncedEntries(trans, &handles); 59 browser_sync::SyncerUtil::GetUnsyncedEntries(trans, &handles);
60 for (size_t i = 0; i < handles.size(); ++i) { 60 for (size_t i = 0; i < handles.size(); ++i) {
61 Entry entry(trans, GET_BY_HANDLE, handles[i]); 61 Entry entry(trans, GET_BY_HANDLE, handles[i]);
62 if (!entry.good()) { 62 if (!entry.good()) {
63 NOTREACHED(); 63 NOTREACHED();
64 return false; 64 return false;
65 } 65 }
66 const sync_pb::EntitySpecifics& entry_specifics = entry.Get(SPECIFICS); 66 if (EntryNeedsEncryption(encrypted_types, entry))
67 ModelType type = entry.GetModelType();
68 if (type == PASSWORDS)
69 continue;
70 if (encrypted_types.count(type) > 0 &&
71 !entry_specifics.has_encrypted()) {
72 // This datatype requires encryption but this data is not encrypted.
73 return false; 67 return false;
74 }
75 } 68 }
76 return true; 69 return true;
77 } 70 }
78 71
72 bool EntryNeedsEncryption(const ModelTypeSet& encrypted_types,
73 const Entry& entry) {
74 if (!entry.Get(UNIQUE_SERVER_TAG).empty())
75 return false; // We don't encrypt unique server nodes.
76 return SpecificsNeedsEncryption(encrypted_types, entry.Get(SPECIFICS));
77 }
78
79 bool SpecificsNeedsEncryption(const ModelTypeSet& encrypted_types,
80 const sync_pb::EntitySpecifics& specifics) {
81 ModelType type = GetModelTypeFromSpecifics(specifics);
82 if (type == PASSWORDS || type == NIGORI)
83 return false; // These types have their own encryption schemes.
84 if (encrypted_types.count(type) == 0)
85 return false; // This type does not require encryption
86 return !specifics.has_encrypted();
87 }
88
79 // Mainly for testing. 89 // Mainly for testing.
80 bool VerifyDataTypeEncryption(BaseTransaction* const trans, 90 bool VerifyDataTypeEncryption(BaseTransaction* const trans,
81 browser_sync::Cryptographer* cryptographer, 91 browser_sync::Cryptographer* cryptographer,
82 ModelType type, 92 ModelType type,
83 bool is_encrypted) { 93 bool is_encrypted) {
84 if (type == PASSWORDS || type == NIGORI) { 94 if (type == PASSWORDS || type == NIGORI) {
85 NOTREACHED(); 95 NOTREACHED();
86 return true; 96 return true;
87 } 97 }
88 std::string type_tag = ModelTypeToRootTag(type); 98 std::string type_tag = ModelTypeToRootTag(type);
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 return false; 136 return false;
127 } 137 }
128 } 138 }
129 // Push the successor. 139 // Push the successor.
130 to_visit.push(child.Get(NEXT_ID)); 140 to_visit.push(child.Get(NEXT_ID));
131 } 141 }
132 return true; 142 return true;
133 } 143 }
134 144
135 } // namespace syncable 145 } // namespace syncable
OLDNEW
« no previous file with comments | « chrome/browser/sync/engine/nigori_util.h ('k') | chrome/browser/sync/engine/nigori_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698