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