| 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 "chrome/browser/sync/engine/conflict_resolver.h" | 5 #include "chrome/browser/sync/engine/conflict_resolver.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <list> | 8 #include <list> |
| 9 #include <map> | 9 #include <map> |
| 10 #include <set> | 10 #include <set> |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 220 if (decrypted_server_specifics == decrypted_base_server_specifics) | 220 if (decrypted_server_specifics == decrypted_base_server_specifics) |
| 221 base_server_specifics_match = true; | 221 base_server_specifics_match = true; |
| 222 } | 222 } |
| 223 | 223 |
| 224 // We manually merge nigori data. | 224 // We manually merge nigori data. |
| 225 if (entry.GetModelType() == syncable::NIGORI) { | 225 if (entry.GetModelType() == syncable::NIGORI) { |
| 226 // Create a new set of specifics based on the server specifics (which | 226 // Create a new set of specifics based on the server specifics (which |
| 227 // preserves their encryption keys). | 227 // preserves their encryption keys). |
| 228 sync_pb::EntitySpecifics specifics = | 228 sync_pb::EntitySpecifics specifics = |
| 229 entry.Get(syncable::SERVER_SPECIFICS); | 229 entry.Get(syncable::SERVER_SPECIFICS); |
| 230 sync_pb::NigoriSpecifics* nigori = | 230 sync_pb::NigoriSpecifics* server_nigori = specifics.mutable_nigori(); |
| 231 specifics.MutableExtension(sync_pb::nigori); | |
| 232 // Store the merged set of encrypted types (cryptographer->Update(..) will | 231 // Store the merged set of encrypted types (cryptographer->Update(..) will |
| 233 // have merged the local types already). | 232 // have merged the local types already). |
| 234 cryptographer->UpdateNigoriFromEncryptedTypes(nigori); | 233 cryptographer->UpdateNigoriFromEncryptedTypes(server_nigori); |
| 235 // The local set of keys is already merged with the server's set within | 234 // The local set of keys is already merged with the server's set within |
| 236 // the cryptographer. If we don't have pending keys we can store the | 235 // the cryptographer. If we don't have pending keys we can store the |
| 237 // merged set back immediately. Else we preserve the server keys and will | 236 // merged set back immediately. Else we preserve the server keys and will |
| 238 // update the nigori when the user provides the pending passphrase via | 237 // update the nigori when the user provides the pending passphrase via |
| 239 // SetPassphrase(..). | 238 // SetPassphrase(..). |
| 240 if (cryptographer->is_ready()) { | 239 if (cryptographer->is_ready()) { |
| 241 cryptographer->GetKeys(nigori->mutable_encrypted()); | 240 cryptographer->GetKeys(server_nigori->mutable_encrypted()); |
| 242 } | 241 } |
| 243 // TODO(zea): Find a better way of doing this. As it stands, we have to | 242 // TODO(zea): Find a better way of doing this. As it stands, we have to |
| 244 // update this code whenever we add a new non-cryptographer related field | 243 // update this code whenever we add a new non-cryptographer related field |
| 245 // to the nigori node. | 244 // to the nigori node. |
| 246 if (entry.Get(syncable::SPECIFICS).GetExtension(sync_pb::nigori) | 245 if (entry.Get(syncable::SPECIFICS).nigori().sync_tabs()) { |
| 247 .sync_tabs()) { | 246 server_nigori->set_sync_tabs(true); |
| 248 nigori->set_sync_tabs(true); | |
| 249 } | 247 } |
| 250 // We deliberately leave the server's device information. This client will | 248 // We deliberately leave the server's device information. This client will |
| 251 // add it's own device information on restart. | 249 // add it's own device information on restart. |
| 252 entry.Put(syncable::SPECIFICS, specifics); | 250 entry.Put(syncable::SPECIFICS, specifics); |
| 253 DVLOG(1) << "Resovling simple conflict, merging nigori nodes: " << entry; | 251 DVLOG(1) << "Resovling simple conflict, merging nigori nodes: " << entry; |
| 254 status->increment_num_server_overwrites(); | 252 status->increment_num_server_overwrites(); |
| 255 OverwriteServerChanges(trans, &entry); | 253 OverwriteServerChanges(trans, &entry); |
| 256 UMA_HISTOGRAM_ENUMERATION("Sync.ResolveSimpleConflict", | 254 UMA_HISTOGRAM_ENUMERATION("Sync.ResolveSimpleConflict", |
| 257 NIGORI_MERGE, | 255 NIGORI_MERGE, |
| 258 CONFLICT_RESOLUTION_SIZE); | 256 CONFLICT_RESOLUTION_SIZE); |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 397 forward_progress = true; | 395 forward_progress = true; |
| 398 break; | 396 break; |
| 399 } | 397 } |
| 400 processed_items.insert(id); | 398 processed_items.insert(id); |
| 401 } | 399 } |
| 402 } | 400 } |
| 403 return forward_progress; | 401 return forward_progress; |
| 404 } | 402 } |
| 405 | 403 |
| 406 } // namespace browser_sync | 404 } // namespace browser_sync |
| OLD | NEW |