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

Side by Side Diff: components/sync/driver/generic_change_processor.cc

Issue 2285753002: Passing correct passhprase type in the generic change processor. (Closed)
Patch Set: Created 4 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
« no previous file with comments | « components/sync/core/base_transaction.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "components/sync/driver/generic_change_processor.h" 5 #include "components/sync/driver/generic_change_processor.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <string> 10 #include <string>
(...skipping 19 matching lines...) Expand all
30 #include "components/sync/driver/sync_client.h" 30 #include "components/sync/driver/sync_client.h"
31 #include "components/sync/syncable/entry.h" // TODO(tim): Bug 123674. 31 #include "components/sync/syncable/entry.h" // TODO(tim): Bug 123674.
32 32
33 namespace sync_driver { 33 namespace sync_driver {
34 34
35 namespace { 35 namespace {
36 36
37 const int kContextSizeLimit = 1024; // Datatype context size limit. 37 const int kContextSizeLimit = 1024; // Datatype context size limit.
38 38
39 void SetNodeSpecifics(const sync_pb::EntitySpecifics& entity_specifics, 39 void SetNodeSpecifics(const sync_pb::EntitySpecifics& entity_specifics,
40 syncer::WriteNode* write_node) { 40 syncer::WriteNode* write_node,
41 syncer::PassphraseType passphrase_type) {
41 if (syncer::GetModelTypeFromSpecifics(entity_specifics) == 42 if (syncer::GetModelTypeFromSpecifics(entity_specifics) ==
42 syncer::PASSWORDS) { 43 syncer::PASSWORDS) {
43 write_node->SetPasswordSpecifics( 44 write_node->SetPasswordSpecifics(
44 entity_specifics.password().client_only_encrypted_data(), 45 entity_specifics.password().client_only_encrypted_data(),
45 // TODO(melandory): Since PasswordsSpecifics care about passphrase type. 46 passphrase_type);
46 // the real value should be passed here. 47
47 syncer::PassphraseType::UNDEFINED);
48 } else { 48 } else {
49 write_node->SetEntitySpecifics(entity_specifics); 49 write_node->SetEntitySpecifics(entity_specifics);
50 } 50 }
51 } 51 }
52 52
53 // Helper function to convert AttachmentId to AttachmentMetadataRecord. 53 // Helper function to convert AttachmentId to AttachmentMetadataRecord.
54 sync_pb::AttachmentMetadataRecord AttachmentIdToRecord( 54 sync_pb::AttachmentMetadataRecord AttachmentIdToRecord(
55 const syncer::AttachmentId& attachment_id) { 55 const syncer::AttachmentId& attachment_id) {
56 sync_pb::AttachmentMetadataRecord record; 56 sync_pb::AttachmentMetadataRecord record;
57 *record.mutable_id() = attachment_id.GetProto(); 57 *record.mutable_id() = attachment_id.GetProto();
(...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after
550 } 550 }
551 default: { 551 default: {
552 syncer::SyncError error; 552 syncer::SyncError error;
553 error.Reset(FROM_HERE, error_prefix + "unknown error", type_); 553 error.Reset(FROM_HERE, error_prefix + "unknown error", type_);
554 error_handler()->OnSingleDataTypeUnrecoverableError(error); 554 error_handler()->OnSingleDataTypeUnrecoverableError(error);
555 LOG(ERROR) << "Create: Unknown error."; 555 LOG(ERROR) << "Create: Unknown error.";
556 return error; 556 return error;
557 } 557 }
558 } 558 }
559 } 559 }
560 syncer::PassphraseType passphrase_type = syncer::PassphraseType::UNDEFINED;
561 {
562 syncer::ReadTransaction trans(FROM_HERE, share_handle());
563 passphrase_type = trans.GetPassphraseType();
564 }
560 sync_node->SetTitle(change.sync_data().GetTitle()); 565 sync_node->SetTitle(change.sync_data().GetTitle());
561 SetNodeSpecifics(sync_data_local.GetSpecifics(), sync_node); 566 SetNodeSpecifics(sync_data_local.GetSpecifics(), sync_node,passphrase_type) ;
562 567
563 syncer::AttachmentIdList attachment_ids = sync_data_local.GetAttachmentIds(); 568 syncer::AttachmentIdList attachment_ids = sync_data_local.GetAttachmentIds();
564 SetAttachmentMetadata(attachment_ids, sync_node); 569 SetAttachmentMetadata(attachment_ids, sync_node);
565 570
566 // Return any newly added attachments. 571 // Return any newly added attachments.
567 new_attachments->insert(attachment_ids.begin(), attachment_ids.end()); 572 new_attachments->insert(attachment_ids.begin(), attachment_ids.end());
568 if (merge_result_.get()) { 573 if (merge_result_.get()) {
569 merge_result_->set_num_items_added(merge_result_->num_items_added() + 1); 574 merge_result_->set_num_items_added(merge_result_->num_items_added() + 1);
570 } 575 }
571 return syncer::SyncError(); 576 return syncer::SyncError();
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
613 return error; 618 return error;
614 } else { 619 } else {
615 NOTREACHED(); 620 NOTREACHED();
616 syncer::SyncError error; 621 syncer::SyncError error;
617 error.Reset(FROM_HERE, error_prefix + "unknown error", type_); 622 error.Reset(FROM_HERE, error_prefix + "unknown error", type_);
618 error_handler()->OnSingleDataTypeUnrecoverableError(error); 623 error_handler()->OnSingleDataTypeUnrecoverableError(error);
619 LOG(ERROR) << "Update: Unknown error."; 624 LOG(ERROR) << "Update: Unknown error.";
620 return error; 625 return error;
621 } 626 }
622 } 627 }
623 628 syncer::PassphraseType passphrase_type = syncer::PassphraseType::UNDEFINED;
629 {
630 syncer::ReadTransaction trans(FROM_HERE, share_handle());
631 passphrase_type = trans.GetPassphraseType();
632 }
624 sync_node->SetTitle(change.sync_data().GetTitle()); 633 sync_node->SetTitle(change.sync_data().GetTitle());
625 SetNodeSpecifics(sync_data_local.GetSpecifics(), sync_node); 634 SetNodeSpecifics(sync_data_local.GetSpecifics(), sync_node, passphrase_type);
626 syncer::AttachmentIdList attachment_ids = sync_data_local.GetAttachmentIds(); 635 syncer::AttachmentIdList attachment_ids = sync_data_local.GetAttachmentIds();
627 SetAttachmentMetadata(attachment_ids, sync_node); 636 SetAttachmentMetadata(attachment_ids, sync_node);
628 637
629 // Return any newly added attachments. 638 // Return any newly added attachments.
630 new_attachments->insert(attachment_ids.begin(), attachment_ids.end()); 639 new_attachments->insert(attachment_ids.begin(), attachment_ids.end());
631 640
632 if (merge_result_.get()) { 641 if (merge_result_.get()) {
633 merge_result_->set_num_items_modified(merge_result_->num_items_modified() + 642 merge_result_->set_num_items_modified(merge_result_->num_items_modified() +
634 1); 643 1);
635 } 644 }
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
687 } 696 }
688 } 697 }
689 698
690 std::unique_ptr<syncer::AttachmentService> 699 std::unique_ptr<syncer::AttachmentService>
691 GenericChangeProcessor::GetAttachmentService() const { 700 GenericChangeProcessor::GetAttachmentService() const {
692 return std::unique_ptr<syncer::AttachmentService>( 701 return std::unique_ptr<syncer::AttachmentService>(
693 new syncer::AttachmentServiceProxy(attachment_service_proxy_)); 702 new syncer::AttachmentServiceProxy(attachment_service_proxy_));
694 } 703 }
695 704
696 } // namespace sync_driver 705 } // namespace sync_driver
OLDNEW
« no previous file with comments | « components/sync/core/base_transaction.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698