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/glue/generic_change_processor.h" | 5 #include "chrome/browser/sync/glue/generic_change_processor.h" |
6 | 6 |
7 #include "base/location.h" | 7 #include "base/location.h" |
8 #include "base/string_number_conversions.h" | 8 #include "base/string_number_conversions.h" |
9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
10 #include "content/public/browser/browser_thread.h" | 10 #include "content/public/browser/browser_thread.h" |
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
369 syncer::SyncError error; | 369 syncer::SyncError error; |
370 error.Reset(FROM_HERE, | 370 error.Reset(FROM_HERE, |
371 error_prefix + "deleted entry", | 371 error_prefix + "deleted entry", |
372 type); | 372 type); |
373 error_handler()->OnSingleDatatypeUnrecoverableError( | 373 error_handler()->OnSingleDatatypeUnrecoverableError( |
374 FROM_HERE, error.message()); | 374 FROM_HERE, error.message()); |
375 LOG(ERROR) << "Update: deleted entry."; | 375 LOG(ERROR) << "Update: deleted entry."; |
376 return error; | 376 return error; |
377 } else { | 377 } else { |
378 syncer::Cryptographer* crypto = trans.GetCryptographer(); | 378 syncer::Cryptographer* crypto = trans.GetCryptographer(); |
379 syncer::ModelTypeSet encrypted_types(crypto->GetEncryptedTypes()); | 379 syncer::ModelTypeSet encrypted_types(trans.GetEncryptedTypes()); |
380 const sync_pb::EntitySpecifics& specifics = | 380 const sync_pb::EntitySpecifics& specifics = |
381 sync_node.GetEntry()->Get(syncer::syncable::SPECIFICS); | 381 sync_node.GetEntry()->Get(syncer::syncable::SPECIFICS); |
382 CHECK(specifics.has_encrypted()); | 382 CHECK(specifics.has_encrypted()); |
383 const bool can_decrypt = crypto->CanDecrypt(specifics.encrypted()); | 383 const bool can_decrypt = crypto->CanDecrypt(specifics.encrypted()); |
384 const bool agreement = encrypted_types.Has(type); | 384 const bool agreement = encrypted_types.Has(type); |
385 if (!agreement && !can_decrypt) { | 385 if (!agreement && !can_decrypt) { |
386 syncer::SyncError error; | 386 syncer::SyncError error; |
387 error.Reset(FROM_HERE, | 387 error.Reset(FROM_HERE, |
388 "Failed to load encrypted entry, missing key and " | 388 "Failed to load encrypted entry, missing key and " |
389 "nigori mismatch for " + type_str + ".", | 389 "nigori mismatch for " + type_str + ".", |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
468 // children. | 468 // children. |
469 *has_nodes = type_root_node.HasChildren(); | 469 *has_nodes = type_root_node.HasChildren(); |
470 return true; | 470 return true; |
471 } | 471 } |
472 | 472 |
473 bool GenericChangeProcessor::CryptoReadyIfNecessary(syncer::ModelType type) { | 473 bool GenericChangeProcessor::CryptoReadyIfNecessary(syncer::ModelType type) { |
474 DCHECK(CalledOnValidThread()); | 474 DCHECK(CalledOnValidThread()); |
475 DCHECK_NE(type, syncer::UNSPECIFIED); | 475 DCHECK_NE(type, syncer::UNSPECIFIED); |
476 // We only access the cryptographer while holding a transaction. | 476 // We only access the cryptographer while holding a transaction. |
477 syncer::ReadTransaction trans(FROM_HERE, share_handle()); | 477 syncer::ReadTransaction trans(FROM_HERE, share_handle()); |
478 const syncer::ModelTypeSet encrypted_types = GetEncryptedTypes(&trans); | 478 const syncer::ModelTypeSet encrypted_types = trans.GetEncryptedTypes(); |
479 return !encrypted_types.Has(type) || | 479 return !encrypted_types.Has(type) || |
480 trans.GetCryptographer()->is_ready(); | 480 trans.GetCryptographer()->is_ready(); |
481 } | 481 } |
482 | 482 |
483 void GenericChangeProcessor::StartImpl(Profile* profile) { | 483 void GenericChangeProcessor::StartImpl(Profile* profile) { |
484 DCHECK(CalledOnValidThread()); | 484 DCHECK(CalledOnValidThread()); |
485 } | 485 } |
486 | 486 |
487 void GenericChangeProcessor::StopImpl() { | 487 void GenericChangeProcessor::StopImpl() { |
488 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 488 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
489 } | 489 } |
490 | 490 |
491 syncer::UserShare* GenericChangeProcessor::share_handle() const { | 491 syncer::UserShare* GenericChangeProcessor::share_handle() const { |
492 DCHECK(CalledOnValidThread()); | 492 DCHECK(CalledOnValidThread()); |
493 return share_handle_; | 493 return share_handle_; |
494 } | 494 } |
495 | 495 |
496 } // namespace browser_sync | 496 } // namespace browser_sync |
OLD | NEW |