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

Side by Side Diff: chrome/browser/sync/profile_sync_service_autofill_unittest.cc

Issue 10310113: Add additional error logging to investigate Autocomplete Sync failures. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: De-nitting Created 8 years, 7 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 | Annotate | Revision Log
OLDNEW
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 <set> 5 #include <set>
6 #include <string> 6 #include <string>
7 #include <vector> 7 #include <vector>
8 8
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 10
(...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after
453 sync_api::ReadNode autofill_root(&trans); 453 sync_api::ReadNode autofill_root(&trans);
454 if (autofill_root.InitByTagLookup( 454 if (autofill_root.InitByTagLookup(
455 syncable::ModelTypeToRootTag(syncable::AUTOFILL)) != 455 syncable::ModelTypeToRootTag(syncable::AUTOFILL)) !=
456 BaseNode::INIT_OK) { 456 BaseNode::INIT_OK) {
457 return false; 457 return false;
458 } 458 }
459 459
460 sync_api::WriteNode node(&trans); 460 sync_api::WriteNode node(&trans);
461 std::string tag = AutocompleteSyncableService::KeyToTag( 461 std::string tag = AutocompleteSyncableService::KeyToTag(
462 UTF16ToUTF8(entry.key().name()), UTF16ToUTF8(entry.key().value())); 462 UTF16ToUTF8(entry.key().name()), UTF16ToUTF8(entry.key().value()));
463 if (!node.InitUniqueByCreation(syncable::AUTOFILL, autofill_root, tag)) 463 sync_api::WriteNode::InitUniqueByCreationResult result =
464 node.InitUniqueByCreation(syncable::AUTOFILL, autofill_root, tag);
465 if (result != sync_api::WriteNode::INIT_SUCCESS)
464 return false; 466 return false;
465 467
466 sync_pb::EntitySpecifics specifics; 468 sync_pb::EntitySpecifics specifics;
467 AutocompleteSyncableService::WriteAutofillEntry(entry, &specifics); 469 AutocompleteSyncableService::WriteAutofillEntry(entry, &specifics);
468 sync_pb::AutofillSpecifics* autofill_specifics = 470 sync_pb::AutofillSpecifics* autofill_specifics =
469 specifics.mutable_autofill(); 471 specifics.mutable_autofill();
470 node.SetAutofillSpecifics(*autofill_specifics); 472 node.SetAutofillSpecifics(*autofill_specifics);
471 return true; 473 return true;
472 } 474 }
473 475
474 bool AddAutofillSyncNode(const AutofillProfile& profile) { 476 bool AddAutofillSyncNode(const AutofillProfile& profile) {
475 sync_api::WriteTransaction trans(FROM_HERE, service_->GetUserShare()); 477 sync_api::WriteTransaction trans(FROM_HERE, service_->GetUserShare());
476 sync_api::ReadNode autofill_root(&trans); 478 sync_api::ReadNode autofill_root(&trans);
477 if (autofill_root.InitByTagLookup(kAutofillProfileTag) != 479 if (autofill_root.InitByTagLookup(kAutofillProfileTag) !=
478 BaseNode::INIT_OK) { 480 BaseNode::INIT_OK) {
479 return false; 481 return false;
480 } 482 }
481 sync_api::WriteNode node(&trans); 483 sync_api::WriteNode node(&trans);
482 std::string tag = profile.guid(); 484 std::string tag = profile.guid();
483 if (!node.InitUniqueByCreation(syncable::AUTOFILL_PROFILE, 485 sync_api::WriteNode::InitUniqueByCreationResult result =
484 autofill_root, tag)) 486 node.InitUniqueByCreation(syncable::AUTOFILL_PROFILE,
487 autofill_root, tag);
488 if (result != sync_api::WriteNode::INIT_SUCCESS)
485 return false; 489 return false;
490
486 sync_pb::EntitySpecifics specifics; 491 sync_pb::EntitySpecifics specifics;
487 AutofillProfileSyncableService::WriteAutofillProfile(profile, &specifics); 492 AutofillProfileSyncableService::WriteAutofillProfile(profile, &specifics);
488 sync_pb::AutofillProfileSpecifics* profile_specifics = 493 sync_pb::AutofillProfileSpecifics* profile_specifics =
489 specifics.mutable_autofill_profile(); 494 specifics.mutable_autofill_profile();
490 node.SetAutofillProfileSpecifics(*profile_specifics); 495 node.SetAutofillProfileSpecifics(*profile_specifics);
491 return true; 496 return true;
492 } 497 }
493 498
494 bool GetAutofillEntriesFromSyncDB(std::vector<AutofillEntry>* entries, 499 bool GetAutofillEntriesFromSyncDB(std::vector<AutofillEntry>* entries,
495 std::vector<AutofillProfile>* profiles) { 500 std::vector<AutofillProfile>* profiles) {
(...skipping 757 matching lines...) Expand 10 before | Expand all | Expand 10 after
1253 std::vector<AutofillEntry> sync_entries; 1258 std::vector<AutofillEntry> sync_entries;
1254 std::vector<AutofillProfile> sync_profiles; 1259 std::vector<AutofillProfile> sync_profiles;
1255 ASSERT_TRUE(GetAutofillEntriesFromSyncDB(&sync_entries, &sync_profiles)); 1260 ASSERT_TRUE(GetAutofillEntriesFromSyncDB(&sync_entries, &sync_profiles));
1256 EXPECT_EQ(3U, sync_entries.size()); 1261 EXPECT_EQ(3U, sync_entries.size());
1257 EXPECT_EQ(0U, sync_profiles.size()); 1262 EXPECT_EQ(0U, sync_profiles.size());
1258 for (size_t i = 0; i < sync_entries.size(); i++) { 1263 for (size_t i = 0; i < sync_entries.size(); i++) {
1259 DVLOG(1) << "Entry " << i << ": " << sync_entries[i].key().name() 1264 DVLOG(1) << "Entry " << i << ": " << sync_entries[i].key().name()
1260 << ", " << sync_entries[i].key().value(); 1265 << ", " << sync_entries[i].key().value();
1261 } 1266 }
1262 } 1267 }
OLDNEW
« no previous file with comments | « chrome/browser/sync/glue/typed_url_model_associator.cc ('k') | chrome/browser/sync/profile_sync_service_password_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698