| 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 #include "sync/engine/nigori_util.h" | 5 #include "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 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 if ((!SpecificsNeedsEncryption(encrypted_types, new_specifics) && | 172 if ((!SpecificsNeedsEncryption(encrypted_types, new_specifics) && |
| 173 !was_encrypted) || | 173 !was_encrypted) || |
| 174 !cryptographer->is_initialized()) { | 174 !cryptographer->is_initialized()) { |
| 175 // No encryption required or we are unable to encrypt. | 175 // No encryption required or we are unable to encrypt. |
| 176 generated_specifics.CopyFrom(new_specifics); | 176 generated_specifics.CopyFrom(new_specifics); |
| 177 } else { | 177 } else { |
| 178 // Encrypt new_specifics into generated_specifics. | 178 // Encrypt new_specifics into generated_specifics. |
| 179 if (VLOG_IS_ON(2)) { | 179 if (VLOG_IS_ON(2)) { |
| 180 scoped_ptr<DictionaryValue> value(entry->ToValue()); | 180 scoped_ptr<DictionaryValue> value(entry->ToValue()); |
| 181 std::string info; | 181 std::string info; |
| 182 base::JSONWriter::Write(value.get(), true, &info); | 182 base::JSONWriter::WriteWithOptions(value.get(), |
| 183 base::JSONWriter::OPTIONS_PRETTY_PRINT, |
| 184 &info); |
| 183 DVLOG(2) << "Encrypting specifics of type " | 185 DVLOG(2) << "Encrypting specifics of type " |
| 184 << syncable::ModelTypeToString(type) | 186 << syncable::ModelTypeToString(type) |
| 185 << " with content: " | 187 << " with content: " |
| 186 << info; | 188 << info; |
| 187 } | 189 } |
| 188 // Only copy over the old specifics if it is of the right type and already | 190 // Only copy over the old specifics if it is of the right type and already |
| 189 // encrypted. The first time we encrypt a node we start from scratch, hence | 191 // encrypted. The first time we encrypt a node we start from scratch, hence |
| 190 // removing all the unencrypted data, but from then on we only want to | 192 // removing all the unencrypted data, but from then on we only want to |
| 191 // update the node if the data changes or the encryption key changes. | 193 // update the node if the data changes or the encryption key changes. |
| 192 if (syncable::GetModelTypeFromSpecifics(old_specifics) == type && | 194 if (syncable::GetModelTypeFromSpecifics(old_specifics) == type && |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 } | 237 } |
| 236 entry->Put(syncable::SPECIFICS, generated_specifics); | 238 entry->Put(syncable::SPECIFICS, generated_specifics); |
| 237 DVLOG(1) << "Overwriting specifics of type " | 239 DVLOG(1) << "Overwriting specifics of type " |
| 238 << syncable::ModelTypeToString(type) | 240 << syncable::ModelTypeToString(type) |
| 239 << " and marking for syncing."; | 241 << " and marking for syncing."; |
| 240 syncable::MarkForSyncing(entry); | 242 syncable::MarkForSyncing(entry); |
| 241 return true; | 243 return true; |
| 242 } | 244 } |
| 243 | 245 |
| 244 } // namespace syncable | 246 } // namespace syncable |
| OLD | NEW |